04 April 2013

How Long Was The Power Out?

I’ve always liked clocks, and especially digital clocks, since I built my first one using TTL ICs back in high school. What I don’t like about mains-powered digital clocks is that many of them need to be reset when power is lost.

Our power has been quite reliable lately, but I can remember coming home from work many times to find all the clocks blinking, and of course the first question was always, “How long was the power out?”

For years my answer to this question was to keep an inexpensive synchronous electric clock in my workshop. (For you youngsters, these are mains-powered analog clocks that derive their timing from the utility frequency via a small AC synchronous motor. They have the characteristic of simply stopping when the power goes out, and when it comes back on, they begin running again right where they left off. Hence it is a simple matter to determine how long the power was out.)

I became increasingly dissatisfied with this solution, as in recent times the clocks didn’t seem to last that long before the motor became noisy, and then they either stopped or no longer kept accurate time. They just don’t make ‘em like they used to.

Last year I began experimenting with Microchip’s MCP79412 Real-Time Clock/Calendar. This chip has several nice features, not the least of which is the ability to store power-down and power-up times associated with a power failure. Not long after I had designed a breakout board for the MCP79412 and written an Arduino library to accompany it, there was a discussion on the Arduino forum about logging utility power outages.

It occurred to me that the MCP79412 could form the heart of such a logger, using its memory in conjunction with the power-fail time-stamps to create a simple Arduino-based “Power Outage Logger”. It seemed like such a neat project that I went ahead and designed a circuit and had boards made. My MCP79412 breakout board plugs in as a daughter board, as does a standard 16x2 LCD display.

The <2> on the display indicates that two outages have been logged.
The red LED indicates that the most recent outage has not been viewed.
The logger will record up to seven outages in the RTC’s static RAM. After a new outage occurs, an LED is illuminated. Using the buttons, the user can scroll through the outages on the display. In addition to setting the date and time, the user can select from several time zones, set the RTC’s calibration register to trim its accuracy, and clear the log.

Displaying the second outage logged, which was ten minutes long.

Ironically, since I built the Power Outage Logger, we haven’t had any actual power outages. There has been scant evidence so far, but they tell me that spring (which can bring storms and maybe some real power outages) is in fact on its way. I hope I haven’t jinxed myself by writing that, but if nothing else, the logger does make a nice little desk clock as well.

The main board with the display and RTC removed.

The Power Outage Logger is an open source project. Hardware design (schematic and board) and software are both available on github.