Controlling a clock with an Arduino
Update: The Arduino system is fine; the only thing you have to take into consideration is the 9.54 hour rollover event, which Rob Faludi has provided an excellent solution for here. I made up a nice little over-analysis of the issue, available here.
I have been wanting to make a variable-speed clock for a while, so this weekend I picked up a cheapish clock unit (thrift stores are a great source!), and played around with using the Arduino to control it. In summary, I was able to get everything going,
but there are some issues with the Arduino software that are going to prevent making it a really accurate clock. Explanation, source code after the break.
Part 1 – Hardware
The mechanical bit is quite simple. The clock functions in a similar fashion to a stepper motor, in the sense that you charge an electric coil to get the mechanical bit to move forward a precise amount. In this case, each firing moves the second hand one second position forward (and makes the familiar tick noise). To ‘fire’ the electric coil, you simply put a voltage across it. The only complicated bit is that you actually have to reverse this voltage to advance the clock to the next step. This is accomplished by using two of the Arduino pins, and switching their polarity. (note: click on the picture to view the embedded notes). On the clock I dismantled, there was a little embedded controller. I used a razor blade to cut the copper lines between that and the connections to the electromagnet so that the original chip would be disconnected, and left it alone.
When we engage the coil by putting a voltage across it, it starts to draw current which then sets up a magnetic field through the coil. This magnetic field then applies a force to a permanent magnet that is attached to a gear, causing it to rotate and line up with the electromagnet. This gear turns exactly 180 degrees, and is connected to a series of gears that translate the 180 degree rotation into a 6 degree rotation (a 1:30 gear reduction). For the next cycle, we have to reverse the voltage that we apply so that the magnetic field we create will be in the opposite direction, and cause the permanent magnet to rotate again. One could also imagine a mechanism using a spring and a ratchet to pull the permanent magnet back into position, but that is not how these clocks work.
So, knowing all this, we should be able to connect up each end of the electromagnet to the Arduino and have it working. Because it is such a low power device (they are made to run on a single battery for months, if not years), it can be powered directly from the Arduino ports. There are only two things we have to consider in the circuit. First, a resistor should be placed in series with the coil to limit the amount of current it can draw. I chose two resistors with a value in the range of 50 ohms, and placed one at each end of the coil. You may need to experiment with these values to see what works. Second, discharging and charging the magnet can create high voltage spikes (it is basically an inductor), so it is recommended to place diodes from ground to each of the electromagnet. This will help prevent the voltage from going any lower than the diode drop, which is probably around .7 volts for the diodes I chose.
For more detail: Controlling a clock with an Arduino
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days