G
Gold_Spark
Guest
I\'m using a STM32 Cortex M0+ to read an AC signal from a CT. I\'m sampling at 6kHz and storing 400 samples. The signal has a DC bias equal to Vcc/2 = 1.65V. In the digital domain this is 2048. In hardware this DC value is very precise, but when sampling it, it varies from 2044 to 2052 inside the buffer. Now if I want to do RMS in that set of data, I need to find a way to deal with this DC bias variation.
I have been thinking the following:
1- Subtract a fixed value of 2048 from each ADC reading. This is no so good as I said above this value may vary slightly. Also, if I want to read zero cross it may cause errors to choose exactly 2048 as reference.
2- Sample the DC bias and average it.
3- Don\'t remove the DC bias. If I calculate RMS then I would get the DC value when there\'s no input signal.
4- Use a more sophisticated software high pass filter?
Example of DC bias readings:
ADC_buffer
[0] 2048
[1] 2046
[2] 2049
[3] 2051
[4] 2051
[5] 2052
[6] 2050
[7] 2050
[8] 2050
[9] 2047
[10] 2049
[11] 2050
[12] 2049
I appreciate any help or suggestion.
I have been thinking the following:
1- Subtract a fixed value of 2048 from each ADC reading. This is no so good as I said above this value may vary slightly. Also, if I want to read zero cross it may cause errors to choose exactly 2048 as reference.
2- Sample the DC bias and average it.
3- Don\'t remove the DC bias. If I calculate RMS then I would get the DC value when there\'s no input signal.
4- Use a more sophisticated software high pass filter?
Example of DC bias readings:
ADC_buffer
[0] 2048
[1] 2046
[2] 2049
[3] 2051
[4] 2051
[5] 2052
[6] 2050
[7] 2050
[8] 2050
[9] 2047
[10] 2049
[11] 2050
[12] 2049
I appreciate any help or suggestion.