Learn › Instructions
TOF: Timer Off Delay
A TOF is the mirror image of a TON. Its done bit turns on the moment the rung goes true, and stays on for the preset time after the rung goes false. Use it to keep something running for a while after the reason for running has gone.
How a TOF behaves
A TOF uses the same TIMER tag as a TON, with the same members: PRE, ACC, EN, TT and DN. What changes is when they turn on.
- Rung true: EN and DN turn on immediately, ACC is held at 0 and TT is off. Nothing is timing yet.
- Rung goes false: EN turns off and the timer starts counting. ACC climbs and TT is on while it does. DN stays on.
- ACC reaches PRE: DN and TT turn off. The delay is over.
- Rung goes true again during the delay: ACC jumps back to 0 and DN stays on. The delay will start over from zero next time the rung goes false.
So TOF's DN means "the rung is true, or was true less than PRE ago". Before the rung has ever been true, DN is off and the timer sits idle.
A timeline
Here's a TOF named FanT with a 10.0 second preset, driven by a heater bit. The heater runs for a while, switches off, comes back on briefly, then switches off for good.
| Time | Rung (Heater) | ACC | EN | TT | DN |
|---|---|---|---|---|---|
| 0 s (heater on) | true | 0 s | 1 | 0 | 1 |
| 20 s (heater off) | false | 0 s | 0 | 1 | 1 |
| 26 s | false | 6 s | 0 | 1 | 1 |
| 27 s (heater on again) | true | 0 s | 1 | 0 | 1 |
| 30 s (heater off) | false | 0 s | 0 | 1 | 1 |
| 40 s | false | 10 s | 0 | 0 | 0 |
The fan bit (driven by FanT.DN) is on from 0 s all the way to 40 s. The short off period at 20 to 27 seconds never reached the preset, so the fan never stopped.
Common uses
Run-on fans and cooldowns. The classic example. A heater, motor or lamp needs cooling for a while after it switches off:
| Heater |
|----] [------------------------------[TOF FanT PRE 10.0s]--|
| |
| FanT.DN Fan |
|----] [------------------------------------( )----|
Running a conveyor clear. A conveyor that feeds boxes should keep running for a few seconds after the last box passes the photo eye at its start, so the box reaches the end instead of stopping halfway.
| PE_In |
|----] [------------------------------[TOF ClearT PRE 4.0s]--|
| |
| Run ClearT.DN Conveyor |
|----] [---------] [------------------------( )----|
Ignoring short dropouts. If a signal sometimes drops out for a split second (a box with a gap in it passing a photo eye, say), a short TOF on that signal bridges the gap. The DN bit only goes off when the signal has really gone.
TON or TOF?
| TON | TOF | |
|---|---|---|
| Delays | turning on | turning off |
| DN when the rung goes true | after PRE | immediately |
| DN when the rung goes false | off immediately | off after PRE |
| Times while the rung is | true | false |
A good test: ask whether the delay should happen when the condition appears, or when it disappears. "Wait 3 seconds after the button is pressed" is a TON. "Keep going for 3 seconds after the button is released" is a TOF.
You can always build a TOF out of a TON and an XIO (time the rung being false), and some programmers do, but the TOF says what you mean in one instruction.
Try it in the Playground
- Open the Playground and add a push button with the tag
Heater. - Build rung 0:
XIC HeaterthenTOF FanT, and set the preset to 4.0 seconds. - Build rung 1:
XIC FanT.DNthenOTE Fan. - Press Run. Tap the button and watch Fan turn on at once, then stay on for 4 seconds after you let go. Tap again halfway through the delay and see ACC jump back to zero.
Common mistakes
- Expecting DN at startup. A TOF whose rung has never been true has DN off. It doesn't "start done".
- Resetting a TOF with RES. RES clears ACC and DN, which ends the delay early. That can be useful, but if the rung is still true the TOF turns DN straight back on the next scan.
- Using a TOF where a TON belongs. If your output comes on too early and goes off too late, you probably wanted the other timer.