# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Calculate RMS with offset

Hello,

I acquire a sinusodial waveform signal and calculate the RMS value using "Average DC-RMS.vi". The calculation works, if the waveform is symmetric around 0. If I add an offset, the calculation is wrong. Any ideas how to solve this?

Thanks a lot and best regards.

Michael

P.S.: I am using LabVIEW 2012.

Message 1 of 11
(3,123 Views)

## Re: Calculate RMS with offset

Hi Micha,

If I add an offset, the calculation is wrong.

What exactly is wrong with the result? Which result do you expect?

You know how the RMS is defined?

Any ideas how to solve this?

You might subtract the DC offset from your waveform before calculating the RMS…

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome

Message 2 of 11
(3,107 Views)

## Re: Calculate RMS with offset

Hello Gerd,

if amplitude is less high then the negative offset the vi calculates a positive value (e.g. amplitude 1V, offset -2V ==> RMS = 2,12V). Okay, depending on the definition, the result might be right, but in realitiy for me it is wrong. In reality it should be a negative value.

How can get the offset, if I only have a acquired wafevorm?

Thanks a lot and best regards.

Michael

Message 3 of 11
(3,102 Views)

## Re: Calculate RMS with offset

Hi Micha,

In reality it should be a negative value.

So you want to have a negative value - from an operation, which involves to square values and take the root from a sum?

Really???

Okay, depending on the definition, the result might be right, but in realitiy for me it is wrong.

No, even in reality the result is correct!

You need to define your requirements - and develop an algorithm to fulfill those requirements…

How can get the offset, if I only have a acquired wafevorm?

There are functions to calculate the DC offset from a waveform…

(Basically it's just the mean value.)

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome

Message 4 of 11
(3,099 Views)

## Re: Calculate RMS with offset

So, what is the task you have to solve?

I have a maybe similar task when I calibrate DAQ cards: My calibrator (Fluke 5700A ) create a well defined RMS output and the DAQ will read a sine including an offset (and more) .  In my application the sine amplitude is the value of interest.

So I apply a sine fit ( easy method is tone detection.vi ) to get the amplitude and phase and look at the residual (RMS , peak to peak noise, offset and (harmonic) distortion).  Read a full number of periodes that also matches full periodes of your line frequency and you can get nice results.

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

Message 5 of 11
(3,074 Views)

## Re: Calculate RMS with offset

@MichaGue_01 wrote:

How can get the offset, if I only have a acquired wafevorm?

Suppose I generate a random signal (using the NI Random Number generator which gives values between 0 and 1) of 1000 points and ask "What is the offset of this signal"?  What would you answer?  How did you get that?  What if I added an (unknown-to-you) additional offset to it?  How would you compute the offset?

You could do the same thing with a sinusoidal signal, but you might be a little bit "off" depending on how you define "offset".  To understand what I mean, consider that the signal represents a half-sinusoid, i.e. sin (theta), where theta goes from 0 to pi.  If you have many cycles of a sinusoid, the "offset estimation" method I hope you figured out from the previous paragraph should give a more accurate answer.

Bob Schor

Message 6 of 11
(3,056 Views)

## Re: Calculate RMS with offset

Us the;

Signal Processing >>> Waveform Measurments >>> Basic Averaged DC-RMS

to calculate the DC level and simply subtract that DC from your waveform PRIOR to getting the RMS value and you will get the value you want save the negative sign.

Spoiler
Somewhere in teh back of my head there is an alarm going off saying "Negative RMS? Doesn't that break some physical law if not qualify one for  a Nobel prize or something?

Ben

Message 7 of 11
(3,048 Views)

## Re: Calculate RMS with offset

@Ben wrote:

Spoiler
Somewhere in teh back of my head there is an alarm going off saying "Negative RMS? Doesn't that break some physical law if not qualify one for  a Nobel prize or something.

It's perfectly logical if it's the RMS of an imaginary signal, the Imaginary RMS.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 8 of 11
(3,034 Views)

## Re: Calculate RMS with offset

turn it 90° or 270° ??

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

Message 9 of 11
(3,026 Views)
Solution
Accepted by topic author MichaGue_01

## Re: Calculate RMS with offset

@MichaGue_01 wrote:

if amplitude is less high then the negative offset the vi calculates a positive value (e.g. amplitude 1V, offset -2V ==> RMS = 2,12V). Okay, depending on the definition, the result might be right, but in realitiy for me it is wrong. In reality it should be a negative value.

No.  RMS is a measurement of the AC component of a signal (closely related to peak-to-peak).  Offset is the DC component.  So RMS should never be negative.

As Ben stated, to do your measurements properly you need to calculate the average of the signal (gives you the offset), subtract that value from every data point and then calculate the RMS.  If you have really tight limits, you should also do some processing to make sure you have an integer number of cycles captured.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 10 of 11
(3,006 Views)