Timers in PLC Programming: TON, TOF, TP Explained
Timers in PLC Programming: TON, TOF, TP Explained
📘 We've expanded this into a fully illustrated guide. See PLC Timers Explained: TON, TOF and TP for timing diagrams of every timer, ladder examples, and the per-dialect naming table.
Almost every PLC program uses timers. A motor that must run for exactly 30 seconds before a valve opens. A conveyor that waits 500 ms for parts to settle. An alarm that only triggers if a fault has been present for more than 3 seconds.
IEC 61131-3 defines three standard timer function blocks: TON (on-delay), TOF (off-delay), and TP (pulse). Each is a self-contained function block that you instantiate by name, wire up with inputs and outputs, and call every scan.
How Function Blocks Work
Before diving into the specific timers, it is worth understanding the function block model. A function block (FB) is a reusable block of logic with:
- Input pins — values you pass in (e.g., enable signal, preset time).
- Output pins — values the block produces (e.g., done bit, elapsed time).
- Internal state — persistent variables retained between scans (the accumulated time, for example).
Every timer instance is a separate variable. If you need two independent timers, you create two instances: Timer1 and Timer2. They share the same TON type but have completely independent accumulators.
TON — Timer On-Delay
TON starts accumulating time when the enable input IN transitions to TRUE. After the elapsed time ET reaches the preset PT, the output Q goes TRUE. If IN drops before PT is reached, ET resets to zero immediately.
TON inputs and outputs
| Pin | Type | Direction | Description |
|---|---|---|---|
| IN | BOOL | Input | Enable — starts the timer when TRUE |
| PT | TIME | Input | Preset time — target duration |
| Q | BOOL | Output | Done — TRUE when ET >= PT |
| ET | TIME | Output | Elapsed time — how long the timer has been running |
TON structured text example
(* Delay-start: Output energises 5 seconds after sensor detects a part *)
StartDelay(IN := PartDetected, PT := T#5s);
IF StartDelay.Q THEN
ConveyorMotor := TRUE;
END_IF;
TON timing diagram
IN: _____|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|_____
PT
ET: _____|///////‾‾‾‾‾‾‾‾‾|_____
^
Q: ___________________|‾‾‾‾‾‾‾‾
When to use TON
- Start delay — an output energises only after a condition has been true for a specified time. This prevents transient sensor spikes from triggering a response.
- Watchdog / timeout detection — if the expected feedback signal has not arrived within PT, trigger an alarm.
- Timed sequence steps — after each step completes, TON delays the transition to the next step.
TOF — Timer Off-Delay
TOF behaves opposite to TON. The output Q is TRUE whenever IN is TRUE. When IN drops to FALSE, the timer starts and Q stays TRUE for PT before going FALSE.
TOF inputs and outputs
| Pin | Type | Direction | Description |
|---|---|---|---|
| IN | BOOL | Input | Enable input |
| PT | TIME | Input | Off-delay preset time |
| Q | BOOL | Output | Output — TRUE while IN is TRUE, then for PT after IN drops |
| ET | TIME | Output | Elapsed time since IN dropped |
TOF structured text example
(* Cooling fan continues running for 60 seconds after motor stops *)
CoolingDelay(IN := MotorRun, PT := T#60s);
FanMotor := CoolingDelay.Q;
TOF timing diagram
IN: ‾‾‾‾‾‾‾‾‾‾|_____________________
PT
Q: ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|________________
^ drops after PT
When to use TOF
- Post-run actions — a lubrication pump that runs for 30 seconds after the main machine stops.
- Debounce on off-edge — a sensor that briefly drops out should not trigger a fault if it recovers within 200 ms.
- Indicator lamp hold — an alarm lamp that stays lit for a minimum duration even if the condition clears immediately.
TP — Timer Pulse
TP generates a fixed-width output pulse of exactly PT duration on a rising edge of IN. Once the pulse starts, changes to IN do not affect it — the pulse runs to completion.
TP inputs and outputs
| Pin | Type | Direction | Description |
|---|---|---|---|
| IN | BOOL | Input | Trigger — rising edge starts the pulse |
| PT | TIME | Input | Pulse width |
| Q | BOOL | Output | TRUE for exactly PT after rising edge |
| ET | TIME | Output | Elapsed time during the pulse |
TP structured text example
(* Fire a 500 ms valve pulse on a rising edge of the cycle start signal *)
ValvePulse(IN := CycleStart, PT := T#500ms);
DoseValve := ValvePulse.Q;
TP timing diagram
IN: __|‾|_____|‾‾‾‾‾|__________
^ ^
Rising edge Does not extend pulse
starts PT
Q: __|‾‾‾|__________|‾‾‾|_____
PT PT
When to use TP
- Dosing pulses — a chemical dosing valve that opens for exactly 200 ms per cycle.
- Starter kick — a pneumatic system that needs a 100 ms air pulse to trigger a latch.
- De-bounce protection — produce a clean one-shot pulse from a noisy input.
TIME Data Type in IEC 61131-3
Timer presets use the TIME data type. The literal format is T#<value><unit> where units are:
ms— millisecondss— secondsm— minutesh— hoursd— days
Examples: T#500ms, T#5s, T#1m30s, T#2h.
You can also use a TIME variable for a settable preset:
ConveyorDelay : TIME := T#2s; (* Default 2 seconds, can be changed at runtime *)
ConveyorTimer(IN := SensorActive, PT := ConveyorDelay);
Allen-Bradley Timer Equivalents
Allen-Bradley (RSLogix/Studio 5000) uses the TIMER data type with fields:
| Field | Type | Description |
|---|---|---|
| .PRE | DINT | Preset (in ms) |
| .ACC | DINT | Accumulated value (in ms) |
| .DN | BOOL | Done bit (equivalent to IEC Q) |
| .EN | BOOL | Enable bit |
| .TT | BOOL | Timer timing bit (true while timing) |
AB timer instructions: TON, TOF, RTO (retentive on-delay — keeps accumulator on loss of enable). Reset uses a separate RES instruction on the timer tag.
(* AB Structured Text equivalent *)
Motor_Timer.PRE := 5000; (* 5000 ms *)
TON(Motor_Timer); (* Calls the TON instruction *)
IF Motor_Timer.DN THEN
Output := TRUE;
END_IF;
Siemens Timer Equivalents
On S7-1200/S7-1500 in TIA Portal, IEC-standard timers are the recommended approach and use the same TON, TOF, TP names with IEC semantics. On older S7-300/S7-400, Siemens used proprietary timers (S_ODT, S_OFFDT, S_PULSE) with a different calling convention.
Using Timers in the Simulator
The Timers and Counters lesson walks through all three timer types with interactive exercises. For a practical application, the Tank Fill scenario uses a TON timer to enforce a minimum fill time before the outlet valve opens.
For sequencing multiple timed steps, see The PLC Scan Cycle Explained to understand how timer elapsed time updates relative to the scan.
Practice this yourself in the simulator — 3 scenarios free. No install. No credit card. Write real ladder logic against a live machine model in your browser.