Watchdog Timer

Fri, Oct 30 2009

After 7+ months of working on Practical Arduino I'm so into the habit of documenting things as I go that it feels like a waste to build something and *not* write it up as a project. It just doesn't seem natural.

So recently I was working on a work-related project that needed a hardware watchdog timer, and I couldn't help but write it up even though Practical Arduino (Volume 1, at least!) is now set in stone and almost ready for printing.

A hardware watchdog timer is a device attached to a computer that watches it for signs of life and if it doesn't detect anything happening for a defined timeout period it forces the computer to reset. In this case the computer was an Arduino that needed to be deployed over 1000Km away and if anything went wrong I'd have no way to reset it, so a simple watchdog timer was the answer.

The circuit is pretty simple - just a 555 and a few supporting components, so it doesn't take up too much space on a shield. In fact not everything you see on the shield below is even part of the watchdog since there were already other parts in place related to the other stuff this project will be doing.

Sorry about the poor quality pics - I had to take them with a webcam since I don't have a real camera handy, and it doesn't do macro very well!

The watchdog uses a 555 timer that slowly charges up a capacitor, and if the cap reaches a certain threshold the 555 then pulses the Arduino's reset line. Just for fun I connected a spare analog input to the capacitor and wrote a little sketch that reports the values, then put it into OpenOffice to plot it. This is the sawtooth waveform of the capacitor voltage when the Arduino is running normally, and you can see the voltage dropping each time it "pats" the watchdog to keep it happy and make it start the timeout again.

Because I'm building a bunch of these devices at the moment I set up a temporary workbench at the office (which is normally a "software only" zone) and got a bit of a production line happening.

The units themselves are simple power monitoring devices that use WiFi to connect to a 3G router and report their readings back to a web service.

Each of them will also have an LCD to display readings locally and report things like the API key used to access the web service, so I've spent way too much time stripping and soldering ribbon cable.

Overall it's come together quite nicely.