MOULDLKnowledge BaseElectrical Knowledge Base3D Model DownloadsMembership
中文版Model Store »
Knowledge Base › Electrical Knowledge Base › How does a PLC watchdog timer work, and what should you do when the program times out?
HomeModels
Table of contents

On this page

PLC & Programming (100 articles)

Quick Reference

  • PLC & Programming
  • Electrical & Electronic Basics (monthly)(每月更新中)
  • Electrical Control & Drawings (monthly)(每月更新中)
  • Drives & Actuators (monthly)(每月更新中)
  • Sensors & Detection (monthly)(每月更新中)
  • Industrial Communication & Networks (monthly)(每月更新中)
  • HMI & Host Systems (monthly)(每月更新中)
  • Industrial Robots & Motion Control (monthly)(每月更新中)
  • Mechatronic System Integration (monthly)(每月更新中)
  • Fault Diagnosis & Standards (monthly)(每月更新中)

How does a PLC watchdog timer work, and what should you do when the program times out?

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.

1. What the watchdog timer actually counts

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.

2. Setting the monitoring time and where the reset happens

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.

3. What the PLC does after a timeout

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.

4. Why a program times out

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.

5. Order of recovery after a timeout

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.

6. Monitoring time and timeout signatures

ItemMeaningTypical rangeSetting or judging basis
Monitoring time settingLongest scan allowed in one passCommonly 2–3 times the normal scanOnline longest scan time
Reset intervalActual gap between two system resetsEquals the current scan timeOnline scan time display
Normal scan timeTime for one pass with the program steadyDepends on program size; measure itProgramming software statistics
Maximum scan timePeak seen during operationAny clear excess over the average needs investigationPeak statistics function
Input refresh timeTime to read the input imageRises with the I/O point countPoint count and bus speed
Program execution timeTime to execute the user programTied to instruction count and floating-point workInstruction statistics
Output refresh timeTime to write the output image to the modulesVaries with output count and bus speedPoint count and bus speed
Communication timePer-scan overhead for communicationRises sharply under heavy trafficStation count and data volume
Interrupt handling timeTime taken by service routinesThe more frequent and the deeper, the greater the effectNumber of sources and nesting depth
Diagnostic buffer entryTime and code of the timeout faultOne entry per timeoutRead from the diagnostic buffer

7. Notes

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.

8. References

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.

9. Points to watch

⚠️ Three common traps:
(1) Treating the timeout as a random fault and power-cycling again and again without reading the diagnostic buffer, so the real on-site cause — a blocking communication instruction — is never fixed;
(2) Scaling the monitoring time up several times "just to get it running", so a stalled program raises no alarm for a long time;
(3) Believing the watchdog can replace a safety circuit and putting the emergency stop in the program only, so the drive cannot be cut off when the device fails.

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.

Related reading

Related 3D models: Ready to build it? Download free 3D models & CAD drawings at MOULDL »
MOULDL · Electrical Knowledge Base · free self-study reference for electrical & automation engineers, 3D CAD models at MOULDL