LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increasing code speed

Hi
 
I have the attached vi that opens a file and then reads the 5 highest frequency/magnitude peaks and their locations over a certain width. The vi is used as a sub vi within a larger program. The problem is it takes minutes per execution , and I need to do this on hundreds of files. Any ideas on how to speed things up?
 
Cheers
 
Dave
0 Kudos
Message 1 of 12
(3,809 Views)
Average and Peek VIs are missing so can't see the whole VI
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 12
(3,801 Views)
Dave,

You appear to be doing a lot of duplication and unnecessary array manipulations. You transpose an array, split it into two cluster arrays, sort it, take a subset by splitting it, convert the clusters to numeric arrays, and then combine the result with a constant array which also has unnecessary manipulations (why not initialize a 2D array of the size needed?). And you do all of this twice, with different input data. A situation like this is usually a good place to create a subVI.

It is difficult to tell exactly what you are trying to do, but I feel very confident that it can be done more effectively. Tell us what the array manipulation needs to do and someone will likely be able to suggest a better way.

Lynn
Message 3 of 12
(3,783 Views)

Hi Lynn

The aim of the vi is to do the following -

1)Open a binary data file which has a constant sampling speed of 20kHz, but a variable length

2) The signal is then converted to a waveform

3) The signal is then filtered to remove low frequency noise

4) Signal then splits to two areas - one for magnitude, the other for frequency

5) For the magnitude, the peaks are then detected and listed in an array, along with the locations of the peaks - peaks must be over a certain width.

6) Same process is done for the frequency spectrum

7) The arrays are sorted to give the mag/freq in descending order. The 5 peak values are then extracted. If there are less than 5 values the arrays is padded out with the value 1.

Thats the basic operation. This will then be used in a larger, vi to pass the data to microsoft excel for analysis.

Cheers

 

Dave 

0 Kudos
Message 4 of 12
(3,742 Views)

It appears that the slow speed is due to the peaks vi. There is another peak vi in the SVT toolkit, but this does not allow you to specify a minnimum peak width. Is there any alternative, faster peak module that allows me to specify peak width?

Cheers

Dave

0 Kudos
Message 5 of 12
(3,710 Views)

Hi

Its very quiet here - any help would be much appreciated!

I've changed the peak detector vi and this has sped up the process but it is still very very slow when run in the parent vi. Attached are the various vi's.

 

Any help would be much appreciated.

Cheers

Dave

Download All
0 Kudos
Message 6 of 12
(3,668 Views)

Hi Dave,

Thanks for posting the code, can you add any of the binary files you are working on, so we can see the VI running with the same data as you?

 

Cheers,

Mark

0 Kudos
Message 7 of 12
(3,658 Views)
Hi Mark
 
Attached are some examples of the binary files. Note that the files can be of a variable length due to the process we are monitoring.
 
I couldn't upload them as .dat so I've had to rename with .txt extension which you will probably need to change back .dat before they will work.
 
Cheers
 
Dave
Download All
0 Kudos
Message 8 of 12
(3,652 Views)

Hi

Just wondering if anyone had any ideas?

 

0 Kudos
Message 9 of 12
(3,578 Views)
There is this wavelet based peak detection VI 'WA Multiscale Peak Detection.vi '. Ithink it comes along with the adv. signal processing toolkit. Don't  know about the speed aspect though. Just give it a try.
 
BR
0 Kudos
Message 10 of 12
(3,567 Views)