50 or 60 Hertz - Roughly.
Measure the main power grid frequency, he said. It will be fun, he said…. Actually, pretty sure I said something like, “it will be easy”... and I was mostly right, and best of all, it did turn out to be fun!
It seemed like both a reasonable and easy request. The requirements were to measure the mains power grid frequency to a resolution of 0.01 Hertz, and to do it every 125 milliseconds (roughly; it could be a max of 200 milliseconds, but not much longer).
Why? In this case, the chase is better than the catch. It's enough to say the customer had his reasons, and this blog is about the chase.
Check the module specifications.
Since the customer wanted to measure either 220 VAC or 110 VAC, I knew that we would use a step-down transformer. Something with a secondary of 24 VAC should do the job.
After that, I thought I might use a diode to half-wave rectify the AC wave and give me a nice pulse to turn a digital input module like the SNAP-IDC5FAST on and off. But after looking at the specs and PAC Control commands we quickly saw that while the module would do a stellar job of counting the pulses, it was a square peg in a round hole for giving us the frequency.
Next up were the two analog input modules Opto 22 has made to do just the job: the SNAP-AIRATE and the SNAP-AIRATE-HFi. Again, with a quick look at the specifications we saw that the AIRATE was not going to cut it for this job; with a data freshness of 126 ms and an accuracy of -/+4 Hz at 50/60 Hz, it simply was not the right hammer for this nail.
The SNAP-AIRATE-HFi, on the other hand, ticked all the right boxes. Fast, accurate, great resolution, and to top it off, really simple to use in PAC Control: just look at its output and you are done. The frequency is the value returned.
I quickly put a module in my Learning Center, configured it in PAC Control, and...Boom! There is the mains frequency…..ahhhhhh, wow. But, uh, wait… the mains is jumping around between 70 something and 50 something Hertz??
I checked with the hardware guys, the very ones who designed the module, and they confirmed that it would be more than up to the job. So why the jumps in frequency? One word: noise.
The power company is making nice clean AC voltage, but the world we live in is less than sterile. The computers (and other devices) we use to do our jobs put a little noise on the main grid. The Opto module was sometimes triggering on that noise. The solution was to build a very simple filter. In my case, a capacitor and a resistor were chosen to create a roughly 100 Hz low-pass filter. That is to say, all signals below 100 Hz (the main grid frequency in the USA is 60 Hz; in a lot of the rest of the world it is 50 Hz) were passed and any above that were attenuated.
Here is one diagram to sum up the whole process.
(Yes, that's a UK power outlet.)
The results had to be tested, of course, so I set up a module at my house with the 100 Hz filter and another module on my desk at work with a 1000 Hz filter (I wanted to see the effect of the higher frequency filter) and put their outputs into a graph in groov.
My house is around 6 miles or 9 kilometers from the Opto 22 building. It was really interesting (well, I thought so at any rate) to see the grid frequency track so precisely over that sort of distance. It is also interesting to see the effects of the different filters. Of course we swapped the filters over and the results were the same: the green line was smooth when the 100 Hz filter was on the Learning Center at work and noisy at home where I tested both no filter and the 1000 Hz filter.
Why does the frequency even change?
That’s a great question and one that I had never stopped to ask myself or answer till now. The short version is that in your typical national or statewide power grid in use today, supply (that is, what’s generated by the power company) always has to match demand (what we the users are, uh, using). If demand is greater, the frequency goes down. If it's the other way around, the grid frequency goes up. Simple as that and as complex as that.
For some time I've been plotting the air temperature and the grid voltage here in Temecula. Here is one week's worth of data from my groov dashboard.
You can clearly see, when the days are warm, the voltage goes down. Of course I did a similar test of the grid frequency vs. voltage and found no parallel at all. I am not the only guy to run this test and find the same result.
Now all this may change in the future when we see batteries and the like being used to stabilize the grid, since they will be able to "spin" up very quickly and provide very (very) fast power reserves. Of course there are many large technical challenges to overcome, not to mention the cost, before we see those sorts of systems come into play. But many companies are working hard to make it happen.
Spec your module and measure the signal.
The takeaway from this is to check the module specifications and make sure it will do the job you want it to do, not the job you hope it will do. Also make sure you are measuring the signal you think you are and not something else. Pretty basic, I know, but still worth reminding ourselves of every now and then.
As it turns out measuring the main power grid frequency was both fun and easy, and I learned a great deal along the way. Win, win win.
Till next time, Cheers Mate.