Reliable Projects 1: WatchDog Timers for Raspberry Pi and Arduinos
Summary: In this series of postings we look at how to set up the Raspberry Pi and Arduino internal watchdog timers. We also explain why an external WatchDog Timer, such as the SwitchDoc Labs Dual WatchDog Timer is a better choice in many, but not all, systems.
- Part 2 – How to Set Up the Raspberry Pi Internal WatchDog Timer
- Part 3 – How to Set Up the Arduino Internal WatchDog Timer
- Part 4 -Internal Versus External WatchDog Timers / Issues with Internal Timers
- Part 5 -Adding an External WatchDog Timer to your Project
Introduction to WatchDog Timers
Computers sometimes lose their way. A power glitch, RFI (Radio Frequency Interference), hanging peripherals, or just plain bad programming can cause your small computer to hang causing your application to fail. It happens all the time. How often do you have to reboot your PC? Not very often, but once in while your Mac or PC will freeze making you have to power cycle the computer. Raspberry Pi’s will sometimes freeze because of a task not freeing up sockets or consuming other system resources and from power supply fluctuations. Arduinos sometimes freeze because of brownouts on the power line or a short power interruption or because of running out of system resources such as RAM and/or stack space, which is a very limited resource in an Arduino. Sometimes even programmers (gasp!) make mistakes.
In small computers, you give your device the chance to recover from faults by using what is called a WatchDog Timer (WDT). A WDT is an electronic timer that is used to detect and recover from computer malfunctions. If the computer fails to reset the timer (also called “patting the dog”) on the WDT before the WDT timer expires, the WDT signal is used to initiate either corrective actions or simply to reboot the computer.
Will the use of a WatchDog Timer make your computer project more reliable? The answer is yes. The proper use of a WatchDog timer can make your computer reboot when it gets lost. A known problem with some Python libraries on the Raspberry Pi is that some of those libraries don’t properly release sockets and after a long period of time (days generally – not weeks) the Raspberry Pi will hang or thrash because it is out of resources. A properly designed program could detect this and reboot the computer, but a WatchDog Timer can be used to cover a whole multitude of sins with one fell swoop. In Project Curacao, we use a WatchDog Timer to reset the Battery Power Watchdog in case of a brownout or an RFI upset event.
In the next few posts, we will be discussing the following topics:
- Part 2 – How to Set Up the Raspberry Pi Internal WatchDog Timer
- Part 3 – How to Set Up the Arduino Internal WatchDog Timer
- Part 5 -Adding an External WatchDog Timer to your Project
10 Trackbacks / Pingbacks
Comments are closed.