I'm a student working on an Electric Load Controller (ELC), for a water turbine in Peru. If you know ELC's already you can skip this part of the post i'll just explain it quickly
(ELC: An ELC is a devise that balances the production and consumation of electrical energy in an isolated power grid. A group of engineering students who went to the peru a few years ago made a water powered turbine (5kW), to give the people of an isolated mountain village acces to electricity (mainly used for lighting). The problem with this turbine is that during daytime little energy is consumed and the generator experiences almost no 'counter torque'. As a result the turbine starts to speed up, hereby generating a huge centrifugal force that tears the turbine apart and greatly reduces the lifespan. An other problem with the turbine and generator when the RPM is to high, is that the voltage on the net goes beyond the required 220V. Therefor we made an ELC. The working of this device is quite simple: it measures the frequency of the AC voltage on the net (should always be 60Hz). When the frequency goes beyond the 60Hz it activates a simple resistance R. This resistance dissipates part of the generated energy as heat. The resistance is cooled by water. When the net frequency goes back to 60Hz the resistance is switched off.)
A very important part of the ELC is the frequency measurement of the net voltage.
The problem is that we're having some serious harmonic distortion. This causes multiple zero-crossings where there should have been only one. As a result the MC thought the frequency was way higher then it actually was and all the dumploads were activated. I think is usefull to use this method.
Can someone help me for programming an analog input in the rawData?
Zero crossings are in the time domain - you would use the frequency domain to measure
frequency, think FFT (or rather DCT), or two resonators either side of 60Hz (59 and 61 perhaps)
to give a differential frequency signal (resonators remove all harmonics of course), or set up
a PLL to track the fundamental frequency. This would all be done digitally these days.
You could even do the very basic low-pass or band-pass filtering before zero-cross detection
if you wanted, not perfect but it at least substantially reduces noise and harmonics.
Why is your mains not sinusoidal though? This is something I would worry about first. Also
is this single phase or three-phase?
How high does the power frequency get during the day?
What's the range of operating frequencies that the turbine can withstand? With this control strategy - a single electrical load applied to the system, or not applied - I'd still expect to see frequency excursions that are pretty large.
How are you measuring frequency today? You're counting time between zero crossings, yes. How is the input signal connected? Is there filtering, or hysteresis? A 220V signal at 60 Hz has a slope of about 0.08 V per microsecond - kind of slow for direct measurement, with opportunity for multiple crossing detections near the zero-crossing. Your measurement troubles may be related more to noise in the measurement, than to power system harmonics.
Can you give us an idea of the magnitude of the largest harmonics? Is an image of an oscilloscope tracing available?
A simple way to fix this problem might be to simply lock out zero-crossing detection for a period of time after a crossing is detected. A reasonable approach might be to trigger the counter when the input toggles, and wait for a nominal quarter-cycle before re-enabling the counter. That would prevent double-stroking the counter should the signal wobble a couple of times at the zero-crossing. This approach will fail if the frequency excursions are too high.
The problem with this turbine is that during daytime little energy is consumed and the generator experiences almost no 'counter torque'. As a result the turbine starts to speed up, hereby generating a huge centrifugal force that tears the turbine apart and greatly reduces the lifespan. An other problem with the turbine and generator when the RPM is to high, is that the voltage on the net goes beyond the required 220V.
Why measure frequency?
Output frequency will be proportional to the turbine speed.
Put a tacho on the turbine shaft and regulate your tacho speed to the equivalent frequency.
No harmonic distortion.