Off-set with voltage sensor

Thread Starter

archxth_13

Joined Nov 23, 2021
24
Hello All!

I am in the process of detecting a full wave rectified signal, as can be seen in the picture below.
Full-wave rectified w.r.t input voltage sensor.png
The blue waveform represents the full wave rectified signal and the yellow waveform represents the output of my voltage sensor. The voltage sensor design I had selected is as follows:
Voltage sensor diagram.jpg
With the input of the voltage sensor being a voltage divider with a high side of 1Mohm and 560ohms. Now as one can see the voltage sensor gives a relatively noisy signal and i implemented a moving average filter to compensate for this. The code recieves the ADC values using polling and Is stored in a variable called VinputADC, furthermore that code is then sent to the moving average filter with the output of that being named as filter_out1.
Snippet of code.png
Now the problem that I seem to be facing is that my ADC values are not able to give me a consistent 0 value, which crucial for the algorithm I want to apply. The pictures below is a graphical representation of how the code plots its ADC values at different input voltages. The blue waveform represents the filtered code, while orange represents the raw ADC. Below shows it at a input of 27.3V.
Full-wave rectified STM32 27.3V.png
Input of 46.6V
Full-wave rectified STM32 46.6V.png
Input voltage of 67.6V
Full-wave rectified STM32 67.6V.png
I am using an STM32-nucleo-f303re and the sampling cycles I have selected is 601.5 cycles. If one sees the waveform it is clear that there is an off-set with the 0 line which is essentially what I require. I am currently doing an Active Power Correction algorithm. Does anyone know how to fix this off-set?

Thank you
 

joeyd999

Joined Jun 6, 2011
6,281
I'd skip the rectification and use an FFT or synchronous (or quadrature) detection to compute phase and magnitude of the frequencies of interest.

Computation is more involved, but software is free. And you'll need to sample and process fast enough for the highest frequency component in your source signal, but DSP-capable hardware is relatively cheap these days.
 

crutschow

Joined Mar 14, 2008
38,506
You are likely seeing aliased noise.
You have to analog (anti-alias) filter the signal to significantly reduce any noise components (to below the desired accuracy required) that are above 1/2 the sampling frequency (Nyquist limit), as that will give aliased noise in the sample which cannot be digitally filtered.

From this it can be noted than the higher the sample frequency is above twice the highest signal frequency, the lower the requirement for the required analog filtering, since any noise below 1/2 the sample frequency can be filtered digitally.
 
Last edited:
Top