GlossaryWatchdog timer
Watchdog timer
A watchdog timer is a hardware timer that resets a processor, or puts a system into a safe state, if the software stops signaling that it is running correctly. Firmware has to restart, or kick, the timer at regular intervals. If a crash, hang or runaway code stops those kicks, the timer expires and triggers recovery.
How it works
The watchdog counts down from a set timeout. Healthy firmware resets the count before it reaches zero, typically from a point in the main task that runs only when the system is working. If the count reaches zero, the watchdog asserts reset or a fault signal.
Simple watchdogs only check that kicks keep coming. Window watchdogs also reject kicks that come too early, which catches code stuck in a tight cycle that keeps kicking. Some watchdogs require a specific sequence or a calculated answer to a question, so only correctly running code can respond.
Independence matters. A watchdog inside the processor and running from the same clock shares failures with the code it watches. IEC 61508-7, which describes techniques for functional safety, covers program sequence monitoring with a watchdog that has a separate time base and time window, and logical monitoring of the program's sequence. A NASA technical report describes building an external watchdog in separate programmable logic for a microcontroller for this reason.
Watchdog timer vs brownout detector
A brownout detector watches supply voltage and resets the processor when it drops too low. A watchdog watches the software and resets when the code stops behaving. They cover different failures, and most designs use both.
Why it matters
Firmware hangs from rare timing bugs, memory corruption or electrical noise are hard to rule out entirely. A watchdog turns a frozen controller into a quick restart or a controlled stop. In robots and drones, the difference between a frozen motor controller and one that resets to a safe state can be a crash or an injury.
How to get it right
- Kick the watchdog only where the system's main work has completed, never from a timer interrupt alone.
- Use a window watchdog, or an external one with its own clock, for safety-related functions.
- Set the timeout from the longest normal task time, with margin.
- Define a safe state, such as motors off, for what happens on expiry.
- Record the reset cause and log it, so field resets are traced.
- Test by forcing hangs during development.
Watchdog timers in robotics and drone hardware
Flight controllers, motor drivers and robot joint controllers all run watchdogs. A drone motor controller that loses commands or hangs has to stop or go to a safe output quickly. Robots with functional safety needs pair internal watchdogs with an external supervisor on its own clock, so one fault cannot disable both the control code and its monitor.