Hacker News new | past | comments | ask | show | jobs | submit login
ESP32 based old clock controller, with NTP sync (smallhacks.wordpress.com)
92 points by zdw on Sept 26, 2020 | hide | past | favorite | 41 comments



These types of older slave clock systems used to be very common in schools in the US (they are still sometimes installed in new schools but usually using newer digital schemes integrated with the paging system). Factories and other campuses also used them but I have not seen this so much personally.

A very common control protocol, used more or less by IBM, Simplex, and Standard Electric, is this: a pulse delivered once per minute advances the minute hand one notch. A pulse delivered at the top of every hour (on a separate wire, I believe in the Simplex case that I am most familiar with) powers an electromagnet which "snaps" the minute hand to the 00 position, correcting any error that occurred in tracking the minute pulses over the preceding hour.

If the clock is doing a poor job of tracking the minute pulse (due to a dirty/bound up local mechanism in the case of school clocks I've messed with), it's common to see the minute hand perhaps ten minutes behind late in the hour, and then at the top of the hour it will fairly quickly "sweep" to the correct position. Of course these clocks should be serviced, but the school district I was dealing with had a paltry budget and a hard time finding companies to service the clocks so they tended to stay broken in this way for years at a time.

The big problem with this system is that it could only "correct" clocks that were a bit off at the top of the hour (if the error was too large the top-of-the-hour reset did not function correctly, and the hour hand was never corrected). This meant that in the event of a loss of power to the clock system, it was necessary to manually reset the hour hand of every clock in the building prior to restart. The convention for Simplex and I believe for other vendors as well is to set all clocks to 12:00 exactly, the master clock then has a mode in which it delivers "accelerated" minute pulses to advance all clocks to the correct time. Back when I was in middle school the controller seemed to be broken in a way where it occasionally went into this mode incorrectly (maybe a short power disruption) and sometimes all the clocks in the building would be moving at 10x speed for a few hours of the day.

DST correction needs to be handled similarly, so you will have to visit every clock in the system at least twice a year, assuming you have reliable power and aren't in Arizona or something. Or, in an underfunded school district, just apply the DST correction weeks late or not at all. It is amazing how habituated people become to the clocks being completely unreliable.

I have read that there were systems that used a third signal to reset the hour hand at 12:00, avoiding this problem, but I've never personally seen one - perhaps they weren't popular at all or perhaps they just fell into an awkward spot at the end of the period where analog systems were being installed. In modern slave clock systems, it's more common to use RS422 or 900MHz radio to directly transmit timestamps once per second. These have the major advantage of making digital displays extremely easy to implement and analog displays still fairly easy, with no need to ever manually set clocks.

In installations today though, it seems like the most popular option for schools are one of several digital (sometimes IP) paging systems that support a clock display as an add-on feature. Integrating the clocks with paging makes more sense than you might think, as the slave clock system in schools generally also controlled the bells (sometimes using the same signal wires, e.g. using opposite polarity of pulses to open a relay on the 12/24vac bells), and so now that bells are being replaced with paging it makes sense to keep clocks on the same system.

There's a subset of the curious internet community of fire alarm collectors who also collect these clock systems, since they are somewhat similar in nature to older fire alarms. I'll admit that I've considered trying to get a few old Simplex slave clocks to fix up and put in my house, probably implementing my own controller since even the later-generation digital controllers Simplex sold were large wall cabinets.


Interesting, in ex. USSR and Czechoslovakia i am aware only about "2 wire" systems, but i heard also about "IBM" one with a 3 wires, so now i know what it was for, thanks :) Here master clock was producing 1m or 30s duration impulses. I also heard about "hybrid" systems where both digital timestamp and 1m impulse were delivered, so clock was able to choose what to use. What is funny that there were no common standard. 6V, 12V, 24 and 60 - all were common! So few times i saw converters from one to another. One of the last "master clock" devices from Pragotron was based on IC circuits, but principle was the same - https://aukro.cz/matecni-hodiny-pragotron-eh40-6960978702


I've heard of hybrid digital/analog systems in the US, I think a few smaller companies introduced them as an upgrade path - IBM/Simplex/Standard pretty much dropped support for these clock systems totally but lots of institutions already had them installed, so a cottage industry popped up of companies that made compatible equipment to keep them working and upgrade them over time. As far as I know virtually everything in the US was 24vdc but I'm sure there's some odd exceptions out there.

I've always had a weird interest in these systems since they tend to pop in large old buildings and are one of the many odd building systems you have to figure out sometimes - along with vacuum controlled HVAC and old phone systems. A small side project of mine right now is trying to get a working dental office communicator light system.


