LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How program for-loop to calculate RMS with window length of 100 samples and window step of 1 sample

Solved!
Go to solution

Hi Jack,

 

read the context help for the PtByPt-RMS! That explains all the magic...

 

No, you don't need a SubArray function or whatever!

Best regards,
GerdW


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

Hello,

 

Assuming you already have an array with all the data in it, you could try having two for-loops [one inside the other], (one that goes up to 4901, and the inside one that goes up to 100,passing a starting value of the array X to which will receive up to X+100 samples to get your rms), using the Iteration numbers within the loops as reference.

 

Let me know if this idea helps,

Miguel V
National Instruments
0 Kudos
Message 12 of 21
(2,634 Views)

Sorry... I have read the context help for the RMS ptbypt and I can't understand how the X input (signal) to the function changes for each interation... It is processing consecutive blocks of 100 samples...e.g block 1-100, 101-200, 201-300, etc, ct

 

check.png

 

Ohhhhh!! Hang on.... When the vi runs, the 2nd loop will not calculate the RMS until 100 samples became available, once the first 100 samples are available and the RMS is calculated, it will then update the 100 sample sequence (when the 101 sample is available) by dropping the oldest sample (i.e. sample 1), and adding the most recent sample (i,e, sample 101), providing an updated sequence on with the RMS calculation is performed...

 

Is this right? So all I would need to do is wire my 5000 sample signal straight through to the X input of the RMS ptbypt, which would be inside the for-loop (as you have it the 2nd loop above)?...

 

Now I feel stupid...

 

Thanks,

 

 

 

 

 

0 Kudos
Message 13 of 21
(2,632 Views)

@jcannon wrote:

Is this right? So all I would need to do is wire my 5000 sample signal straight through to the X input of the RMS ptbypt, which would be inside the for-loop (as you have it the 2nd loop above)?...

 

That is right.

 

You might have to throw away the first 99 values from the output array, depending on your requirements.  The for loop will output something regardless and you won't have a completed 100 sample RMS until the 100th iteration.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 21
(2,627 Views)

So the RMSptbypt will output values for any sample length, up to the sample length defined in the function.... So if I set the function to calculate the RMS over 100 samples, I will still get a value for any sample length between 1-99 samples?

 

Is that is the case I think it would be easier to use the subarray function to get the samples of interest so that I known than the output values form the RMSptbypt function directly match which the sections of the signal I am interested in.... I will nee tosynch these RMS values with other signals (e.g. force/strain), which will be mean dropping the first and last 50 sample from those signals...Using the subsarray will permit easier synching.

 

Regards,

Jack

0 Kudos
Message 15 of 21
(2,607 Views)

So you are now looking for something like this?  I scaled it down to test it.  You would change the 10 to 100.

 

Moving RMS.png


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 21
(2,609 Views)

Hi crossrulz,

 

Your solves my problem... I made a couple of changes to include the window length and step length in the calculations...

 

Many thanks,

Jack

 

 

0 Kudos
Message 17 of 21
(2,589 Views)
Solution
Accepted by jcannon

I think what you really want is this.  You were shortening your window size and weren't stepping your windows position inside of the loop.  Also, use the Quotient & Remainder VI for integers.  It makes life a little easier.

 

RMS.png


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 18 of 21
(2,581 Views)

Hi crossrulz,

 

This is brillant..!

 

Many thanks for your help!!

 

Regards,

Jack

0 Kudos
Message 19 of 21
(2,566 Views)

You can use the moving average program for that.

0 Kudos
Message 20 of 21
(2,154 Views)