AC powerline monioring, zerro crossing detection

Thread Starter

iceman529

Joined Jun 17, 2013
16
Hi I am working on a project analyzing the ac power line and I need to detect the zero-crossing point using an 16bit ADC, is there a smarter/better way of doing this than

if(last_sample==<== adc_average&==&== current_ sample> adc_average)

I sample 128 times per period and I'm calculating the adc_average every period, by using the method above I'm still having some jitter when detecting the zero-crossing.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,415
It's better to do this digitally: drop a transistor next to your power transformer to capture the AC wave and make power line synched pulses.
 

Thread Starter

iceman529

Joined Jun 17, 2013
16
I have to use the ADC for doing this so the only way i see it is maybe there a better mathematical solution to my question?
 

ericgibbs

Joined Jan 29, 2010
21,567
I sample 128 times per period and I'm calculating the adc_average every period, by using the method above I'm still having some jitter when detecting the zero-crossing.
hi,
Sampling at 128/sec is every ~8mSec, so if the mains frequency is say 50Hz, 20mS, I would expect you would always get jitter when trying to detect zero crossing using this method.

As suggested, a comparator which triggers a MCU interrupt would be the way I would go, you can still process the AC waveform using the ADC.

E
 

THE_RB

Joined Feb 11, 2008
5,438
hi,
Sampling at 128/sec is every ~8mSec, ...
...
Hi Eric, I believe he is sampling 128 times during each mains cycle period?

For the O.P, I think you can use a "debouncing" system to remove any noise artifacts near the zero cross point.

You can use similar code but detect when the ADC has been >avg for X samples (detects / edge), then when it has been <avg for X samples you detected the \ edge.

A more sophisticated system uses a window, and will be safe even when any individual zero-cross is damaged;



The one above I have used many times with excellent result. Because it syncs first, then only tests for the edge during a tiny window, it will negate large errors that occur during any one cycle and give a solid sync even if there is some nasty noise at times.

More mains sync systems are shown on this page (3/4 down the page);
http://romanblack.com/onesec/High_Acc_Timing.htm#decfreq
:)
 
Top