PLC Simulator
Task execution and scan faults

PLC Watchdog Timers: Detect the Scan That Did Not Finish in Time

A PLC watchdog is a time boundary around controller execution. When a task takes too long—or does not start when expected—the runtime raises a fault according to platform configuration. The hard part is not defining the timer. It is proving why execution overran, what the controller and outputs did, and how recovery avoids an unsafe or unexplained restart.

Vendor behavior differs. CODESYS documents task watchdog time and sensitivity; Rockwell documents task watchdog major faults. Exact fault codes, output states, recovery handlers and allowable settings must come from the installed controller, firmware and safety design.

From scheduled task to watchdog evidenceevidence path

The watchdog observes elapsed execution, not whether the process result was logically correct. Code can finish inside the limit and still be wrong; correct logic can also overrun because its execution path is unbounded.

Answer first

What is a PLC watchdog timer?

A PLC watchdog timer monitors whether a controller task completes within an allowed execution time. If elapsed time exceeds the configured limit, the controller reports a watchdog or task-overrun fault and follows platform-specific handling. A watchdog protects runtime availability; it does not validate the control algorithm, prove safety integrity, or automatically identify the slow instruction. Diagnosis requires task statistics, the execution path, competing workload, fault records and the machine state at the first overrun.

Deadline, not delay

A watchdog is not a normal IEC timer in the user program. It is runtime supervision around task execution or scheduling.

First evidence matters

Capture the task, maximum scan, code path, communication state and first fault before clearing or increasing the limit.

Response is platform-specific

A task may halt, an application may stop, outputs may take configured defaults, or a major controller fault may occur.

Runtime boundary

A watchdog supervises a scheduled task, not one ladder rung

Start with the controller execution model because “PLC scan time” can refer to a continuous task, a periodic task, one program, one routine or the complete application cycle.

Watchdog placement in a task cycle

The platform may include interruptions, I/O service or other runtime work differently. Treat the exact measurement boundary as a controller-specific fact.

A cyclic PLC program is repeatedly scheduled by the runtime. On a simple controller, engineers often call one complete repetition the scan. On a controller with several tasks, each task has its own period, priority and execution budget. A ten-millisecond motion task and a one-hundred-millisecond supervisory task can therefore have different watchdogs and different consequences. Before diagnosing an overrun, record the exact task name, type, configured period, priority, watchdog, firmware and program calls assigned to it.

The watchdog normally measures elapsed task execution from task start until its configured programs finish. Elapsed time may include pre-emption by higher-priority work depending on the platform. That means a task can overrun even when its own logic did not change: a new high-priority task, communication load, motion processing or runtime service can consume the available wall-clock budget. Conversely, average task time can look healthy while one rare data path exceeds the limit.

Do not confuse this with an ordinary TON instruction. A TON models process time while the PLC continues scanning. A task watchdog is enforced by the runtime when execution is late. A communications watchdog supervises stale or missing messages. An external hardware watchdog may supervise whether the controller itself is alive. Each answers a different question and produces different diagnostic and output behavior.

Watchdog and timer terms that are often confused
MechanismWhat it supervisesTypical evidenceWrong assumption
Task watchdogTask completion within a runtime deadlineTask name, elapsed/max time, exception or major faultIt identifies the exact slow rung automatically.
Omitted-cycle supervisionWhether a scheduled task starts at allMissed releases, scheduler or priority diagnosticsIt is identical to one long task execution.
Communications watchdogFresh messages from a peer or deviceConnection status, sequence, timeout and data qualityThe controller CPU has stopped.
IEC TON / TOFA control condition over process timePreset, elapsed and done state in the user programIt protects the runtime from an infinite loop.
External hardware watchdogController or processor livenessHardware diagnostics, reset cause and module statusIt validates machine control logic.

Root-cause families

The slow scan may come from logic, scheduling, communications or a damaged execution assumption

Treat watchdog diagnosis as a boundary search. Find which workload or path changed before changing the limit.

Four watchdog root-cause families

The first category that correlates with the maximum-time excursion becomes the next proving test; it is not yet the final root cause.

Begin with data-dependent execution. A WHILE loop that waits for a process value can never complete because the physical value changes between scans, not inside the current scan. A FOR loop over a recipe array may be acceptable at fifty elements and destructive at fifty thousand. String manipulation, sorting, protocol parsing and bulk copies can create a rare but legitimate long path. Bound every loop, divide large work across scans and measure worst-case input rather than the friendly commissioning sample.

Next examine scheduling. Adding a faster periodic task or raising its priority can starve lower-priority work. Two tasks that share locks or resources can create blocking and jitter. A task period that is shorter than its worst execution time guarantees backlog. Record minimum, average, maximum and jitter by task over representative machine modes; one average number cannot reveal a deadline miss.

Communications and diagnostics also matter. Synchronous file operations, large recipe transfers, excessive online monitoring, dense trace capture and bursts of network processing can change timing. A programming workstation may make the fault appear only while many tags are watched. Test with and without the suspected workload, but preserve the same process and program state so the comparison is meaningful.