> at the top of the hour it will fairly quickly "sweep" to the correct position.

THATS why the clocks at school did that when I was a kid. I always thought they did it to mess with us (why is the minute hand taaaaaaaking so long??). Regardless of the veracity of my statement- good info, thanks.


This $15 controller on Tindie works with those ubiquitous analog clock movements so that you could do something similar with just about any cheap clock: https://www.tindie.com/products/nsayer/crazy-clock/


It doesn't do ntp though, and the 30s/month spec is not not very impressive (over 5m drift in a year!)


I was thinking it just does the the work of providing an interface to the cheap controller, so you could replace the attiny85 with something like what's shown in this article.

Though you're limited to pulses that drive the second hand. So you would have to keep track of pulses and hold one back or add an extra now and then. Something like waking up every half second, calculating current ntp time minus last known ntp time and sending pulses to match.

Daylight savings that goes back would be an issue for that hour, best you could do is wait, or send a bunch of pulses to go around as quick as the stepper allows.


you can easily convert any cheap clock mechanism to such :) But my intention was to keep all original mechanic.


Yes, sure..wasn't meant to diminish that.


Fun project! If you wanted to make it more "autonomous", you could buy a cheap ublox neo-6m GPS chip, then the clock could set it's time (based on GPS) anywhere in the world as a stratum 1 timeserver!


Thank you! I was thinking about it - as clocks and controller are indoor it is unlikely that there would be stable GPS signal, external antenna may be needed. Another option is to add DCF-77 receiver, this one could be used in most of the EU countries, including indoor. May be will do this in v2 version :)

Another idea is to use FRAM instead of the board flash, to solve wear out problem forever :)


I've also written a controller for those slave clocks. Instead of an ESP32 I used an ESP8266. [1] and [2]

An even earlier version used an atmega and was powered from batteries [3]

Those slave-clocks are pretty loud. Both versions have a way to pause the clock.

https://gitlab.com/close2/nebenuhr https://gitlab.com/close2/nebenuhr_hardware https://github.com/close2/nebenuhr


Nice, i will add link to your project to my GH :)

I see you solving +- same problem but a bit different way + my board have OLED to show the status and also that you supporting work on battery and i was not doing that. Another different i found that you using custom hw board. I was thinking about this initally, but later decided that motor driver is the best match here. This would work (with a small changes) with 24v version as well, but will require different hardware (custom h-bridge?) for the 60V version.


@samm_cz: If you need more flexible timezone and DST handling (for example, if you need every timezone in the world from the IANA TZ database) take a look at https://github.com/bxparks/AceTime.

Also, the commenter on your website is correct about fading OLED displays. The cheap 128x64 OLEDs selling on eBay for $1-$2 seem to degrade within 6 months. I hope to use an LCD for my next clock.


I was looking on acetime but it was not working as expected on ESP, so switched to Timezone. I will add screensaver to my code soon to protect OLED, good suggestion.


I would be curious to know what the issue was, so that I can fix it. I have used it with both ESP8266 and ESP32, and do not know of any problems.


