Troubleshooting
Why a CODESYS TON output stays on after its rung goes false
Short answer
A false EN does not reset a CODESYS TON — it stops the block from executing at all, so Q holds the value from the last executed call. Route the process condition to IN, keep the enable permanently true, and the timer resets itself the way the standard intends.
On this page
Q stays on because the rung condition gates EN, the execution enable, instead of IN. A false EN stops the function block from executing at all, and a TON clears Q only when it executes with IN false — so the instance simply keeps the last value its code produced. Route the process condition to IN and keep the call unconditional: insert the timer as a plain function block rather than an enabled box, or leave EN permanently true with no contacts ahead of it. The reset you have been applying to Q clears the bit for one scan and leaves the fault in place.
What EN does that IN does not #
IEC 61131-3 gives a function block instance stored state that survives from one invocation to the next, and the block body updates its outputs only when the body runs. The standard's on-delay timer has four variables: IN, PT, Q and ET. While the block executes with IN true, ET counts up toward PT and Q becomes true when ET reaches PT. An invocation with IN false executes the reset path: Q goes false and ET returns to zero in that same invocation.
EN is not one of those four. It is execution control, the enable the ladder editor attaches to a box: EN false inhibits execution of the body. An inhibited call is not a reset — it is no call. Inputs are not even registered, and outputs hold whatever the last executed invocation left them.
| EN | IN | Result in that invocation |
|---|---|---|
| true | true | Body runs; ET advances toward PT; Q true once ET reaches PT |
| true | false | Body runs the reset path; Q false, ET zero |
| false | either | Body does not run; Q and ET hold their last executed values |
Why the freeze lands exactly at the end of the cycle #
The trap closes at completion. The contact that starts the timing also feeds the enable, and the coil the timer switches off belongs to that same condition, so the sequence stops at precisely the wrong point:
- The process condition closes: EN true and IN true, ET counts.
- ET reaches PT: Q goes true.
- The logic on Q switches coil K4 off.
- That change opens the contact feeding the rung, and EN goes false.
- From this scan on, the instance is never invoked, the IN-false reset never executes, and Q stays true indefinitely.
In the rung that typically produces this fault, the coil node also feeds IN, which means the program can read the IN line anywhere it read the coil. That convenience is what makes the wiring easy to get wrong: one node looks like a timer command in one place and an execution gate in another.
The numbers on a 5-second cycle #
Illustrative worked example: PT = 5 s in a task with a 10 ms cycle time.
- Timing: 5000 ms ÷ 10 ms per invocation = 500 invocations. Q rises on the 500th.
- Freeze: if the enable opens at completion, invocations 501 onward never run. The hold is unbounded — with IN false for 60 000 ms, Q is still true, because zero invocations have executed since completion.
- After rewiring: EN permanently true, condition on IN. When the condition opens, the reset executes on the next invocation, at most 10 ms later: Q false, ET 0.
The numbers assume the 10 ms task; a 20 ms task gives 250 invocations to Q and a worst-case reset latency of 20 ms. The freeze duration does not depend on the task at all — it depends on EN never returning true.
Confirm it online before you rewire #
- Watch five things together in the online view: the contact feeding the box, EN, t2.IN, t2.Q and the coil. The fault is the combination EN false with Q true.
- Prove the block is healthy: hold EN true and take IN false. Q clears within one task cycle with no reset instruction anywhere in the program.
- Confirm the mechanism: with the process condition open and EN false, Q holds scan after scan. That hold, not a broken timer, is the diagnosis.
- Search the program for a second call of the same instance and for other writes to the coil. A later rung that sets the coil again will disguise the sequence and survive the rewire.
- If the transitions hide inside one scan, use the engineering environment's trace function, or work the inputs one at a time in a test project.
Make these forced checks with the machine outputs isolated or in a test project: forcing a live process condition can start real equipment.
Rewire the call #
- Replace the enabled box: delete it and insert the timer through the editor's Insert / Function Block command, which places the block with no EN pin. Menu wording varies between versions; the pin set is what matters.
- Wire the process condition — the contact that used to feed the enable — to IN.
- Leave the completion logic on Q as it is; the timing behavior does not change.
- If the version forces Box with Enable, tie EN to the left power rail with no contacts ahead of it, and still put the condition on IN.
- Check the container. A TON called inside conditionally executed code is skipped the same way; move the call to code that runs every scan. A call wrapped in an IF statement in structured text is the same suppressed call — the placement question behind when a CODESYS TON works in structured text but not ladder is the one that settles this fault too.
- Compile, download with the outputs isolated or to a test project, then run the cycle proof: command false, Q false; command true, Q false until ET reaches PT; Q true and the coil does its work; command opens; Q clears on the next invocation. Repeat once, then interrupt a cycle halfway and confirm both paths reset.
When a frozen output is the goal #
Gating a block with EN is legitimate when holding the last computed result is the intent: holding a sampled measurement while a station is empty, or freezing a computed setpoint during a bypass. Two rules apply. The block's documented behavior must tolerate skipped calls, and the intent belongs in a comment, because the next technician will read a frozen output as a fault. A TON fails the first rule whenever the process needs it to answer an off command, which is every ordinary on-delay use. Nor is a skipped call a pause: elapsed-time behavior after a suppressed interval is not the reset behavior, and a pause function needs logic built and tested for it.
The decision by case #
- Condition ahead of EN on a TON: rewire — condition to IN, EN unconditional. This is the fix for the fault in this article, in every version that offers either insertion method.
- Editor offers only the enabled box: EN straight from the left rail, condition on IN. The box then behaves like a plain inserted block.
- Freeze is deliberate: keep it, comment it, and keep it off timers.
- Timer sits in conditionally executed code: move the call out. An always-enabled box inside a skipped routine still never resets.
Questions asked
Is EN part of the TON definition in IEC 61131-3?
No. The standard's on-delay timer interface is IN, PT, Q and ET. EN and ENO are the standard's execution control for ladder and FBD boxes: EN false inhibits execution of the body. The timer never sees IN change while the call is suppressed, so EN is an execution switch, not a timer input.
Will resetting or forcing Q false fix the rung?
It clears the visible bit for the scans you force it, but the call is still suppressed, so the instance has still not executed its IN-false reset. The next completed cycle freezes Q again and you are resetting it once more. Move the process condition to IN so the timer resets itself; forcing outputs is a diagnostic, not a fix.
Does the same freeze happen in structured text?
Yes. A TON call inside an IF branch in structured text is skipped whenever the condition is false, which is the same suppressed call as a false EN in ladder. The instance keeps its last outputs either way. Keep timer calls outside conditional branches and let IN carry the process condition.
When is it correct to gate a function block with EN?
Only on blocks whose documented behavior tolerates skipped calls and where the hold is wanted by design — never on a timer that must answer an off command. Write the intent in a comment so the next technician does not read the frozen output as a fault, and build a real pause function with tested logic rather than relying on a suppressed call.
How do I tell which insertion form my rung uses?
Look at the left edge of the box in the ladder editor. An inserted function block shows its own inputs, IN and PT for a TON, with no enable pin. An enabled box shows EN ahead of the block inputs, and anything wired ahead of EN gates execution. Menu names for the two insertions vary by version; the pin set does not.