LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RMS calculation through Rectangular Window with 25% time gap

Solved!
Go to solution
Solution
Accepted by AlainKabs

That requires doing all the calculations in 1 ms or less. The Extract Portion VI in your code averages >2.7 ms on my computer and the longest call took >16 ms according to the Profile tool. 

 

Does the processing need to be done at the acquisiton rate or can the data be processed later at a lower rate?

 

Since your data (in the simulation) is an array, doing the processing yourself with array primitives may be faster than conversion to Dyanmic Data Type and back for the Express VI. Internally the Express VI converts DDT to an array of waveforms then uses WDT Get Waveform Subset.vi which does a bunch of things irrelevant to your code before using Array Subset to get the desired portion.  Just using Array Subset and some simple bookeeping for the index will certanly eliminate a lot of code and might be fast enough.

 

You may also be able to use for loop parallelism to speed things up.

 

Lynn

0 Kudos
Message 11 of 13
(498 Views)

Your code has an error. The last segment has only 375 elements, not 500.  It is easy to see. Wire from the Array Size to the border of the while loop. Set the tunnel mode to Indexing. Place an indicator outside the loop. 

 

RMS overlap.png

I tried the Array Subset method I suggested earlier. It is somewhat faster (even allowing for calculating 1 fewer segment) but still takes >9 ms. 

 

I noticed that most of the time is involved with the drawing of the display (as is often the case). So I created a subVI (RMS by Segment) to do the calculations. With the subVI FP closed, the calculations take an average of 41 us for the 1000 sample data set. It takes 630-860 us for a 100000 sample data set. The range depends on which combination of methods I chose. Surprisingly it seems that calculating RMS with primitives is significantly faster than usnig RMS.vi. Of course it does no error checking but you are not using the error anyway.

 

RMS primitive.png

 

Also note that the variations in the value of RMS in RMS List are due to calculating over incomplete cycles of the input waveform.

 

 

 

Lynn

Download All
0 Kudos
Message 12 of 13
(492 Views)

Dear  Lynn aka Johnsold,

 

By 1 millisecond integration time, I did not mean the processing time, but the size of the time window ( t = N / fs ).

 

 

Moreover, the Array Subset tool works just great, my computer thanks you for the relief. I have not tried the primitive RMS calculation yet, but I keep it in mind in case I need to spare more memory. Smiley Wink 

RMS primitive.png

 

 

 

 

 

 

Finally, I know the last segment might be shorter than the others, because of the overlap of the windows. It is not a problem. I even use that particularity to end my windowing While loop.

RMS List.png

 

 

 

 

 

 

 

 

 

 

 

Thank you very much.

 

Regards.

0 Kudos
Message 13 of 13
(454 Views)