Making an electronic clock is pretty easy here in 2023, with a microcontroller capable of delivering as many quartz-disciplined pulses as you’d like available for pennies. But how did engineers generate a timebase back in the old days, and how would you do it today? It’s a question [bicyclesonthemoon] is answering, with a driver for a former railway station clock.
The clock has a mechanism that expects pulses every minute, a +24V pulse on even minutes, and a -24V pulse on odd ones. He received a driver module with it, but for his own reasons wanted a controller without a microcontroller. He also wanted the timebase to be derived from the mains frequency. The result is a delve back into 1970s technology, and the type of project that’s now a pretty rare sight. Using a mixture of 4000 series logic and a few of the ubiquitous 555s [bicyclesonthemoon] recovers 50Hz pulses from the AC, and divides them down to 1 pulse per minute, before splitting into odd and even minutes to drive a pair of relays which in turn drive the clock. We like it, a lot.
Mains-locked clocks are less common than they used to be, but they’re still a thing. Do you still wake up to one?
You might be reading this six minutes early. Assuming that the Hackaday editors have done their job, this article should have appeared in your feed right on the half-hour. We have a set schedule to keep you supplied with the tastiest of hardware hacks and news. For some of you though perhaps there has been a treat, you’ve seen it and all the other stories six minutes early.
Think for a minute of a modern car on a hot day. When you turn on the air conditioning you will hear a slight dip in the engine revs as it accommodates the extra load. So it is with an alternating current power grid; a simple example is a power station supplying a city. In periods such as cold nights when the demands of the city go up, the result would be that the power station needs to work harder to satisfy it, and until that happens there would be a slight dip in its line frequency. Power grids compensate for this by increasing and decreasing the available generating capacity in real time, maintaining a mean frequency such that the “grid time” of a clock controlled by it matches an atomic clock as closely as possible over time.
It is at this point we leave the realm of electrical engineering and enter that of international politics, normally something far removed from Hackaday’s remit. It is fair to say that the history between Serbia and Kosovo is extremely delicate, and to understand some of the context of this story you should read about the war at the end of the 1990s. After the conflict the Serbian-majority region of what is now Kosovo refused to pay the Kosovan utility for its electricity, eventually leading to the Kosovans refusing to pay for that region’s share of the power received by Kosovo from Serbia. The resulting imbalance between demand and supply was enough to drag the supply frequency down across the whole continent, and though a short-term agreement has been reached the problem still remains on the grid.
Clocks and Mains Frequency
So if you are a continental European and you find yourself six minutes behind your British or American friends, don’t worry. We know that among our readers are people with significant experience in the power generation world, perhaps some of you would like to use your six minutes to give us a bit of insight in the comments. Meanwhile here at Hackaday we maintain an interest in the mechanics of power distribution even if some might say that it is Not A Hack. We’ve taken a look at utility poles, and examined how power grids are synchronised.
As for those slow clocks, the use of mains frequency to keep accurate time is quite brilliant and has been used reliably for decades. Tightly regulating grid frequency means that any clock plugged into an outlet can have the same dead-on accuracy for the cost of a few diodes. These clocks count the zero crossing of the alternating current. There may be moment to moment drifts but the power utility injects or removes cycles over the long term so the sum of crossings is dead on over the course of the day. It’s an interesting phenomenon to experiment with and that’s why we see it in microcontroller projects from time to time.
[Lujji] is playing around with the STM8 microcontroller. In reviewing the official documentation for this chip, he read the external clock can be a sine wave, a triangle wave, or a square wave with a 50% duty cycle. The minimum CPU frequency is 0 Hz. [Lujji] doesn’t have a signal generator, and presumably, he’s all out of crystals. He does have mains AC, though, so why not clock a microcontroller with wall power?
Using mains power as a frequency standard is a concept a hundred years old. Synchronous motors turn at a rate proportional to the mains frequency, and this has been used in clocks for decades. If you’re really clever, you can clock digital circuits with mains AC, but we’ve never seen someone replace a tiny crystal in a microcontroller circuit with mains power.
After an experiment to prove the concept, [Lujji] went on to construct a circuit that wasn’t as dumb as connecting the microcontroller directly to a wall socket. The direct approach didn’t work that well anyway — the STM8 didn’t like low frequency clocks with slow edges. [Lujji] needed a clock with cleaner edges, and a 555 configured as a comparator fit the bill.
The completed circuit sends mains power through an optocoupler to drive a 555 configured as a comparator. The output is a clean 50Hz clock that is connected to the OSCIN pin on an STM8. This is now a chip running at 50Hz, and yes, it works. [Lujji] set up a circuit to write ‘Hello World’ on an old Nokia LCD. That took about three minutes. It works, though, even though it’s completely useless. Maybe this can be applied to some novel timekeeping similar to that one-instruction-per-day clock we looked earlier in the year.