thanks, i don`t remember, may be it was something on my side. Anyway, i am happy with current implementation, so no need to migrate. Will try it on some next project :)


Your bog standard old AC clock is synchronously timed from the input AC.

So one just need synthesize a perfect 60Hz ~115vac input and the clock will keep perfect time. (In theory the grid tries to keep somewhat accurate time, but in practice at least on the west coast the departures can be pretty substantial.)

I have a wall clock here that keeps coordinated Mars time, driven off a local atomic clock.


> (In theory the grid tries to keep somewhat accurate time, but in practice at least on the west coast the departures can be pretty substantial.)

I was under the impression that even though the frequency drifts can be substantial, the grids compensate so that the total number of cycles over a longer time matches pretty exactly what the target frequency would have given?

I.e. if the target is 60 Hz, and 61 Hz happens for an hour, then the grid will later on intentionally go down to 59 Hz for an hour (or, perhaps more likely, a frequency close to, but below, 60 Hz for a longer time) to compensate. This is an easier task than targetting a fixed frequency, because the total number of cycles is just a matter of counting and crude intentional drifts for compensation. And it's the total number of cycles that AC-synced clocks use, so they might run slow or fast for a short while, but will then correct themselves by running faster or slower later on.

Can someone more knowledgeable comment?


Your understanding isn't incorrect but you're probably expecting smaller time and error scales then there are in practice:

Here are some charts of grid time offset from 2014 (I think from Menlo Park): http://users.megapathdsl.net/~hmurray/time-nuts/line/Calif-6... -- so you can see this spanning 60 seconds in a year.

[Source post: https://www.febo.com/pipermail/time-nuts/2015-July/092791.ht... ]

Here is some more recent data: http://users.megapathdsl.net/~hmurray/time-nuts/60Hz/60Hz-20...


Interesting! Thanks!


this device was not connected to AC input. And, btw, few yrs ago in EU AC based clocks had an issue due to problems in the grid (frequency was < 50Hz)


https://www.theguardian.com/world/2018/mar/08/european-clock...

I use ntp and this: https://www.npl.co.uk/msf-signal

I set my wrist watch manually. That's my time of first resort. It's slightly inaccurate but very, very reliable and handy (by definition!) I bought it about 15 years ago and its solar powered. Never failed yet. My phone keeps decent time but the battery needs charging - fails very infrequently but needs waking up. My laptop keeps a decent tick. It has a fairly decent local oscillator and ntp with several sources. Similar probs to phone and takes a while to boot. My three GPS synched ntp stratum 1 servers (RPis) that I keep in the office keep a very good tick.

For my needs, consistency is more important than real accuracy but I do like to see sub millisecond accuracy available. It makes log analysis a lot easier.


I was under the impression that if your frequency is not exactly 60 Hz then a place where two separate power sources meet could result in what you might describe as a kaboom. Is that not correct?


Power sources are not synchronized to a fixed 60 Hz, but to each other. If the frequency drifts off 60 Hz, the entire grid drifts together.


There is a physical reason for that - all the generators connected to the grid, including massive nuclear/coal-steam-turbine powered ones, literally slow down due to increased load. Thats why in AC grid actually the frequency decreases and not the voltage (though voltage may drop also because of higher currents in wires). I'm generally curious how battery-backed sources or solar plants respond to that, since their output frequency is artificial due to DC-AC inverters being used. Do they adapt to the grid frequency following some kind of control mechanism, or do they literally experience higher load when out of sync?


Inverter sources also sync to the grid.


"The clock mechanism is very simple and expects 1m impulse with different polarity on every run to move the arrows"

This is interesting because that's very similar to how the Swiss railway clocks synchronize their time. The second hand takes 58.5 seconds to make one full rotation, and then the clock pauses and waits for a central pulse that comes every minute.

If I'm not mistaken I believe most of their actual station clocks are made by Mobatime, although Mondaine seems to have gotten the rights for the Swiss railway's merchandise, which is kind of sad because they haven't replicated that characteristic and historic smooth second hand and pause-and-go motion on their clocks and watches, and seem to have slapped on a run-of-the-mill cheap ticking quartz mechanism.


Nice :) This mechanism is less advanced, when there no impulses it just sleeps. BTW, same company (pragatron) been doing very nice "digital" clocks with the "rotating" digts, e.g. https://f.aukro.cz/images/sk6955866345/730x548/170ebc8e-f3e3...


They do make them in both watch and wall clocks. Stop2go is the branding. The rest are generic movements.


There's this guy who got an authentic Mobatime in his kitchen: https://www.youtube.com/watch?v=RGmcHuL3Gpg


This is neat.

I'd love an NTP sync'd wall clock but my time for hardware hacking is pretty limited. Are there any off the shelf wall clocks that do NTP? Bonus points for POE and no WiFi.


In EU using DCF-77 probably would be more practical. I am sure that similar radio-s are in US too.


On my end I wish I had the knowledge to make a similar clock but synced to GPS time, allowing to set the timezone and DST using DIP switches on the back.

It could work anywhere a GPS signal can be locked, no need for an Internet connection.


Synchronized wall clocks are a thing


In the US you can get clocks that auto-set by tuning into the NIST radio signal WWVB. They come in both digital and analog, with various designs. They don’t need Internet; just some regular batteries.


hell, my wrist watch does that, and it's solar powered. thanks, Citizen.


A friend of mine made this Nixie clock

https://www.timeexpander.com/posts/nixie_kit_1_3/

It currently uses RPi Zero, but I think there is an ESP32 version planned.


nice. friend of my grandfather had similar and it was USSR DIY. It had 2 PCB boards full of transistors and other elements to drive them :) At that time no lcd was available for amateurs, so it was a natural, non-vintage choice :)


> It is Pragotron PJ 27, 12V version. They have been produced in Czechoslovakia during 196x years and using the PS-1 mechanism.

What is the PS-1 mechanism?


Oldest electrilcal mechanism from pragotron, was produced in 195x-196x years, see https://f.aukro.cz/images/sk6961755962/c15a8263-ced4-4e31-a3... for the photo.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: