Tutorial: WatchDog Timer – Adding a Status Bit

Tutorial:  WatchDog Timer – Adding a Status WatchDog TimerBit

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.  Watchdog timers can help make your system more reliable.

Enter WatchDog Timers

If you don’t know what a WatchDog timer is, here is a series of articles explaining them in some detail.   The SwitchDoc Labs Dual WatchDog Timer is an external watchdog timer.   And it uses Grove Connectors!

IMG_4119 2One of the things missing on the SwitchDoc Labs Dual WatchDog Timer board is a status bit that tells us that the WatchDog has been triggered.   Why do we need this?   It would be good for the computer connected to the WatchDog to know that the latest reboot or reset came from the WatchDog timer and not from another source (like a power failure).   Using this knowledge, the computer may determine what to do knowing the the computer has hung or not come up properly when the power system recovered. This is definitely something we will add when we next revise this product.

 

William Lucid has built an Arduino based weather station and has added a JK Flip Flop to store this information and then be read by a GPIO from the Arduino and then reset by another GPIO bit from the Arduino.   Very elegant, very cool.

You can read more about it here:   https://forum.arduino.cc/index.php?topic=390110.0

and his software is here: https://github.com/tech500

Here is the log from the server showing the different types of resets:

Manual RESET:  08/01/2016 , 21:01:33
Watchdog RESET:  08/01/2016 , 21:04:24
Manual RESET:  08/01/2016 , 21:04:46
Manual RESET:  08/01/2016 , 21:07:21
Manual RESET:  08/01/2016 , 21:08:17
Manual RESET:  08/01/2016 , 21:09:23
Manual RESET:  08/01/2016 , 21:09:46
Watchdog RESET:  08/01/2016 , 21:11:07
Manual RESET:  08/01/2016 , 21:14:53
Watchdog RESET:  08/01/2016 , 21:16:21
Manual RESET:  08/01/2016 , 21:20:30

And the Schematic for the projects:
WatchDog Timer