LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RMS sliding window

Hi Everyone

 

I am calculating the RMS from a 50 sample window (sampling rate 1000Hz). I am using the Biosignal RMS.vi but I want to change the window to use 25 samples before and 25 samples after the point I want  to calculate. I am still new to labview and have been running in circles a little. Help is appreciated! I have attached the VI I am using along with some sample data.

 

Thanks again!

Download All
0 Kudos
Message 1 of 3
(3,321 Views)

Hi DaveSA,

 

I'm not sure this is possible using just this particular VI.  You could however do this by making presamples in an array and putting postsamples on the end of the presamples. You might try using a while loop and "Replace Array" to cycle through sets of 25 samples and when you want to read, grab the latest 25 samples in your array and throw the next specificied 25 samples (using the Biosignal RMS.vi) on the end of your presamples.

David H.
National Instruments
0 Kudos
Message 2 of 3
(3,268 Views)

This is basically the same answer David gave you, but stated a little differently.  Consider what you want to do, namely take n RMS value of a 50-sample sliding window.  Let's say your total number of samples is 100.  How many 50-second sliding windows can you "fit"?  The answer is 100 - 50 = 50 (because the first window has Samples 1 to 50, and the 50'th has samples 51 to 100 -- any more windows won't have 50 samples).

 

Now consider how you want to interpret the values in, say, the first Window, samples 1 to 50.  The RMS value you compute represents responses over the entire 50-sample period, so you could reasonable say it represents the "midpoint" value (which would actually occur halfway between Samples 25 and 26, but that's a detail).  So if you ran your sliding window over the 100 points, you could say that the 50 points "represent the RMS values of samples 26 through 75".  Note that dealing with the "end points" when doing digital filtering is always an interesting question -- a reasonable thing to do is to start sampling before you need to save the data (say, 25 samples before) and continue sampling after you need to save (say by 25 samples).  Alternatively, throw away the first and last 25 samples, or "make your best guess" at the values (one method is to say "the first 25 samples are the same as Sample 26", or "the first 25 samples are a least-squares polynomial interpolation from points 26-75").

 

Bob Schor

0 Kudos
Message 3 of 3
(3,248 Views)