Step 5: Write Code to Synchronise Time

The time synchronisation code ended up proving the most difficult. I had originally intended to use NTP (Network Time Protocol) to get the time, however I was unable to get this to work with the web server. Instead I ended up implementing the simpler DAYTIME protocol. This involves connecting to port 13 on a given sever, which then automatically responds with the time in a known format. The code parses this and updates its internal time accordingly.

Two possible server addresses are used. If one fails then the other is tried. These are queried on startup, and every hour afterwards. The DAYTIME server sites recommend you limit how often you query them, and may block your address if abused. 
I had occasion to fly in a RN helicopter and the engine RPM gauge was in the same font as your clock.<br><br>I found it interesting as I had seen your clock in the movie 'Brazil' by one of the Pythons (the one from Minnesota). I made the 'Brazil' comment to one of the RN pilots and he said that many British schools had those clocks. Makes 'Brazil' even more bazzar.<br><br>As the owner of a couple of MGs, I'd love to have a Smith's clock. Another reason to travel to England, to go to car-boot sales and such.<br><br>Great Instructable. I've a GE clock of this same style that could use your very same modification.<br><br>Cheers,<br><br>Fin
Very nice project, and well explained!&nbsp; Finally, a great use of the internet without having to use Twitter to do useful work. The place where I work still uses centralized timekeeping in much the same way they did in the 50's, though I dare say with fewer switches and more electronics than they had back then.<br> <br> I gather that the arduino does not actually sense the clock's hand positions, only keeps track of the number of pulses sent to the mechanism. On initial power up&nbsp;I assume that the initial clock position must be defined and input into the arduino firmware.&nbsp;&nbsp;What happens if the mechanism &quot;skips a beat&quot;?&nbsp; Does the operator then have to redefine the hands position manually, mechanically reset it, or can the arduino issue an extra pulse or two to make the clock catch up automatically?&nbsp; Does the mechanism need greasing and/or dust protection to keep it from jamming as &quot;time goes by&quot;?&nbsp; Thanks.
Thats correct. The Arduino just keeps track of where the hands are; there is no feedback mechanism. Hence on initial startup you have to tell it where the hands are. However it DOES then remember this even if power is lost, so you should only need to do it once. The hands themselves cannot be moved manually.<br><br>In operation it has been very reliable (at least the mechanical portion). When you consider how they were originally used, it would have been fairly important that they never miss a beat. I did up the voltage to the coil a little to help ensure this, but most likely this was not really needed.<br><br>If power is lost and the time falls behind, when powered up the Arduino will fast-forward, sending a pulse every second until its caught up. Its rather funny to watch. Apparently some slave dials supported a reverse mode too, but mine does not.<br><br>I used a little light oil on the mechanism itself, but it was in great condition when I got it. It is rather 'chunky' for a clock movement, so it would take a fair bit to jam or damage it. Beyond being flush up against the wall, there is no dust protection (but I doubt much will find its way in).<br><br>Thanks for the comment!
Thanks for the quick response. Can you tell me how long a 9V battery will last powering both the clock coil and the arduino?<br> <br> Good idea on the foam.&nbsp; The minute by minute jogging of my work clock gets loud when I stay late at night to catch up on paperwork.
I'm afraid I'd have to tale some measurements to be accurate (and I won't have a chance for a week or so), but I can provide some rough figures.&nbsp;<br><br>When not performing a pulse, the circuit draws around 100mA (I think much of that is the WiFi, and could probably be improved by adding sleep support to the code). When performing a pulse this rises to 200 to 500mA (I can't remember exactly what this figure was). A pulse lasts 200mA, and is performed once every 30 seconds normally, or once a second during a fast-forward.&nbsp;<br><br>From Wikipedia (http://en.wikipedia.org/wiki/List_of_battery_sizes) we see that a 9V battery has a capacity of around 565mAh. However if you draw more than a few tens of milliamps, the effective capacity will be far lower. Based on that even ongoing the pulses, you would get only around 5 hours, and probably less.&nbsp;<br><br>It may be possible to stretch this significantly; add sleep support to the Arduino and put the WiFi to sleep expect when updating the time from the net (once an hour at the moment). You could also derive a better power supply circuit for the coil (possibly charge a capacitor at a lower current over a longer time). Also, using a switching regulator to more efficiently make use of the 9V (rather than throwing away 4V worth as heat) would help.&nbsp;
My Elementary School had one of these systems timed in the main office off a beautiful deadstop movement pendulum clock that was a real industrial work of art. Nice to see one of the slaves repurposed like this.
Slick Project and well documented.<br>Great Job!<br><br>KK
Great job, and interesting too. <br>However, if anybody just wants an accurate clock, then Radio Controlled clock movements can be obtained in the UK for about &pound;10 or less.
Magnificent clock.<br>Magnificent reincarnation.
Very nice.
Very Nice Work !! <br> <br>5 of 5 stars
Great find, and an inspired project! Thanks for the detailed writeup.
Nice job!
I love the retro look of this device, and the fact that you've melded something 60 years old with something brand new. Good job!

About This Instructable


41 favorites


More by LinusDillon: Make an Atom Synchronised Clock from a 1950's Slave Dial
Add instructable to: