LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop slows down

Hi,

 

I am currently making an application in LabVIEW 2015 that has 4 while loops in parallel. One of them collects data from DAQmx device, Second & Third ones collects data from CNC Controller and Fourth one writes the collected data to a tdms file and also has a waveform chart displaying live data. All the loops run at 100ms time interval collecting 10 data/second (16 channels here 160 data/second). All these loops slow down after few seconds and especially the fourth one takes a significant drop in speeds. I have attached the LabVIEW snippet of second loop which is similar to third and fourth loop. First loop is nothing but DAQ Assistant VI. I am not allowed to completely share the VI due to certain restrictions. Requesting someone to help me with this.

 

Thank You.   

Download All
0 Kudos
Message 1 of 7
(642 Views)

It is difficult to say for sure, since I don't know where "appended array" comes from (hint: don't use local variables to transfer data between loops!). But my gues is that it is growing indefinitely and saving files to disk is taking longer and longer each time as a result. 

 

My suggestion is to use a queue to send data from your acquistion loop to your write loop, and only send the data that was acquired in the latest iteration. You then simply append the latest acquired data to the file you already have instead of overwriting the entire file each time.

 

Secondly, I suggest to completely remove any express VIs and replace them with primitive functions (open file once before loop -> write file each iteration -> close file once after loop. Express VIs are great to make very simple test programs, but any program that becomes more complex will suffer from the slowness of them.

Message 2 of 7
(609 Views)

Basjong seems to be right on the money!

The Write measurement file is opening and closing the refrence each time and then rewrites the full file 10 times/sec!

Open the ref before the loop (using primitives as suggested), only append the new data and close after the loop.

Send data through a queue to this loop, and you'll see it working as a charm.

 

Also, don't use Comparisons with Floats and reduce/remove the locals.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 7
(595 Views)

Please attach the actual VIs. A snippet full of local variables, potential race conditions, and terminals without labels is not useful.

 

In any case, 'Insert into array" should be a "built array" and growing data structures without upper limits is wrong. Do you know the final data sizes?

0 Kudos
Message 4 of 7
(544 Views)

Thank You @Basjong53

After using producer/consumer loop and replacing express VIs I was able to achieve maximum speeds. Also I directly wired the controls to terminals rather than using locals as per 

suggestion. But my waveform chart clears automatically after sometime or precisely while shuffling tabs. My chart has a waveform history length of 600 points and displays the data from 12 channels. Requesting to provide a reason/solution.   

0 Kudos
Message 5 of 7
(497 Views)

@altenbach I am unable to share the actual VI due certain organizational restrictions. 

0 Kudos
Message 6 of 7
(494 Views)

@Josh2212 wrote:

Thank You @Basjong53

After using producer/consumer loop and replacing express VIs I was able to achieve maximum speeds. Also I directly wired the controls to terminals rather than using locals as per 

suggestion. But my waveform chart clears automatically after sometime or precisely while shuffling tabs. My chart has a waveform history length of 600 points and displays the data from 12 channels. Requesting to provide a reason/solution.   


I'm guessing you have some case structure regarding tabs what don't have the data wire wired through to it resets to an empty array.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(387 Views)