English
Language : 

AN3322 Datasheet, PDF (29/38 Pages) STMicroelectronics – Watt-hour meter based on the STM32F101 microcontroller
AN3322
Computational issues and compensation algorithms
2.6
Filtering of input signal for proper zero crossing detection
Proper detection of the zero crossing is the key parameter in order to measure and compute
all the values correctly. Possible problems are caused when the voltage channel contains
more harmonics and such a signal with these harmonics crosses the zero voltage line more
times. Figure 16 shows the voltage signal that is crossing the zero line twice. The same
situation can be caused not only by higher harmonics but also by noise present in all the
circuitry.
Figure 16. Voltage signal crossing zero voltage line twice
In order to avoid an incorrect zero crossing detection, a filter was introduced. The filter is the
simple moving average. The length of the filter is 18. Since the number of the samples per
period of mains is 44, the filter removes all the harmonics starting at 50 Hz with growing
attenuation. Figure 17 shows the signal after the filtering that allows for failure-less zero
crossing detection.
Figure 17. Voltage signal used for correct zero crossing after proper filtering
DocID18304 Rev 1
29/38