Learn Automation with MINATA #35: PLC Timers and Counters — Turning One Signal into a Controlled Sequence
PLC Timers and Counters: Turning One Signal into a Controlled Sequence
Timers and counters appear in nearly every automatic machine: hold a valve open for an interval, count products, create a waiting time, limit the number of runs. What makes them useful is not the counting or the delay itself, but placing them inside the right state and reset condition.
A timer is not one single thing
- On-delay (TON): the timer output turns ON once the input has stayed ON for the preset time.
- Off-delay (TOF): the output stays ON for an interval after the input goes OFF.
- Pulse (TP): produces a pulse of defined width when it receives the right trigger.
- Retentive timer: accumulates time across conditions and needs an explicit reset.
Names and detailed behaviour differ between manufacturers. Always check the PLC documentation for the enable condition, the reset, the resolution, and whether the timer retains its value through a power loss.
How the three basic timers behave
| Type | When the input goes ON | When the preset (PT) is reached | When the input goes OFF |
|---|
| TON (on-delay) | Starts timing | Output turns ON | Output OFF, value back to 0 |
| TOF (off-delay) | Output ON immediately | — | Holds ON for PT, then goes OFF |
| TP (pulse) | Output ON and timing starts | Output OFF at the end of PT | Does not cut a pulse in progress |
A retentive timer differs in that it adds up time across several ON periods and returns to zero only on its own reset command. That is exactly why this type always needs a clear reset path — otherwise a value hangs over from one production batch into the next.
Counters need an edge rule too
A counter should receive a clear event, normally a rising edge from a filtered or pulse-caught sensor. If you feed the long ON state of a sensor straight into a count instruction, the counter may count once, or repeatedly, depending on how the program is built. Decide explicitly:
- Count on the rising edge, the falling edge, or as a high-speed pulse?
- What is the preset value, and what does the machine do when it is reached?
- Is the reset done by the operator, per batch, or by a fault condition?
- Does the value need to survive a power loss?
Timers, counters and the scan cycle
A software timer updates once per scan, so its accuracy is bounded by the scan time and the timer resolution. If the scan is around 10 ms, a 5 ms preset cannot be measured reliably; anything finer needs a hardware timer or an interrupt. A counter read by scan will likewise miss a pulse shorter than one cycle. When the pulse frequency exceeds what the scan can see — counting a high-speed encoder, for instance — use the built-in high-speed counter hardware rather than ordinary logic.
Example: a reject pusher and a product count
When the sensor detects a defective product, the PLC generates a rising edge, sets the "push" step, opens the valve for 250 ms with a pulse timer, then waits for the sensor confirming the cylinder has retracted before the next product may be counted. The counter increases only on the signal confirming that a product genuinely passed the measuring position — never from the conveyor command.
That design separates three jobs: detection, action and confirmation. If the cylinder does not return within the timeout, the program raises a fault instead of pushing at the products behind it.
Common mistakes
- Using a timer to paper over a mechanical or sensor fault instead of having a confirmation signal.
- Not resetting a counter at a batch change or after a fault.
- Placing the same timer or counter in several networks, so nobody can tell who writes the value.
- Setting a time shorter than the scan or I/O resolution.
- Letting the HMI change a preset without limits and without an audit trail.
A worked engineering situation
In a packing station, a timer can limit how long the machine waits for a part while a counter holds the quantity for the batch. Each value needs a clear unit, a valid range, a place to enter it on the HMI and a reset condition. When an alarm is raised, show the machine step, the timer or counter value and the condition not yet satisfied, so the operator does not have to guess.
The actual times must be commissioned against the real machine speed, the mechanism, the sensors and the assessed risk.
Checklist
- [ ] The timer or counter type matches the behaviour you actually want.
- [ ] The trigger is a clear event or edge, not an ambiguous signal level.
- [ ] Reset, timeout and fault response are all explicit.
- [ ] Preset, unit and limits are recorded in the documentation and on the HMI.
- [ ] No timer stands in for a safety signal or a mandatory confirmation.
Good timers and counters give a machine both rhythm and memory. Post #36 moves from digital I/O to analogue signals: 0–10V and 4–20mA.
Read more automation knowledge at MINATA: https://minatavn.com/en/blog/industrial-automation
Previous — #34: PLC outputs, relay and transistor: https://minatavn.com/en/blog/automation-34-plc-outputs-relay-transistor
Next — #36: Analogue signals, 0–10V and 4–20mA: https://minatavn.com/en/blog/automation-36-analog-signals-0-10v-4-20ma
View all MINATA technical articles