TON delays an output turning ON, TOF delays it turning OFF, and TP produces a fixed pulse on a rising edge. Each IEC timer needs its own instance, a Bool IN, a TIME preset PT, and gives Q and ET. Map the sensors into DB_IO, use the timers in an FB as multi-instances, and publish ET and Q to the HMI.
- TON = confirm a signal, TOF = keep something running, TP = fixed pulse.
- One instance per timer, never shared.
- Publish ET and PT so the operator can see how long is left.
How IEC Timers Work
| Timer | Q behaviour | Typical use |
|---|---|---|
| TON | Q = 1 after IN has been 1 for PT; resets when IN = 0 | Debounce, jam confirmation, delayed start |
| TOF | Q = 1 with IN; stays 1 for PT after IN falls | Fan run-on, conveyor run-out |
| TP | Q = 1 for exactly PT after a rising edge | Horn, pulse to a valve, one-shot actions |
Lab Flow: Three Timers at Work on One Conveyor
Every lesson in the Softwell PLC lab manual series follows the same six stages and the same address rule, so the code you write here plugs straight into the HMI lessons.
Stage 1Field Signals and PLC Tags
| PLC tag | Address | Type | Device / comment |
|---|---|---|---|
B50_Jam | %I6.7 | Bool | Photo-eye at the transfer point, 1 = blocked |
M50_Running | %I7.0 | Bool | Conveyor contactor feedback |
M51_Fan | %Q3.4 | Bool | Motor cooling fan |
H50_Horn | %Q3.5 | Bool | Warning horn |
Stage 2Input Mapping into DB_IO
// FC_InputMapping "DB_IO".B50_Jam := "B50_Jam"; "DB_IO".M50_Running := "M50_Running";
Stage 3Logic: FB_ConveyorTimers with Multi-Instances
// FB_ConveyorTimers – STAT: T_Jam, T_FanRunOn : TON_TIME / TOF_TIME; T_Horn : TP_TIME; #T_Jam(IN := "DB_IO".B50_Jam AND "DB_IO".M50_Running, PT := T#3S); // blocked 3 s = jam "DB_Conv".Jam := #T_Jam.Q; #T_FanRunOn(IN := "DB_IO".M50_Running, PT := T#4S); // fan keeps running 4 s "DB_Conv".Fan_Cmd := #T_FanRunOn.Q; #T_Horn(IN := "DB_Conv".StartRequest, PT := T#2S); // 2 s warning before start "DB_Conv".Horn_Cmd := #T_Horn.Q; "DB_Conv".JamET_s := DINT_TO_REAL(TIME_TO_DINT(#T_Jam.ET)) / 1000.0; // for the HMI // FC_OutputMapping "M51_Fan" := "DB_Conv".Fan_Cmd; "H50_Horn" := "DB_Conv".Horn_Cmd;
A latched jam becomes one bit in the alarm word from HMI alarm configuration; a timer used as a step watchdog appears in PLC step sequences.
Stage 4Link PLC Tags to the HMI
| HMI tag | PLC member | Used by |
|---|---|---|
DB_Conv_JamET_s | "DB_Conv".JamET_s | ET field / bar |
DB_Conv_Jam | "DB_Conv".Jam | Jam lamp and alarm |
DB_Conv_Fan_Cmd | "DB_Conv".Fan_Cmd | Fan lamp |
Stage 5Link the Graphics
| # | Object | Properties | Tag / event |
|---|---|---|---|
| ① | Output field ET | Format 9.9 s | DB_Conv_JamET_s |
| ② | Bar | Process value ET, maximum PT | DB_Conv_JamET_s |
| ③ | Lamps Jam / Fan / Horn | Appearance 0/1 with text | Status bits |
The same ET-against-limit bar is the step watchdog on the sequence status screen.
Stage 6Perform and Test: TON, TOF and TP Live
Three real uses on one conveyor: a TON confirms a jam only when B50 stays blocked for PT, a TOF keeps the cooling fan running after the motor stops, and a TP sounds the horn for a fixed time on a rising edge. Hold the buttons and read the timing diagram.
Troubleshooting
| Symptom | Likely cause | First check |
|---|---|---|
| Timer never finishes | IN drops every scan | Monitor IN online |
| Two timers interfere | Shared instance | One instance per call |
| TP restarts unexpectedly | Edge logic wrong upstream | IN of the TP |
| HMI ET always 0 | ET not copied to a DB member | FB code / HMI tag |
Hands-On Lab: Jam Detection, Fan Run-On and Horn Pulse
Hands-on- TIA Portal with an S7-1200 or PLCSIM
- Estimated time: 60 minutes
Wire and declare the signals
Declare B50_Jam, M50_Running, H50_Horn and M51_Fan.
Map into DB_IO
Copy B50 and M50 into DB_IO.
Write FB_ConveyorTimers
Add T_Jam (TON 3 s), T_FanRunOn (TOF 4 s) and T_Horn (TP 2 s) as multi-instances.
Link HMI tags
Publish ET in seconds and Q for each timer.
Build the timer screen
Show ET/PT fields and status lamps.
Test each timer
Hold and release each input and compare with the timing diagram.
You can predict Q from IN and PT for all three timers and see it confirmed online and on the panel.
Frequently asked questions
Does a PLC timer stop the program scan?
No. The CPU continues scanning the complete program while the timer function block updates its state each cycle.
Can multiple timer calls use the same instance?
Unrelated timers should not share an instance because the stored state will be overwritten. Assign a unique instance or a dedicated multi-instance member to every timer.
Which timer should I use for sensor debounce?
A short TON is commonly used when the signal must remain continuously true before it is accepted. Confirm the delay is compatible with the machine speed and safety requirements.
What is the difference between TON, TOF and TP?
TON delays switching ON, TOF delays switching OFF, and TP produces a fixed-length pulse on a rising edge regardless of how long the input stays true.
How do I show a timer on the HMI?
Copy ET and PT into a DB as Real seconds and display them as output fields or a bar, as in the step time bar of the sequence status screen.
Where should the timer instances live?
As multi-instances in the static area of the FB that uses them, or in a dedicated global DB. Never reuse one instance in two places.