Finally consider environmental and platform changes: firmware upgrades, memory exhaustion, failing storage, a new module, power quality or temperature. These are less common than code and scheduling errors, yet they matter when the program fingerprint is unchanged. Use controller diagnostics and official service guidance rather than assuming every watchdog is a programming defect.

  • Search for loops whose exit depends on data that cannot change during the current scan.
  • Compare task maximum time and jitter before and after the last change.
  • Correlate overruns with recipe loads, communications bursts, trace capture and online clients.
  • Record firmware, module and program versions with the fault evidence.

Machine consequence

A watchdog fault is only understood when output and restart behavior are proven

The same phrase—watchdog timeout—can lead to different task, application and output states on different systems.

Watchdog consequence chain

Document observed behavior on the exact controller. Do not borrow the output response from a different platform family.

Do not write “the outputs turn off” as a universal watchdog rule. Output behavior depends on controller state, I/O ownership, module fault action, produced data, network connection response and any configured fault program. A physical output may also remain energized through interposing hardware or stored energy after the controller command changes. The safety assessment and electrical design must define the required response independently of ordinary software assumptions.

Fault handlers require restraint. A handler can save evidence, place ordinary logic into a documented state or support an approved recovery path. It must not repeatedly clear an overrun while the same unbounded path remains active. Some platforms escalate repeated watchdogs, and an automatic clear can hide a machine that is no longer executing its intended control interval.

Recovery begins from physical truth: identify which actuators moved, which state was retained, whether commands remain present and whether sequence data is coherent. Clear the initiating demand before returning the controller to run. Reinitialize only the state that the recovery design specifies; resetting every tag can destroy evidence or create an unplanned process transition.

Evidence sequence

Diagnose the first long path before the fault reset erases context

A disciplined sequence turns “the PLC froze” into a reproducible timing defect with a named execution boundary.

Watchdog diagnostic sequence

Change one factor at a time. A faster scan after several simultaneous edits does not show which edit corrected the defect.

First preserve volatile evidence. Photograph or export the fault log, controller mode, task monitor, maximum scan and timestamp. Record the machine state, recipe, batch step, active alarms and connected engineering tools. If the controller must be power-cycled for recovery, capture what will be lost first. A statement such as “faulted sometime on night shift” is not enough to distinguish a rare data path from accumulating load.

Then localize without adding heavy instrumentation that changes the timing. Use built-in task metrics, trace features and controller-supported profiling where available. Add coarse execution markers around major routines before instrumenting every rung. Binary search is useful: identify which half of the program contains the timing jump, then narrow further under the same stimulus.

Compare normal and failing runs using the same program version. Vary one input dimension: array length, message count, recipe size, active client count or machine state. If the execution time grows linearly or quadratically with data size, the curve itself is evidence. If time jumps only when a higher-priority task runs, scheduling is the stronger lead.

After correcting the path, repeat at worst credible load and retain margin. Run startup, normal production, fault, recovery, recipe change and online maintenance modes. A watchdog repair is incomplete if the controller survives a quiet bench test but still misses deadlines during the busiest production transition.

Watchdog evidence record
FieldWhy retain itExample proving question
Task and triggerNames the actual supervised execution boundaryWas it the continuous task or a periodic communications task?
Period, priority, watchdogDefines the schedule and time budgetDid configuration change before the first fault?
Last / average / maximum timeSeparates typical load from rare excursionsIs growth gradual, bursty or one specific outlier?
Program and firmware revisionConnects behavior to an exact buildCan the same binary and configuration reproduce it?
Machine mode and sequence stateIdentifies data-dependent pathsDoes the overrun occur during startup, recipe transfer or recovery?
External workloadExposes communications and online-tool correlationDid a trace, HMI poll burst or download coincide?

Engineering margin

Set the watchdog above proven worst-case execution and below unacceptable loss of control

A threshold is a risk and scheduling decision, not a number copied from another machine.

Watchdog threshold window

The acceptable window must be measured again after program, firmware, communications or task-configuration changes.

Measure first. Capture task execution across representative production, startup, changeover, fault and recovery conditions. Include the largest supported recipes and the intended number of communication clients. Use the maximum and distribution, not only the average. If maximum time is still climbing during the test, the sample has not established a stable bound.

Then define margin based on variability and process consequence. A threshold only slightly above a noisy maximum creates nuisance stops; a value hundreds of times the normal scan can allow a stalled control loop to persist too long. The correct number balances scheduler variation against the maximum tolerable loss of timely control and the platform fault response.

Document why the number is acceptable, who approved it and which test supports it. Treat a watchdog increase as a control change requiring review. If the program begins overrunning after a release, raising the limit may merely convert a visible fault into slower, less deterministic control.

Controlled verification

Test the watchdog with bounded injected load and a defined recovery plan

The goal is to prove detection, evidence, outputs and recovery—without creating an uncontrolled machine hazard.

Safe watchdog test progression

Stop at the lowest layer that answers the requirement. A live machine fault is not the first test environment.

Never add an infinite loop to a production controller as an informal experiment. Use a bounded workload whose duration can be increased gradually, or use a vendor-supported test method. Start offline or on isolated representative hardware. Define the stop condition, expected code, expected controller mode and method of recovery before the first run.

