Hello All!
I am in the process of detecting a full wave rectified signal, as can be seen in the picture below.

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:

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.

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.

Input of 46.6V

Input voltage of 67.6V

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
I am in the process of detecting a full wave rectified signal, as can be seen in the picture below.

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:

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.

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.

Input of 46.6V

Input voltage of 67.6V

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