Keeping track of time Jun 29, 2016
One of the things I’d love to do is measure the AC mains grid frequency with fairly high precision. We know that it’s kept at 50 Hz long term, so that old mains-powered alarm clocks, etc. can keep track of time by simply using AC mains as their input time source.
But at the same time, there’s a well-known effect with generators, which causes them to slow down when the load is high and speed up when the load is low. By measuring the precise frequency, we can get an insight into the total load on the grid all across Europe (yet that alarm clock still manages to keep time: the utility company artificially runs the generators slightly fast at night to end up with close to 4,320,000 cycles per day).
The UK is special (in more ways than one these days…), in that the island’s grid is decoupled from the rest of Europe: all power exchanges are converted to DC at some point, so that the UK can operate its 50 Hz independently. Still, the same speed effects are present there as well, as seen on the UK-based Dynamic Demand site:
For a nice glimpse into the total UK power status, see this site.
As you can see, the frequency will normally vary only very slightly, with every attempt made to keep it limited between 48.8 and 50.2 Hz in extreme cases. Much higher or lower than that, and some power plants will in fact automatically cut out or kick in!
To measure the grid frequency, I’m going to expand the JeeLabs Energy Monitor setup, since it’s already detecting zero crossings anyway. There may be some variation in this detection due to noise, but over several cycles - say the 3000 cycles that make up one minute - it should all average out nicely.
The Olimexino board has two sources of time built-in: an 8 MHz crystal driving the µC’s high-speed clock (from which the 72 MHz system clock is derived) and a 32,768 Hz crystal used to track wall clock time. There’s not really much point in using that second crystal for this case.
Both of these should be accurate to at least 50 ppm, i.e. 1 part in 20,000 or 0.005%. The error is temperature-related, but it also drifts due to age, and it’s systematic: in the long term, it does not average out to zero!
To improve long-term accuracy, I could tie into the DCF77 receiver - this is an excellent source of long-term time information since it’s based on a very accurate atomic clock. DCF77 is located in Germany, but there is a similar one (not compatible, alas) in the UK, called MSF60 and managed by the NPL.
For some good information about DCF77 and MSF60, see this site.
There are numerous DCF77 decoders on the web. For details about MSF60, see this PDF.
I’ll probably stick to just using the 72 MHz system clock initially. Reading out DCF77 reliably and using it to synchronise the system clock will be a challenge in itself…
PS. Another signal on AC mains would also be really fun to pick up: at certain times during the day, there are special signals superimposed on AC mains to switch the street lighting on and off, and to tell dumb domestic power meters when to switch from daytime to nightime energy tariffs. If you have more information about this, please share it on the JeeLabs forum - maybe we can get something going … together!