Kaly

Calculate rms value of an an array

Recommended Posts

Somehow, I can't find an 'rms' function in Daqfactory. Is there truly no way to calculate the actual rms value of an array? The array may not be a sine wave so I cannot simply divide by the square root of 2. How would one go about obtaining the actual rms value of an array?

Share this post


Link to post
Share on other sites

There is no built in function for calculating RMS, but if you can point me to a page with the formula you'd like to use, I can probably show you how to write it in DAQFactory.

Share this post


Link to post
Share on other sites

Yup, but I'm not sure how well it will work with quantized data.  The accuracy is going to depend on the sampling interval, and some sort of curve fit might be helpful. 

But ignoring that and assuming you have a channel / array "X" with your data, the RMS calculation in DAQFactory would simply be:

mean(x^2) ^ 0.5

 Remember, doing x^2 returns an array the same size as x, where each value of x is squared.  Mean() takes the mean of whatever array is provided to it.  And ^ 0.5 raises whatever is to the left to the 1/2 power, which is the same as square root.

 

Share this post


Link to post
Share on other sites

OK So I think I have it all figured out. I attached a .ctl file showing how I did it. The file uses an original daqfactory example as a starting point.

Does all seem well?

Thanks.

Share this post


Link to post
Share on other sites

I don't think so.  You were on the right track at the bottom, but the field labelled RMS is:

max(captureddata) / 2^0.5

when it should be:

mean(captureData^2) ^ 0.5

 

Share this post


Link to post
Share on other sites

The field labeled RMS is from the original Daqfactory example. That field calculates RMS value by first determining the peak. That would only work for a true sine wave. I added the 'TrueRMS' field (and some other things). The 'TrueRMS' field should show the true RMS value for any wave shape. Accuracy depends on the field labeled 'capture length'.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now