Timers in CODESYS: Complete Guide with TON, TOF, TP
Timers are one of the most important building blocks in PLC programming. In CODESYS, mastering timers like TON, TOF, and TP gives you precise control over delays, pulses, and sequence logic in industrial automation.
This guide walks through:
1. What Are Timers in Industrial Automation?
A timer in a PLC is a function block that measures time between events and changes outputs after a defined delay. Instead of wiring separate hardware time relays, PLCs implement timers in software while preserving the same concepts: on‑delay, off‑delay, and pulse timing.
There are a lot of uses of timers, such as:
- Delay starting a motor after a start command (e.g., pre‑lubrication time)
- Keep a fan running for a few seconds after a heater turns off
- Generate a fixed‑length pulse for alarms or indicators
- Sequence operations (conveyor start → clamp close → cylinder extend with delays)
In IEC 61131‑3‑based systems (like CODESYS), timers are standardized function blocks, so once you learn them in one platform, the logic transfers easily to others.
2. Visualizing Timer Behavior (Simple Graphs)Â
Below are simplified timing diagrams to build intuition. The horizontal axis is time; 0 = OFF / low, 1 = ON / high.
TON (Timer ON Delay)
2.1 On‑Delay Timer (TON)
The output turns ON after the input has been continuously ON for the preset time.
– When IN goes from 0 → 1, timer starts counting.
– After PT elapses, Q turns 0 → 1.
– If IN goes back to 0 before PT, timer resets and Q stays 0.
These graphs match the standard definitions adopted by IEC 61131‑3 timers TON, TOF, and TP.
3. Timer Types in CODESYS ( Practical use example):
We walk through Codesys. After creating a Ladder Logic Diagram project, as described in the video below, we double-click on PLC_PRG (PRG). In the Toolbox, under Function Blocks, we find TOF and TON timers. For the PT timer, we add it from an empty box in the toolbox under General, declare it as TP, and then name it, as we did with TON and TOF. Here is the description on Codesys:
Note (TIME Constants in CODESYS):
To set PT, CODESYS uses TIME literals with the prefix T#:
- T#100ms
- T#1s
- T#2.5s
- T#1m30s
You will type these directly into the PTÂ field when configuring the timer in Ladder or FBD.
And here is the entire description in video, including instructions on how to connect to the virtual PLC Codesys, as we described before her.
Â
Â
Summary
Timers are essential tools for introducing time‑based logic into your PLC applications:
- TON (On‑delay)delays turning ON an output until the input has remained TRUE for the preset time.
- TOF (Off‑delay)keeps an output ON for a defined time after the input goes FALSE.
- TP (Pulse)generates a fixed‑length pulse when the input sees a rising edge.
In CODESYS, these timers are standardized IEC 61131‑3 function blocks with clear inputs (IN, PT) and outputs (Q, ET). Using simple TIME constants like T#5s or T#500ms, you can define precise delays and pulses that make your automation logic safer, more robust, and easier to understand.
By:
- Creating a structured Ladder program
- Declaring TON, TOF, and TP timers
- Running everything on CODESYS Control Win V3
- Simulating inputs and watching live timer values
you gain hands‑on experience without needing any physical hardware.









