The watchdog timer (WDT) is a monitoring timer that runs independently of the user program. The program resets it once every scan; if it is not reset within the set time, the PLC treats the program as stalled and stops. This article explains what the timer actually counts, what the PLC does on timeout, and the order in which the fault should be cleared on site.
It does not count time as such; it counts the gap between two resets. The time base comes from a clock inside the PLC that is independent of user program execution. The system program writes a reset at the start or end of every scan and the timer restarts from zero. The moment the gap between two resets exceeds the monitoring value, the timeout fault flag is set. It therefore watches whether a whole scan finishes on time, not whether some individual instruction is correct.
The monitoring time is normally not set equal to the scan cycle but with margin: a common approach is two to three times the longest normal scan, or start from the vendor default and adjust it against online scan data. The reset points are fixed in the system program — typically once after the input refresh and once after the output refresh, or at the start and the end of the scan. Adding a long timer in the user program does not extend the monitoring time unless there is another system reset along the way.
Vendors differ in detail but the direction is the same: the fault lamp and the diagnostic register are set, the CPU moves from RUN to STOP or into a fault-hold state, and the user program stops executing. The outputs go to their configured safe state — on-board output points are generally all switched off, while remote I/O stations and slaves may hold their last state or drop out according to their own configuration. The fault code is usually stored in a diagnostic buffer and can be read back with the programming software.
The root cause in every case is a single scan stretched beyond the monitoring value. The usual suspects: the user program contains a wait or a loop that depends on a field condition and keeps waiting when the condition is not met; interrupts are nested too deeply, or a long task runs inside an interrupt service routine; a communication instruction blocks while waiting for a reply; a large block of floating-point or string work is concentrated in one scan; a timed interrupt does work that should have been spread across the main program. A program that is not complex can still overrun when the communication load suddenly rises.
Read the diagnostic buffer and the fault code first, to confirm this is a timeout and not a module failure. Then monitor the current scan time, the maximum scan time and the execution time of each program section online, to locate the section that stretched the scan. Short-term measures — widening the monitoring time a little, splitting a long task across several scans, or slicing it with interrupts — only buy time. The real fix is structural: remove blocking waits, break long tasks into stages and hand fast signals to interrupts or high-speed modules. After the fault is cleared, power-cycle or reset, and confirm that every actuator is in a safe state before restarting.
| Item | Meaning | Typical range | Setting or judging basis |
|---|---|---|---|
| Monitoring time setting | Longest scan allowed in one pass | Commonly 2–3 times the normal scan | Online longest scan time |
| Reset interval | Actual gap between two system resets | Equals the current scan time | Online scan time display |
| Normal scan time | Time for one pass with the program steady | Depends on program size; measure it | Programming software statistics |
| Maximum scan time | Peak seen during operation | Any clear excess over the average needs investigation | Peak statistics function |
| Input refresh time | Time to read the input image | Rises with the I/O point count | Point count and bus speed |
| Program execution time | Time to execute the user program | Tied to instruction count and floating-point work | Instruction statistics |
| Output refresh time | Time to write the output image to the modules | Varies with output count and bus speed | Point count and bus speed |
| Communication time | Per-scan overhead for communication | Rises sharply under heavy traffic | Station count and data volume |
| Interrupt handling time | Time taken by service routines | The more frequent and the deeper, the greater the effect | Number of sources and nesting depth |
| Diagnostic buffer entry | Time and code of the timeout fault | One entry per timeout | Read from the diagnostic buffer |
The watchdog timer is a reliability measure, not a safety function. It can catch a program that has run away or stalled, but widening the monitoring time weakens that protection; and it neither replaces a safety relay nor meets a safety level. On machines with safety requirements, the emergency stop and the safety gates must be handled by an independent safety circuit, not by a watchdog in the program alone.
The general requirements and equipment tests for a PLC follow GB/T 15969.2 and the equivalent international standard IEC 61131-2, which covers operational monitoring and fault reaction for programmable controllers. The electrical connection, protection and earthing of peripherals follow GB 5226.1 and IEC 60204-1. The default monitoring value and reset method of a particular product are as stated in its manual; the discussion here is meant to explain the principle and the troubleshooting order.
Changing the monitoring time, the interrupts or the reset logic affects operational safety: verify the change in an offline program and keep a backup of the original; on site, work with the supply isolated, tested dead and locked off. Where a safety level is required, use a safety controller and safety circuit that meet the required performance level.