Verify more than fault appearance. Confirm the task and timestamp in diagnostics, what other tasks did, how local and remote I/O behaved, whether the HMI showed stale data, which outputs physically changed and whether the fault survived power loss. A screen capture of the fault code alone does not prove the machine consequence.

Finally prove recovery. Remove the injected cause, clear run demand, establish safe physical state, acknowledge according to procedure and return to run. Confirm that sequences do not resume from an invalid step and commands do not automatically re-energize. Store the result with the program and controller version so future changes can rerun the same acceptance case.

  • Use bounded, reviewable injected load rather than an uncontrolled infinite loop.
  • Record controller, task, I/O, HMI and physical response separately.
  • Test repeated-fault and recovery behavior as well as the first timeout.
  • Repeat the timing suite after changes to tasks, communications, firmware or program structure.

Design for bounded work

Prevent watchdog faults by making execution observable and bounded

The strongest fix is an execution design whose maximum work can be explained before the machine is commissioned.

Bounded PLC execution design

Timing is a maintained product property. A passing functional test does not replace an execution-time regression check.

Make every loop visibly bounded. Validate array limits before iteration, reject malformed lengths and avoid waiting inside a scan for external state. For algorithms that may process large collections, use a stateful worker that handles a fixed number of elements per cycle and exposes progress, completion and error states.

Separate fast control from slow support work. Motion, interlocks and critical process control need predictable tasks; reports, recipes, diagnostics and noncritical communication can often run at lower priority or in staged services. Shared data then needs an explicit consistency strategy so moving work does not create races or half-updated structures.

Treat timing like memory or I/O capacity: budget it, observe it and regression-test it. Record maximum task times for a known scenario set before release. Flag meaningful growth even when it remains below the watchdog, because disappearing margin is the earliest warning that the next feature may cross the boundary.

Verified product surface

What you can practise here today

The browser simulator makes the cyclic execution model visible and supports deterministic behavior tests, but it does not claim to emulate a vendor controller scheduler or hardware watchdog.

Scan-cycle highlighting

The learning interface shows how contacts, instructions and outputs are evaluated through repeated scans.

Deterministic test cases

Scenario cases reset to fresh state, apply timed actions and assert outputs or process state against explicit deadlines.

Loop and timing instruction practice

Structured Text and ladder exercises expose program paths whose behavior can be observed under repeatable inputs.

Fault-learning adjacency

Troubleshooting scenarios connect logic state, input evidence and output consequence without claiming controller fault-code parity.

Product boundary

The product does not currently emulate controller task priorities, pre-emption, hardware execution timing, vendor watchdog fault codes, fault routines, firmware scheduling, I/O fault-state modules or safety-task behavior. A future scan profiler and bounded watchdog fault-injection lab could expose educational timing evidence while remaining explicitly separate from target-hardware validation.

Answer-engine questions

Direct answers to the questions engineers ask

What is a watchdog timer in a PLC?

It is runtime supervision that checks whether a controller task completes within an allowed execution time. Exceeding the limit raises a platform-specific task exception or controller fault.

What causes a PLC watchdog fault?

Common causes include unbounded loops, unexpectedly large data work, higher-priority task interference, communication or logging bursts, blocking resources, configuration changes and less commonly firmware or hardware problems.

Is a PLC watchdog the same as a TON timer?

No. A TON measures a process condition while the program keeps scanning. A task watchdog is enforced by the runtime when scheduled execution exceeds its allowed time.

Do PLC outputs turn off after a watchdog timeout?

Not universally. Output response depends on controller, application, I/O module, network, configured fault handling and electrical design. Verify the exact target and physical machine response.

How do you diagnose a PLC watchdog timeout?

Preserve the fault and task metrics, identify the affected task and active machine state, correlate maximum time with code paths and workload, then reproduce with one controlled variable at a time.

Should I increase the PLC watchdog time?

Only after measuring worst-case execution and confirming the larger delay remains acceptable. Increasing the limit without finding new scan-time growth can hide a defect and reduce control determinism.

Can an infinite loop trip a PLC watchdog?

Yes. A loop whose exit cannot become true within the current scan can prevent the task from completing. Loops should have explicit finite bounds and error exits.

What is watchdog sensitivity?

On platforms that provide it, sensitivity modifies how consecutive or exceptionally long overruns trigger the watchdog. The precise rule is platform-specific and must be read from the target documentation.

How should a PLC watchdog be tested?

Use bounded injected workload on simulation or isolated representative hardware, define expected fault and output behavior first, preserve diagnostics, and prove controlled recovery before any machine-level test.

Does this simulator emulate vendor PLC watchdog faults?

No. It teaches scan behavior and deterministic testing but does not emulate controller scheduling, hardware timing, vendor fault codes, fault routines or safety-task watchdog behavior.

Turn the guide into evidence

Measure the path that owns the deadline

Start with the scan-cycle visualizer, identify one bounded execution assumption, and write a repeatable test that proves its worst credible input does not change the required behavior.

Inspect PLC scan behavior