LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating Vrms in labview

I am using the NI 9220 with the NI cDAQ-9185 to measure temperature and voltage (to calculate current using a shunt) of an AC circuit. I would like the system to output the RMS voltage/current in an array and on a waveform (not the voltage waveform, only the rms values) with the temperatures (so I can correlate temperature rise with RMS current/voltage). I am currently using the RMS VI block to calculate the voltage using a 20kHZ frequency and 1000 samples (I have also tried 20k samples), the source voltage is at a ~60 Hz frequency. This however is not outputting a consistent RMS value and when compared to values measured with a current clamp multimeter, is not very accurate. Is there a better RMS VI to use to calculate the voltage/current? Any suggestions would be much appreciated, as this is the final piece before my code should be done.

 

Thanks!

0 Kudos
Message 1 of 9
(1,925 Views)

Hi PTL,

 


@PTL_HCL wrote:

 I am currently using the RMS VI block to calculate the voltage using a 20kHZ frequency and 1000 samples (I have also tried 20k samples), the source voltage is at a ~60 Hz frequency.


Have you tried to sample at 18kHz (or 24kHz) and read 3000 (or 4000) samples?

This should fit better to your 60Hz power supply frequency…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(1,904 Views)

I think (based on a little testing, which I'll explain, below) that the NI Calculation of RMS is probably spot-on, but maybe you are "applying it wrong".  I also think I disagree with my friend @GerdW about your sampling -- for 60 Hz signals, you'll get an integer number of cycles with 1000 or 20,000 samples at 20 kHz, no need for other sampling frequencies.

 

However, you might not understand what RMS means!  Fortunately, LabVIEW provides the tools to let you "do the experiment" and see how "noise" (which I think is Gaussian), "offset", and "other frequencies" can have a dramatic influence on RMS.

 

Look at the Waveform Palette -- it has a number of useful VIs that you can use to build a "Test Bench" to generate analog signals and bring on the Analysis Tools to see what you get.  I built the following in about 5 minutes, saved it as a Snippet (it's simple enough that even if you don't have LabVIEW 2021, you can "build it from scratch", yourself).  Of course, just after I saved the Snippet, I (stupidly) closed LabVIEW, so I lost the source VI (and am too lazy to pull it back).

 

Anyway, here's the Snippet:

Explore RMS.png

The box with all the Inputs is the Tones & Noise generator from the Analog Wfm, Generation sub-Palette, which takes an array of Tone Frequency, Amplitude, and Phase Clusters (I recommend starting with 60 Hz, amplitude 1, and 248 Hz, amplitude 0), plus inputs for Noise and Offset (start with both 0).  The lower cluster is the Sampling Frequency (20000) and Number of Samples (1000).  This generates data that you can put into the RMS block and see what you get.

 

For 1 second to noise-free 60 Hz, amplitude 1, the "right answer" is sqrt(2)/2 = 0.71.  Guess what LabVIEW computes?

 

Now explore "messing it up".  Add a second waveform of amplitude 1, but a different frequency.  Add (what I assume is Gaussian) noise.  What changes?  What does that suggest you might need to do to "condition" your signal?

 

Bob Schor 

Message 3 of 9
(1,857 Views)

Hi Bob,

 


@Bob_Schor wrote:

I also think I disagree with my friend @GerdW about your sampling -- for 60 Hz signals, you'll get an integer number of cycles with 1000 or 20,000 samples at 20 kHz, no need for other sampling frequencies.


You're right. It seems my calculation was completely wrong yesterday evening…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(1,848 Views)

You measure the RMS in a window, in best case that window matches n periodes of the signal of interest.

in the boundaries of the aquisition, a rectangular window of n periodes give the correct answer.

A problem for precise and fast AC/line RMS measurements can be small variances in the line frequency.

but there is a cycle RMS vi 😄  maybe a bit tricky if a strickly continous measurement is needed.

 

I once wrote my own one using tone detection to measure the actual frequency and cut the max cycles out of a fixed number of samples (no need for phase in this case)

 

@ Bob: 1000 samples @ 20 kSPS results in 50 ms signal wich is not a multiple of 1/60 s 😉  

 

 

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 ǝɥʇ'


0 Kudos
Message 5 of 9
(1,843 Views)

Hi Volker,

 


@Henrik_Volkers wrote:

@ Bob: 1000 samples @ 20 kSPS results in 50 ms signal wich is not a multiple of 1/60 s 😉  


1000S/20kS/s * 60 Hz = 0.05ms * 60 Hz = 3 or 1/20 / 1/60 = 3…

🙂

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 9
(1,819 Views)

You are never as dumb as when you try to show how smart you are ...

 

Bob Schor

Message 7 of 9
(1,800 Views)

@Bob_Schor wrote:

You are never as dumb as when you try to show how smart you are ...

 

Bob Schor


The problem with that is the reverse is never true.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 8 of 9
(1,794 Views)

OK OK 

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 9
(1,756 Views)