Silent Q

Azog's little slice of the world. Whee.

Another revisit to my analog meter clock

Posted By on August 23, 2008

Since I’ve been playing with Lady Ada’s Ethernet shield, I figured I’d see if I can do something useful. I wanted to see if I can get network time, which was a fair pain in the you-know-what.

“Real” network time is via NTP, which is not exactly a walk in the park to manage at this level. Even the “simpler” implementation, SNTP, is complex. The NTP response is a 64-bit timestamp. Pretty hairy to parse. And most NTP servers will only allow you to connect via the UDP port, and while the Xport supports UDP, it’s just another level of complexity I didn’t want to examine.

A few servers will provide daytime on TCP 13. It’s an ASCII time, but not very well standardized. Some servers may provide you with one format, while others may differ. And then you need to even find a server which offers TCP 13.

In any event, time.nist.gov does do TCP 13, as well as NTP on UDP 123. Another nist server, nist-nw, does another fun protocol on TCP 37 (time). TCP 37 might be easier to manage, it’s just time since Jan 1, 1900, but in the end, I decided to try TCP 13 and bang the numbers around.

The idea went well:

Which got me thinking about one of my prior projects, the analog meter clock. I had left that in a dissatisfactory state, so I figured I could revisit it, and use the network time concept. To start with, I found some nice Darlington arrays, which will let me dump the crufty scaling I was doing previously, and just manage “native” time (12:59:59). Since I’m getting time from the network, I discarded the time setting code which managed two separate switches. I still use the calibration mode switch, and reused one of the switches as a way to switch to/from daylight savings time. NIST reports in GMT format, so I twiddle the time using the switch to identify if we’re in DST or standard time. Also, since the Arudino “delay” is not exactly precise, I resync the clock once an hour.

At the end of the day, I finally came up with:

The enclosure is the same, as is much of the hardware I used previously. You can see the Arduino / Xport peeking up on the left, and on the right is a small piece of perboard for the Darlington array. The switch on the far left, in the back, is disconnected, and you can see the wire heading up into nowhere. That used to be the calibration switch, but I moved that since I don’t need the hrs/mins settings switches anymore.

Now, this poses another unique set of possible problems. Since it’s network-aware now, if it can’t get the time, it won’t be able to do anything. And since I’ve removed the setting switches, I can’t manually set the time if there is a loss of network connectivity.

I should re-scale the meter faces. Someone once sent me a very nice PostScript utility to draw meter faces, so maybe I’ll sit down later and try to see what I can hack up. I’d also like to re-case this somehow. That’ll come later, I guess. Here is the new code. As with all my code, it’s probably hideous to a seasoned developer, and there is a decided lack of error checking.


Comments

Leave a Reply

Please note: Comment moderation is currently enabled so there will be a delay between when you post your comment and when it shows up. Patience is a virtue; there is no need to re-submit your comment.