HomeProjectsDownloadsLinks
Swarga Research

Projects > PiClock

An Analog Clock That Keeps Perfect Time

I love antique clocks. They have a certain old-world charm that, well, never gets old. The gentle sound of the quarterly chimes exudes a real homey feeling and hearkens back to a simpler time. One of the things I remember about visiting my great-grandfather's house back when I was a small boy was the sounds of his clocks. Of course, to him they weren't antiques - when he purchased them they were brand new. Old railway clocks are especially cool; it is because of the railroads' need to coordinate train movements across large distances that we have standardized time today. The railroads also pioneered some of the earliest methods for synchronizing clocks. Railroad clocks simply exude history.  A few years back I stumbled across this clock while surfing the web. It's an old railway station clock from the Chicago & North Western Railroad.

Seth Thomas Drop Octagon Clock

It's a classic style "Drop Octagon" wall clock, often called a "Regulator" because many of them had that word emblazoned across the front. They are also known as "Schoolhouse" clocks because they were very common in classrooms across the country. They were also commonly found in railway stations; often the railroad would order special versions with the railroad's name printed on the face and/or special mechanisms to keep the clocks synchronized. A similar clock appears in this photograph, taken in the office at the C&NW's Proviso rail yard.

Drop Octagon Clock in Proviso Yard
        Office

While I liked the idea of having such a clock in my home, I didn't particularly relish the idea of having to wind it every week, or reset it whenever it drifted or when daylight savings time begins or ends. I wondered if there were a way to combine the old-world charm of an antique clock with the modern convenience of never having to wind or set it, all while keeping perfect time. Perhaps I could upgrade an old clock with a new mechanism that would constantly synchronize itself with an atomic reference clock? Perhaps a stepper motor and some gears could replace the clock's original pendulum escapement and drive the clock's gear train electronically? Or maybe regulate the period of the pendulum using a computer-controlled electromagnet? As I continued to ponder, I realized that the chances of finding an original C&NW station clock seemed pretty low. Aside from the original web page that had prompted my interest, I have never seen another one of these clocks offered for sale anywhere. And even if I did find one, my proposed modifications would probably destroy the resale value of the clock, not to mention its historical significance. So I decided on a different approach.

Reproducing an Old Station Clock

I decided to duplicate as closely as possible the look and feel of the antique C&NW clock using modern components. I felt this would exude the charm of the old world clock without sacrificing any of the modern conveniences. As a starting point, I found a modern reproduction of a similar drop octagon wall clock on Amazon. Made by Seiko, it's a very nice clock in own right, with a modern quartz movement, digitized quarterly chimes, and a fake pendulum (it swings back and forth, but is not involved in any actual timekeeping functions). More importantly, it comes apart fairly easily, allowing me to customize it and install a new (old) clock face. My first thought was to use a photograph of the original clock's face, but I didn't have any pictures without the hands installed, and my Photoshop skills aren't sufficient to effectively remove them from the photo. So I found a picture of a similar clock face online, scaled it to the correct size, and added the C&NW logo and text. I then printed my new clock face out onto heavy-stock paper with a color laser printer and carefully cut the face out. I then lay the new face right on top of the old one, holding it in place with some Scotch tape. The clock's bezel hides the tape and my slip-ups with the scissors. The result looks like this:



With the exterior complete, the next phase of the project is to update the interior.

Controlling the Clock

If you open up pretty much any modern clock with a quartz movement you'll find something like this:

Lavet Quartz Movement

This movement is based on a Lavet stepper motor. A controller circuit, typically powered by a single AA battery, delivers a current pulse to an electromagnet coil once per second, causing a small permanent magnet to rotate exactly 180 degrees with each pulse. The magnet is attached to a gear train which moves the hands on the clock's face. With a minor modification, it is possible for pretty much any embedded microcontroller with General Purpose I/O capability to provide the pulses and control the movement.  There are lots of videos on YouTube which explain how these movements work and how to modify them; here's but one example:



Once the micro can advance the clock hands, I needed some way of accurately tracking real-world time. One oft-used solution is to receive and decode the WWVB time signal broadcast by NIST from Ft. Collins, CO. This approach has the advantage of being standalone, requiring no network connection, but this advantage is offset by the high cost and limited availability of WWVB receiver modules. If the chosen micro has networking capability, a second option would be to maintain the clock using Network Time Protocol software. The Network Time Protocol is one of the oldest and most robust protocols in use on the Internet today, and is more than sufficient for my needs. For this project, I decided on the Raspberry Pi because it is cheap (as low as $25), has plenty of GPIO pins, and it runs Linux which allowed me to leverage existing software like gcc and the NTP daemon. Because of its immense popularity, the Pi is also supported by an immense ecosystem of add-on hardware, which also proved useful in wiring up the interface circuit.

To avoid making any costly mistakes on my actual project clock, I purchased a (broken) clock from a thrift store. It's a miniature Grandfather clock which was sold by The Bombay Company for significantly more than the $0.99 that I paid for it. Although the battery in the back of the movement was badly corroded, I took the chance that the movement itself was still usable. The gamble paid off.

Bombay Company Mini
                Grandfather Clock

After removing all the corroded parts, I started by soldering two wires onto the ends of the coil. I then built an interface circuit called an H-bridge to go between the Pi and the coil using an H-bridge module from Adafruit. Because there is no way for the Raspberry Pi to "read" the position of the hands, I also added a ferro-electric RAM module to provide non-volatile storage for the hand positions so I don't have to re-set the hands after every power failure.

PiClock Interface Circuit
I wired it all together on a prototyping hat and plugged it into a Raspberry Pi.

All Wired Up

To protect the circuitry and facilitate mounting I purchased an acrylic case made by Sunfounder. Because the prototyping board added some additional height when plugged in, the combination would not fit comfortably inside the case. Fortunately this was easy to remedy by adding longer standoffs. The case fits nicely on the back of my "practice" clock.

Pi mounted on the back of the clock

Since the project clock is wall-mounted, my plan is to run a cat-5e Ethernet cable to the location and install a wall-mounting RF-45 jack similar to the ones used to mount wall POTS telephones. By running 802.3af power-over-Ethernet to this jack I can provide the clock with both power and network connectivity. A small PoE splitter module provides regulated 5V power to the Pi. There is plenty of space inside the project clock's case to hide both the Raspberry Pi and the PoE splitter, leaving none of this infrastructure visible from the outside.

Software

The NTP daemon does an excellent job of maintaining the system clock to within a few milliseconds of the reference atomic clock. Because the NTP daemon does all the heavy lifting, the software which controls the positions of the clock hands is extremely simple: the main loop reads the current time from the system clock, and updates the positions of the hands on the clock face to match. If the hands are "behind" the actual time, the clock movement is stepped repeatedly (and quickly) until the hand position catches up. If the hand position is "ahead" of the actual time, the Lavet mechanism is not stepped and the hands wait for actual time to catch up with them. This is necessary because the Lavet stepper mechanism is not designed to move the hands backwards.Oddly enough, through experimentation I discovered that it is possible to make a Lavet movement step backwards by applying a relatively high voltage and current to the coil; apparently the much-larger-than-normal magnetic field that this generates causes the magnet gear to spin in the wrong direction. Not wanting to impact the reliability of my control circuit, I chose not to make use of this "feature."

Remaining Steps

The "practice" clock has been running flawlessly for several weeks now. The final phase of this project will be to modify the Lavet movement of the real project clock and transfer the Pi and PoE splitter into it. I then need to run cat-5e cable to my selected mounting location and install the jack. Fishing cables through finished interior walls is a PITA, so it might be a while before I get around to fully completing this project...