A watchdog timer (sometimes called a watchdog or just watchdog) is an electronic timer that is used to detect and recover from computer malfunctions in programmable logic controllers (PLCs). The watchdog timer resets itself periodically and triggers a system reset if it is not reset before the time interval lapses. This helps improve the reliability and stability of the PLC system.
PLCs are special computers used in industrial control systems to automate processes and machinery. They are designed to be extremely reliable and fault-tolerant. However, they can still experience malfunctions like any computer – for example due to electronic noise, power glitches, software bugs, etc. The watchdog timer acts as an automatic safeguard to detect such faults and reset the system before they lead to larger failures.
How watchdog timer works in PLC
The basic working principle of a watchdog timer in a PLC is as follows:
- The watchdog timer circuit is built into the PLC hardware or software. It consists of a counter that regularly counts down to zero from a preset value.
- The PLC program must periodically restart or ‘kick’ the watchdog timer to prevent it from reaching zero. This is done by writing to a specific watchdog register that resets the timer counter.
- As long as the PLC program operates normally, it will keep kicking the watchdog at regular intervals before timeout.
- If the PLC program crashes or malfunctions, it will fail to restart the watchdog timer.
- When the timer expires and counts down to zero, it will trigger a reset signal to restart the PLC and recover normal operation.
The time period for the watchdog timer is set carefully depending on the PLC application. Typical timeout periods range from tens of milliseconds to a few seconds. The PLC program needs to reset the timer before this timeout, otherwise the watchdog will reset the system.
Why watchdog timers are needed in PLCs
Watchdog timers provide an easy and effective way to automatically detect faults and reset malfunctioning PLC systems. Some key reasons why watchdogs are important in PLCs:
- Detect stuck programs – Watchdog can identify program crashes, infinite loops, deadlock conditions that ‘hang’ the PLC.
- Recover from faults – Timely resets can restore normal operation instead of waiting for manual intervention.
- Improve reliability – Periodic resets refresh entire PLC system and clear any latent issues.
- Identify specific failures – If watchdog keeps firing, it indicates a specific program or hardware problem.
- Low cost and simple – Watchdog hardware is inexpensive and easy to integrate.
Without a watchdog, minor faults can accumulate over time and lead to bigger failures that can be dangerous and expensive in industrial systems. The use of watchdog timers drastically improves the availability and safety of PLC controlled processes.
How to implement watchdog timers
Watchdog timers can be implemented in PLC systems in two main ways:
Hardware watchdog
A standalone hardware watchdog timer module is integrated into the PLC system. This watchdog timer circuit resets the PLC CPU directly if triggered. Some ways hardware watchdogs are implemented:
- Separate IC on PLC board – For example, computer chip LM61810-ISP
- Built-in CPU feature – Some PLC CPUs have inbuilt watchdog logic
- Addon watchdog cards – External cards can be purchased to add watchdog reset function
The main advantage of a hardware watchdog is that it functions independently and resets the PLC even if the PLC program or OS crashes completely.
Software watchdog
A software watchdog timer module is built right into the PLC firmware or programming environment. The PLC ladder logic has to include a watchdog timer instruction that needs to be periodically triggered. If the instruction is not executed within the timeout, the system is reset. Some ways software watchdogs are added:
- Firmware function blocks – Watchdog function blocks provided by PLC manufacturer
- Custom ladder logic – Programmer can code watchdog timer logic in ladder diagrams
- OS task monitor – Watchdog tasks built into PLC operating system
Software watchdogs have the advantage that they can be easily configured and modified without hardware changes. However, they rely on the program being in a functional state to operate.
Typical watchdog implementation in a PLC
A typical watchdog timer implementation in a PLC system would have the following key elements:
- Watchdog Timer – This is the watchdog circuit that performs the actual timing and reset functionality.
- Timer Value – Defines the preset countdown time, usually between 25 milliseconds to 5 seconds.
- Reset Logic – PLC program code that periodically restarts the watchdog before timeout.
- Reset Output – Signal from watchdog to reset the PLC CPU and peripherals.
- Status Flags – Indicators that show if watchdog has timed out and reset the system.
- Notification – Alert messages to notify operators of watchdog reset events.
The reset logic is usually implemented as a continuously executing portion of the ladder program. It resets the hardware or software watchdog timer register at regular intervals. If the rest of the program stalls or malfunctions, the timer expires and triggers reset signals to restart the PLC.
Examples of watchdog timers in commercial PLCs
Some examples of how major PLC manufacturers implement watchdog timers in their systems:
Allen-Bradley
- Hardware watchdog – Built into ControlLogix, CompactLogix, GuardLogix CPUs
- Software watchdog – RSLogix 5000 includes watchdog timer instructions
Siemens
- Hardware watchdog – On-chip feature of S7-1200/1500 CPUs
- Software watchdog – S7-300/400 has SW_WATCHDOG function blocks
Omron
- Hardware watchdog – Included in Sysmac NJ/NX PLCs
- Software watchdog – Uses WD_PNL instructions in ladder logic
Mitsubishi
- Hardware watchdog – Built-in watchdog timers
- Software watchdog – WDT and WDT_Start instructions
Most major PLCs provide both hardware and software watchdog timer options to improve reliability of the control system.
Tips for using PLC watchdog timers
Some design tips and best practices to follow when implementing watchdog timers in PLC systems:
- Select suitable timeout duration – Too long can miss faults, too short can cause nuisance trips
- Reset watchdog early and often – Reset at least 4x during timeout period
- Handle watchdog events – Design program logic to handle resets gracefully
- Retain variables – Use retain memory to preserve critical data across resets
- Hardware preferred – Hardware watchdog works independently of program
- Software watchdog as backup – Use as backup protection in case hardware watchdog fails
- Test thoroughly – Validate watchdog operation during commissioning
- Monitor flags – Check status flags to identify watchdog events
Properly configured watchdog timers will monitor the system continuously and provide a last line of defense against dangerous or costly PLC failures.
Summary
Watchdog timers are essential in PLC systems to achieve high reliability and uptime. They automatically detect program crashes and hardware faults, and reset the system before these issues can cascade into equipment damage or process disruptions. Both hardware and software watchdogs are used to maximize coverage. When implemented properly, the watchdog timer can identify problems early and restore normal operation quickly and safely.