openenergymonitor / EmonLib

Electricity monitoring library - install in Arduino IDE's libraries folder then restart the IDE
openenergymonitor.org
GNU Affero General Public License v3.0
584 stars 418 forks source link

error in calculating offset for RMS calulations #35

Closed dragonflight closed 4 years ago

dragonflight commented 7 years ago

First, I have no experience with Arduino's, nor do I have one - so pinch(grain) of salt - I just came across this while looking up ideas.

I do not know the speed of the iterations in the sampling loop, but assuming there are more that just a few samples each half cycle offsetIV(I) will move up and down by about (A * S)/1024 where A is the peak A/D count (≈500/2000 at full scale) and S is the number of samples per half wave.

Better would be to update the calculated offset each full wave or even just once each measurement (again depending on # samples each half wave) mike