[Lucassiglo21] developed this logic clock without using a crystal oscillator or a resonator. Instead, he’s letting the incoming electricity keep the time for him. The supply is AC at 50 Hz so he’s using some 4017 decade dividers to reduce that down to a 1 Hz signal. From there it keeps track of the ticks just like the last digital logic clock we saw.
If you’ve used AC line frequency as the clock source in your project we’d like to hear about it. Send us a tip and make sure your writeup includes a schematic. We’re especially interested to see if anyone has a good way of using this method with inexpensive microcontrollers.
Yeah well, for AC mains 50/60Hz is just a guideline. So I bet this clock will differ in time within a matter of a few day, possibly few hours. If the feq is off by 1/2Hz, it would become off by 12min a day.
This is how A/C mechanical clocks have always worked – an induction motor running synchronously with mains frequency driving gears and hands (or flipover digits). The accuracy isn’t bad – utilities hold their frequencies pretty well – but crystal oscillators have become ubiquitous for a reason.
@David Millions of synchronous motor driven mechanical clocks disagree with you.
This seems like a good post to ask. I’m still learning EE myself and I am wondering if its possible to just use a resistor/capacitor to use a clock pulse input and why nobody uses it if it is possible.
Building a clock using logic chips and line frequency was a standard procedure in computer lab in 1986.
True, the line frequency isn’t very accurate or stable. When I worked on medical linear accelerators, some of the gear had to run on special line conditioners that displayed to two decimals the frequency and voltage, incoming and outgoing. It might have been sloppy design that some parts of the system needed exactly 60.0 hz and 120.0 volts, or maybe they were just being extra careful due to the huge system complexity and the medical nature of it.
@TRB,
An RC oscillator will be far less accurate than line frequency. It would be sensitive to temperature changes (as well as the zodiac).
About 18 years ago, there was a group of people on Usenet that were tweaking their digital watches for accuracy. A digital watch typically has one adjustment, a capacitor which can slightly influence the crystal time base. Some were wrapping wire around the watch to read the Xtal frequency with a frequency counter and atomic time base and would adjust the capacitor for a “better” second. Some even left their watches on their wrists while they slept to stabilize the watch temperature, i.e. using their bodies as an Xtal “oven”.
@TRB do you mean to use a simple RC oscillator circuit or what? If you do mostly the operating voltage and temperature both affect the frequency so the accuracy would not be too good in normal situations. If you just want to have some frequency coming out then it would not matter.
Actually, the grid frequency is maintained long-term so that clocks are accurate.
http://en.wikipedia.org/wiki/Utility_frequency#Long-term_stability_and_clock_synchronization
@David: That’s BS. I’ve got a nixie clock here that’s been running with power line sync for over 5 years and I’ve never had a problem.
It might interest you to know that any phase drift in the power is corrected at the plant every night so as to prevent this kind of drift..
@Leigh Hahah thanks, amazing what happens when you go out and look for the answer instead of assuming you must already know it…
Re: simple oscillators — I use internal RC oscillator in most of my ATmega-based projects that don’t require serious stability or clock speeds over 8MHz. I’m not sure why people keep insisting on using a real crystal in every LED blinker. The possible downside is that like in 1 out of 10 ATmegas you might need to calibrate the oscillator before you can use it with UART.
For a clock you need a more stable source though. Like the line frequency ;)
I am working on a project using ac line frequency as a timebase. It is corrected over the long term so it is useful for clocks and suck. The short term error can be quite high however.
Actually line frequency is very stable, probably up to 2 or 3 decimals. I lived in Venezuela and I remember that during a drought they have to save water by saving power and to do that the electrical company reduced the line frequency to 59.98Hz. Before doing they announced in the news that the clocks will run slower and they would require adjustments every day.
Here is a beginner project to get at the 50/60Hz signal (and later they even use the same 4017/4022 chips for a one-second reference):
http://www.play-hookey.com/digital/experiments/line_clock.html
The clock radio on my night stand keeps accurate power line based time. There is no Daylight Savings Time here in Arizona so no need to adjust it for that. I bet it would keep running accurately longer if it would get uninterrupted power (stupid summer storm power outages). And yes I’m pretty anal about time keeping, I wear a watch that receives atomic time nightly.
The frequencies may have been inaccurate in the past but nowadays with power companies needing to trade power amongst them, I bet it’s actually very important for them to keep power frequencies accurate and in sync.
As for the question about keeping a project in sync with line frequency: look up “Phase Locked Loop” on Wikipedia. They’re not very difficult to implement even if you don’t use one that’s integrated in a chip.
===Jac
I’m certain that I’m much older than most readers of this blog and it’s amusing to me that those who have grown up with microprocessors or micro-controllers have difficulty with what once was first year digital logic in school. On the other hand I all too frequently get stuck on Arduino issues. It’s no surprise that when people collaborate to find a solution, it’s generally very effective.
With regard to the accuracy of using the AC line as a time base, I can’t speak for other countries, but in the US all utility companies count the number of cycles they output and they tweak generator speed up or down as required to keep the cycle count exactly correct over a nominal amount of time.
http://en.wikipedia.org/wiki/Telechron
Telechron pioneered clocks powered by synchronous electric motors back in the early 20th century.
@David
Short-term average power line freq stability is OK. Long-term average power line freq stability is excellent.
From wiki:
“Regulation of power system frequency for timekeeping accuracy was not commonplace until after 1926 and the invention of the electric clock driven by a synchronous motor. Network operators will regulate the daily average frequency so that clocks stay within a few seconds of correct time. In practice the nominal frequency is raised or lowered by a specific percentage to maintain synchronization. Over the course of a day, the average frequency is maintained at the nominal value within a few hundred parts per million.[17] In the synchronous grid of Continental Europe, the deviation between network phase time and UTC is calculated at 08:00 each day in a control center in Switzerland, and the target frequency is then adjusted by up to ±0.02% from 50 Hz as needed, to ensure a long-term frequency average of exactly 24×3600×50 cycles per day is maintained.[18] In North America, whenever the error exceeds 10 seconds for the east, 3 seconds for Texas, or 2 seconds for the west, a correction of ±0.02 Hz (0.033%) is applied. Time error corrections start and end either on the hour or on the half hour.[19][20] A dynamicdemand.co.uk/grid – Real-time frequency meter for power generation in the United Kingdom is available online. Smaller power systems may not maintain frequency with the same degree of accuracy.”
The power grid frequency is extremely stable. I used to be an operator at a nuclear power plant that generated 1200 megawatts of electricity. When we would go back online from a refueling outage we had to set the generator phase and frequency very close to the grid. When the breaker was thrown, the grid would actually PULL the 1200 megawatt generator into phase.
The only problem with the mains time is that if you don’t filter the signal correctly you might count additional spikes that come from switching appliances and thus make your clock fast.
Of course, your clock is stuck (or worse, reset) when you loose power.
In some designs, there is a battery and an R/C onboard oscillator (it doesn’t need to be very accurate) to keep the time (not the display) during power outages.
It would be fun to see that implemented in pure logic.
My favourite is still the neon clock: http://www.vf.utwente.nl/~ptdeboer/ham/neonclock/
What software do you think he is using for his simulations? I’ve tried using MultiSim to design digi circuits but it doesn’t seem to work properly (I have even more issues using it to do analog stuff).
@everyone – Wow, I was wrong (spoke before doing research). After some reading, the frequency does fluctuate but is averaged over one minute to be pretty well on the money. Very surprised to hear that much goes into the phasing of mains power. I tended to think mains are a crude/rough “good enough” power source, saying anything sensitive tends to go through power conditioning. Thanks for the correction/info!
Many if not all 1st generation digital clocks from the 70’s/80’s used the mains frequency as a base clock due to its precision and the high cost of crystals plus dividers circuitry.
Internal clock generators were usually used only during blackouts. Being mostly RC oscillators they lacked precision and required a separate battery for backup.
-and knowing is half the battle.
http://www.youtube.com/watch?v=pele5vptVgc
Here’s an excellent introduction to timekeeping, with some ancient historical stuff and really modern stuff:
http://www.allanstime.com/Publications/DWA/Science_Timekeeping/TheScienceOfTimekeeping.pdf
One of the key measures of time and frequency reliability is the Allan Variance. The Wikipedia article is rather dense, but what you wind up with is a plot of error on the Y axis and interval of measure on the X axis.
I’ve got a Rubidium atomic oscillator at home which gives me something like 10^-11 per day, and most people who care about such things would consider me a duffer. Here’s the spec sheet: http://www.freqelec.com/rb_osc_fe5680a.html You can see the Allan Variance plot more easily in its data sheet: http://www.freqelec.com/pdf/rfs_12pg.pdf
Leigh.
So, the short-term variance of the electric grid might not be that great, but over the longer term (farther along the X axis), it is managed, so it would have a smaller variance.
Also some of the computer designs of the 1980’s used 60Hz line for their clock, but they required a signal from the power supply. Battery-backed RTC killed those.
@S2H, Simulations? Why would you use a simulator for such basic digital logic? As fopr the analog section a diode, transistor and a cap is all I have needed to make a 5 volt squarewave out of a 12V sine wave.
You young folk sure do need your hands held tight when it comes to this stuff.
Regarding mains power as a time base – one adventurous/motivated guy did manage to measure it and publish the results: http://www.leapsecond.com/pages/mains/
Brian
Seriously guys.. You make not think you can hire an EE for crap pay, but have you looked into hiring EE students?
In other words, please send Mike Szc… back to the world where windows solitaire is the most complex item one needs to understand!
If you had a sine wave input that is >logic voltage value, it is possible with a diode, a zener diode and a resistor.
first diode goes in series with the source to cut out the lower half of the waveform. Next place a resistor in series to limit the current. Next place the zener diode to pass any excess voltage to ground creating the desired voltage across it. Finally connect the micro-controller’s counter input in parallel with the zener diode and watch for rising edge.
This is identical to the input used in the upper right hand corner of the circuit diagram. Except that his used an extra diode to have the lower part of the wave form go to ground. In other words switch out U1 with a micro-controller and place 14 on the counter input.
IsotopeJ:
> When the breaker was thrown, the grid would actually PULL the 1200 megawatt generator into phase.
Wow, that’s not something you’d think could be done, but I guess it’s obvious when you think about it. Do you have to “idle” the turbines and generators to do that, or do you just end up with them delivering a bit less electricity to the grid before they’re in sync?
@david. Epic fail. the Ac frequency is highly stable. in fact most alarm clocks use it for the time signal, or at least used to.
This is incredibly old-skool. WE used to do this decades ago. It kills me that anyone uses “simulations” for such n00b stuff, wow, they dont teach people real electronics in school anymore do they…
@magetoo
>Do you have to “idle” the turbines and generators to do that, or do you just end up with them delivering a bit less electricity to the grid before they’re in sync?
There is a single generator driven by a massive turbine. The turbine/generator would be spun up first. IIRC: The generator is spun slightly faster than the grid frequency. There is an analog dial right on the outside of the generator housing that spins in relation to the difference in phase between the generator and grid. When closing the breaker, the operator had to look at this dial and flip the switch as the needle approached a mark that indicated phase-sync. Failing to do so would result in the generator and turbine immediately moving in phase with the entire grid – meaning goodbye turbine building. If you think that’s crude, you’d be surprised – a lot of things that happen at nuclear power plants are purposefully low tech.
This is pretty common for plug-in “digital” alarm clocks, even today. I’ve taken apart a few alarm clocks where this is the case.
@S2H: that’s multisim 10, it is simulating perfectly, proteus is also a good software.
@Adventure in: D3 is there along with C1 making a half wave rectifier. the cathode of D3 is not connected to GND.
the line frequency is very stable, i did some research before building this, and maybe it shifted 200mS during the night, and -200mS during the day. it was plugged all day for the last year, and it didn’t shifted at all, at least not notoriously.
certain places dont have stable ac. or, it’s stable at not exactly 50/60 herz. not arguing that mains power is a reliable thing or any of that stupid crap, but it’s not always 60.0 or whatever.
i have a friend who lives in a small northern town and their clocks have to be reset periodically because their power isn’t quite right.
@Lucassiglo21: Gracias amigo. I am using multisim 10 and it tends to give me a lot of convergence errors even when simulating some very basic circuits, so it has hindered me from designing anything large-scale. Any advice? I will also take a look at Proteus.
@croftj: While I agree that the components used in this circuit are by themselves quite basic, would you go ahead and design a PCB for this device without drawing up a schematic and simulating/breadboarding? Let me know if you need me to hold your hand…
@David –
Good on you for coming back, admitting your mistake, and showing you’ve learned from it.
most of times multisim works just fine, and when the convergence thing happens, there is some kind of convergence problem solver that shows and solves the problem automagicly(included in version 10).
in my experience, proteus is much better for microcontroled systems and digital/mixed designs. and the pcb layout software (proteus ares) is very nice, i use it a lot.
is you want full analog analysis with complex things, multisim works better.
that’s just my opinion.
Assuming a normal distribnution of the variance in the frequency of the AC supply it should never bee off by more than 12% a Hz 63% of the time.
With all errors “canceling out” over a significant period of time.
@S2H
I’ve used Multisim for years and haven’t hit a convergence error yet. What kind of simulation are you doing? DC operating point? Transient analysis? Fourier analysis? AC analysis? Don’t bother with simulating HP function generators and scopes. Simulated equipment sucks. Also, make sure to have all your sources setup correctly.
Here’s an example of a simple amplifier circuit which should have about 20dB of gain with a maximum output power of 2 watts from roughly 20-20000Hz. If you enter this exactly how it is, and you can’t get a simulation working, well, I suppose there could be something wrong with your copy of Multisim.
http://dl.dropbox.com/u/449518/amplifier2.png
A simple circuit to pick up the 60Hz signal wirelessly:
http://www.techlib.com/electronics/atomic.html
@natrix: Thanks for the suggestions. I was getting errors when doing a dead-simple simulation of a comparator circuit (none of the fancy analysis stuff, just pressing the “play” button and sticking probes in). I was able to repeatably cause an error by just sticking a probe at one of my op-amps inputs.
What do you mean by having my sources set up correctly? In the case of the comparator, the only source I had was a battery going through a voltage divider (if a first year electrical student could do the math in their head, then surely the software could too?!).
Come on, that’s so oldschool! In the days, all cheap alarmclocks who couldn’t afford a crystal oscillator used that technique. Nothing revolutionary here, not even to speak about the accuracy achieved by such a circuit. Still, bonus points for the nice housing and pcb!
Anyone doing such a design try to be sure to internationalise it if they’re putting it only and build in a small DIP switch for 50/60Hz selection.
yes, but i’m not planning going to the US with this, they will think it’s a bomb of something at the airport.
@magetoo
Following up what Isotope* wrote. My former supervisor worked with a transportable weather radar. When a storm approached, they switched to standby power. He started the standby generator and watched a panel of three lights. Each light was connected between one leg of the mains and standby generator (3 phase). When all three lights dimmed out, (indicating the phase difference between the mains and standby was not enough the light the bulbs) he threw the transfer switch.
Amazing! He made a clock that uses AC as a timebase.
Just like I did in ’74
Now, isn’t that something.