127,127,126,127,127,126, etc) APPROX. = 126.67
If you have a voltage =126.66 in 8 bit mode you will likely get 127 and 126 readings.
If I use 1% resistors then the error from resistors could be as great as 2%. Typically under 0.5%
The ADC is not perfect. point 128 may be off a little. Typically it is close but it could be several counts off. I wanted to correct for both resistor and ADC worst case errors.
Yes I have a DC blocking cap.
It appears you read in data in 8 bit mode. After rectificaton you have 7 bit data.
I chose to read in data in 10 bit mode. Rectify to 9 bit data. Loose the LSB to get 8 bit data.
The math is done in 8 bit mode to keep the speed high.
In RMS mode I square the 8 bit number to get a 16 bit number that is averaged.
Bookmarks