Contents AN3322
2/38 DocID18304 Rev 1
Contents
1 Watt-hour meter using the STM32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1 STM32 ADC parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Requirements for meter in Class B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Definitions of the power meter parameters (according to EN 50407-1:2006) . . . . . 7
1.3 STM32 ADC dynamic measurement range . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.1 Voltage measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.2 There are two current ranges in the meter . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 Error sources on the STM32 meter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5 Linearity of STM32 ADC and its INL reduction . . . . . . . . . . . . . . . . . . . . . 10
1.6 Thermal noise present on STM32 meter platform . . . . . . . . . . . . . . . . . . 10
1.7 Crosstalk between subsequent multiplexed channels . . . . . . . . . . . . . . . .11
1.8 Power and energy measurement by STM32 embedded ADC . . . . . . . . . 13
1.9 ADC enhancement by oversampling technique . . . . . . . . . . . . . . . . . . . . 15
1.10 Output values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Some reference values and constants are defined . . . . . . . . . . . . . . . . . . . . . . . . 16
1.10.1 RMS voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.10.2 RMS current - high gained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.10.3 RMS current - low gained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.10.4 Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.10.5 Energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.10.6 Pulse output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2 Computational issues and compensation algorithms . . . . . . . . . . . . . 22
2.1 Non-coherent sampling issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2 Timer evaluation for coherent sampling triggering . . . . . . . . . . . . . . . . . . 24
2.3 Timer setting constraints for coherent sampling triggering . . . . . . . . . . . . 25
2.4 Precise timer setting for coherent sampling . . . . . . . . . . . . . . . . . . . . . . . 26
2.5 Frequency measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.6 Filtering of input signal for proper zero crossing detection . . . . . . . . . . . . 29