Meridian Works
ENTR
Open the simulator
Waking the Machines

Lesson 3

PLC Timers Explained: TON, TOF, TP and RTO

The parts of a timer, the on-delay, the off-delay and the pulse, the retentive timer, which one to choose, and how to build a flasher.

From Usta's field manual in Meridian Works, a story-driven PLC course: chapter 3, “Time”. A program that cannot wait, and the instructions that let it keep time anyway.

A machine that cannot wait

Everything you built in the gatehouse answered at once. The switch went on and the lamp lit. You pressed the button and the contactor pulled in. The answer came inside the same scan.

Nothing on the packaging line works like that.

The horn must sound for three seconds before the belt starts. The dust extraction fan must keep pulling for half a minute after the line stops. Otherwise the shift breathes the dust the line left behind. The date stamper must strike for exactly half a second. How long the carton waits in front of it does not matter. Three different jobs, and what they share is time.

The problem is this: a program cannot wait. There is no instruction that says "stop here for three seconds". If there were, the processor would stay inside it. The scan would stop. The outputs would freeze at their last values. In the end the watchdog would put the CPU into STOP. That is the right thing to do. A PLC that does not scan is just a box with terminals.

So the job is done the other way round. The program does not wait, it comes back. Every scan it asks the same question: how long has this condition been true? If the answer is long enough, it acts.

That is exactly what a timer is. It is not a stopwatch you wind up and leave. It is an ordinary instruction, scanned every cycle. Each time it is scanned it looks at the clock and leaves an answer for the rungs that follow.

The scan is fast, the world is slow. The timer connects the two.

The parts of a timer

A timer has four parts. The two platforms give them different names, but the jobs are the same.

Part Siemens Rockwell
Input IN the rung itself (.EN bit)
Preset PT .PRE
Elapsed time ET .ACC
Done Q .DN

Input. A Siemens box has an IN pin. A Rockwell box draws no input pin; the rung itself is the input. Rockwell's .EN bit shows that power is reaching the input. In this editor, in both views, the power arriving at the left of the box is the input. While there is power, the timer counts. What happens when the power goes depends on the type of timer. The next three pages cover that.

Preset. How long to wait. It is written on the box.

Elapsed time. How much time has passed so far. It is a number in milliseconds that you can watch live. When somebody says "the delay does not work", this is the first place to look.

Done. The timer's answer. Rockwell also has a .TT bit. It is TRUE while the timer is counting.

TON T_Warn PT T#3s Start_Req Belt IN Q ET counts inside the box · Q comes up when ET reaches PT

In this editor the box sits in the middle of the rung. The power leaving the box is the done bit. The coil comes after the box. On the real platforms the habit is a little different. In Studio 5000 a TON usually sits at the end of its rung. Other rungs read its T_Warn.DN bit with a contact. In TIA Portal the Q output can be wired straight to a coil. Another rung can also read it as T_Warn.Q.

I have seen many apprentices draw a timer at the far right like a coil and then look for its output. In this editor the box is not a coil. It is a gate you pass through: conditions on the left, the box in the middle, the coil on the right.

Every timer needs a name of its own: T_Warn, T_Purge, T_Stamp. That name is the timer's memory. In Siemens it is an instance data block (an instance DB of type IEC_TIMER). In Rockwell it is a tag of type TIMER. The preset, the elapsed time and the status bits live there. If two rungs use the same name, they share the same memory and spoil each other. Use one timer name for one job. In these work orders the names are already in the symbol table.

Writing the time. Here the two platforms part.

  • In Siemens the time is a TIME constant: T#3s, T#500ms, T#1m30s. Always write the unit. T#30s says clearly what you meant.
  • In Rockwell the preset is a whole number of milliseconds (a DINT). Three seconds is written 3000, half a second 500. No unit is written. That is why it is a good habit to note the time in seconds in the rung comment.

This editor accepts both. T#3s and 3000 are the same time.

TON — the on-delay

TON (on-delay). The most used timer. Most timing questions on site are solved with it. It has the same name on both platforms.

Power reaches the input and the elapsed time starts to rise. The done bit stays FALSE. When the elapsed time reaches the preset, the bit goes TRUE. It stays TRUE for as long as the input stays. So the output arrives late. That is the whole job of a TON.

