RMS calculation does not agree with DMM's

Hi,

I have concocted a simple sketch to sample a 2Vpp sinewave voltage at 50Hz on ADC0.
The sketch calculates an RMS voltage of 1.2, which agrees with the RMS calculation of my DSO.
However, these values do not agree with two of my TRUE RMS DMM's, they report about 0.715V and also not with an online Vpp to RMS convertor, which reports 0.714V. [https://www.allaboutcircuits.com/tools/rms-voltage-calculator/]

I can't figure out where the differences come from.
Can you help/enlighten me?

Timer_rms_test.ino (3.6 KB)

2v ptp is 1v peak which is an rms voltage of 0.7071 v (i.e. i/sqrt(2)). Have you got a DC offset on the signal you are sampling?

I can't be bothered to work out how that sketch works I'm afraid, but you need to take your samples, calculate their mean over the block, subtract the mean from each sample to remove DC offset, then square, sum, and take the mean again. Depending on how many samples you have the mean may vary with exactly where you start and stop sampling the block.

Thanks for the quick reply.
No need to bother with the sketch, this is all textbook stuff.
There is no offset on the waveform, it is specifically removed by the AWG. The bottom of the sinewave is at 0V.

Because I do not have a DC component (never will) I believe I do not need to subtract the mean from each sample.

At first I was sampling the 50Hz sinewave 20x at 1ms, getting one complete cycle covered, but that result was unstable, ie has a slow periodic drift between 1.2 and 1.3V. Sampling 40 times at every 1ms showed a more stable result at 1.2 with an occasional drift to 1.27 and then back to 1.2V. This could be due to a calculation drift based on the sampling start-stop of the waveform. Right now the sampling is free running.

I will need to study the relation of using Vp (apperantly used by the DMM's) and Vp-p (used by my code and the DSO) more.

Thanks!

The bottom of a sine wave is negative so if the sine wave is offset to put the bottom at 0 it has a DC offset.

Exactly! And the rms value of such a waveform of 1v ptp is sqrt(1^2 + .7071^2) = sqrt(1+.5) = sqrt(1.5)= 1.22v. Where have I seen that value?

Can you post a schematic (or sketch of the hardware) ? This will answer the "DC" offset concern.

Note, If you run the 1V AC into an analog pin of the processor you will get a half wave rectified sine wave. You should also know mains voltage is rarely even close to a pure sine wave.

How good is your "TRUE RMS DMM" ?

1 Like

Thank you @johnwasser and @jhaine, that was helpful and clarified a lot.
Obviously I didn't "get" the sinewave offset, even though everything was positive from GND.

To try to circumvent the offset issue for a moment, I used my AWG to output a 3 Vp double rectified sinewave. This is also the intended input for the system this test is part of.

My sketch and the DSO again agree with the (calculated) RMS values for this waveform (2.08 & 2.1Vrms), but the DMM's are not in agreement with 0.916VAC, so the original question was still open for me.

The comments about the offset put me on the right track however, so this is also for others following this topic.

The reason why the DSO RMS calculation for the waveform are so different from a true RMS DMM is that the DMM's measure the AC coupled waveform. When I AC couple the DSO input, the RMS voltages agree.


There are several examples for RMS calculations and scripts out there, similar to what that I use, so be aware.
I have seen libraries that take the offset into account. I need to examine them.

Standard approach in DSP is just to take the mean of the sample block and subtract from each sample.

This library produces the correct results.
[GitHub - MartinStokroos/TrueRMS: Average, RMS, Power and Energy measurement library for Arduino.]
I found a good explanation that explained what was pointed out to me.
[How to Derive the RMS Value of a Sine Wave with a DC Offset – Mastering Electronics Design]

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.