IN ET Q PT IN drops, ET = 0 too short: Q never comes

The second half of TON matters at least as much as the delay: when the input goes, everything resets. The elapsed time goes straight back to zero. The output drops. When the input comes back, the timer starts again from the beginning, with the full time. A TON does not remember the past.

This is not a shortcoming. It is what makes a TON safe for a warning horn. An operator starts the line. Two seconds later he changes his mind and presses STOP. Then he presses START again. He hears the full three seconds of horn, not the one second that was left. Somebody who has just walked up to the belt does not need to know what happened before.

Three jobs a TON does in every plant:

  • The warning delay. Horn first, then the machine. You build this in 3.1.
  • The staged start. The outfeed belt starts first. A few seconds later the infeed belt starts. That way product never drops onto a belt that is standing still.
  • The filter. A photo-eye can flicker at the edge of its beam. A level switch can open and close with a wave. Pass a signal like that through a TON with a short preset. 200 ms is a good start. Take the answer from the done bit. Nothing shorter than the preset reaches the rest of the program.

Do not forget the third one. Many "now and then" faults are an unfiltered sensor. The fix is a single timer.

TOF and the pulse — run-on and a single stroke

Two more timers. Between them they do most of the remaining jobs.

TOF (off-delay). When the input arrives, the output goes TRUE at once. There is no delay on the way in. The delay is on the way out. When the input goes, the output stays TRUE for the preset and then drops. Electricians call this run-on. It is everywhere in a real plant. The extraction fan that keeps pulling after the line stops is one example, because the dust does not stop when the belt does. The cooling fan that keeps turning after the drive stops is another.

A TOF has one property you need to know. If the input comes back while the output is running on, the timing starts again. Stop the line, start it, stop it again. The fan runs for a full thirty seconds from the last stop. That is what you want. 3.2 measures it.

TOF exists on both platforms and behaves the same. In Rockwell the .DN bit is TRUE while the input is TRUE. After the input drops, it goes FALSE when the preset has run out.

The pulse. Sometimes you want an output of fixed length, however long the input lasts. The stamper is an example. Whether the carton passes slowly or fast, the stamper must strike for 500 ms. The diverter solenoid is the same. You give a short push and the spring does the rest.

  • In Siemens there is a ready-made instruction for this: TP. On the rising edge of the input the output goes TRUE. It stays TRUE for exactly the preset and then drops. How long the input lasts does not matter. Touch the input for one scan or hold it for an hour, you get the same pulse, once. TP ignores the input while the pulse runs. The pulse does not stretch and does not restart. For a new pulse the input has to drop and come back.
  • Rockwell has no TP. The pulse is built from a few rungs. An ONS catches the rising edge of the input and sets a bit (OTL). That bit starts a TON. The TON's .DN bit resets the same bit (OTU). The result is the same as a TP: a single pulse that starts on the edge and lasts for the preset.

In this editor's Logix view, TP is taken out of the palette. If you want to use a TP, switch the view to Siemens and place the box from there. The program runs the same in both views.

IN TON TOF TP late by PT holds PT longer PT wide, always one input · three answers

One input, three answers. Look at this picture carefully. A TON delays the output coming on. A TOF delays the output going off. The pulse ignores both and gives a fixed rectangle. Most timing questions on site are really this one: which of these three do I want?

RTO — the timer that does not reset itself

The retentive timer (it accumulates time). In Rockwell it is called RTO, in Siemens TONR. It is the one apprentices misuse most.

It counts like a TON: the input arrives and the elapsed time rises. The difference shows when the input goes. A TON resets the elapsed time. A retentive timer keeps it. Take the input away for a second, a shift or a week. The elapsed time waits where you left it. When the input comes back, it carries on from there.

So this timer never resets itself. Something outside has to reset it. Here the two platforms part.

  • In Siemens the TONR box has an R input. While R is TRUE, the elapsed time is held at zero and the output drops.
  • In Rockwell the RTO box has no reset pin. The reset is a separate rung: a condition and a RES instruction naming the same TIMER tag. When RES runs, .ACC is cleared and .DN drops.

In this editor the RTO box has a reset (Reset) field. You can use it in both views. In a real Studio 5000 program the same job is done by a RES rung.

Read like that, it looks like a defect. In fact it is the reason this timer exists. It does not measure a delay. It measures total running time. That is the number the maintenance team really cares about.

A belt does not wear out by the calendar. It wears out after it has turned for a certain time. So you connect a retentive timer to the belt's contactor. You set the preset to the service interval. When the time is up, a lamp lights and tells the fitter the machine is due for service. The fitter does the greasing. Then he turns the key in the panel. The key resets the meter and the count starts again.

That key is the whole discipline of the job. Only the person who did the work resets the meter, on purpose and by hand. If the program resets it by itself, you have built a meter that lies. A meter that resets on a stop, on a start or on any other condition is like that. The bearing fails when its time comes, but the lamp never lights.

In 3.4 you build this at a small scale: twenty seconds instead of five hundred hours. To the logic there is no difference.

A TON asks "has it been long enough?". A retentive timer asks "how long has this machine worked in total?". Never wire a service meter so that it can reset itself.

Which timer, and how to build a flasher

Before you start drawing, say the requirement out loud and find its row in the table.

What the plant wants Siemens Rockwell Why
Wait, then act TON TON the output comes late
Act now, keep going for a while after the command ends TOF TOF the output goes late
A pulse of fixed length, whatever the input does TP ONS + TON the output is a fixed rectangle
Total running time for maintenance TONR RTO the time accumulates
Fault if a condition lasts too long (timeout) TON TON wired to the condition itself
Ignore signals shorter than X (filter) TON TON a short signal never reaches the preset

The last two rows are the same instruction facing opposite ways. Picture a valve that has been told to open. Its limit switch has not made yet. A TON on that condition is a timeout. If the condition lasts longer than the preset, something is wrong and the timer's output is your fault bit. A TON on a noisy input is a filter. If the condition lasts less than the preset, it never happened. Same box, opposite meaning. In both, the question is the same: has this condition been true long enough to believe it?

Building a flasher. A Siemens CPU's clock memory gives you bits that blink at fixed frequencies. But those bits run on their own. They do not know when your warning started. Rockwell has no such bit at all. If the warning must start lit every time, you build the flasher yourself. Two TONs chasing each other are enough.

TON T_Lit T#500ms TON T_Dark T#500ms Q sets Beacon_Dark Q sets Flash_Rst Flash_Rst breaks the first rung — and the cycle begins again 0.5 s lit 0.5 s dark

The first timer measures the lit half second. When it is done, it sets the "dark" bit TRUE. That bit puts the lamp out and starts the second timer. When the second timer is done, it breaks the first timer's rung. The dark bit drops. The second timer drops with it. The cycle goes back to the start and begins again. Half a second lit, half a second dark. The price is two timers and two bits.

There are two details, and both were learned the hard way. The first is rung order: first timer, then second timer, then the lamp. That way the cycle resolves inside a single scan. The second: gate both timers with the condition you are warning about. That way the flasher starts from the beginning every time. Nobody trusts a lamp that starts its warning halfway through a dark half second.

You will need all of this page in 3.5.

Time is measured, not counted

One last subject. If nobody tells you, it will cost you a night.

A timer does not count scans. It measures the clock.

Every time a timer is scanned, it looks at the processor's clock. It adds the time since it was last scanned to its elapsed time. That is the right way to do it. Whether the scan takes two milliseconds or nine, your three-second delay is three seconds.

But one thing follows from it. A timer is updated only when it is scanned. If the program skips it, the timer sees nothing. What happens when it is scanned again can differ by platform. In this simulator the timer looks at the clock and adds all the missing time at once. In other words, it jumps forward. Often it comes back already done.

You have not met jump instructions yet. They come in zone 6. But keep the trap in mind now. If the program jumps over a section, or stops calling a block, a timer in there is not paused. It is blind.

Do not put timers inside code you skip. Put timers where they are scanned every cycle. Let their input conditions, not the program's structure, decide whether they run. If you want to stop a timer, take away its input, not its scan.

One smaller rule. Do not compare the elapsed time with a number to make your own done bit. The timer already has its own bit: Q or .DN. It is calculated in the same instruction, in the same scan. It is never one rung behind.

The clock is honest, the scan is not. Put your timers where the scan cannot miss them.