LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop with increasing iteration time

Solved!
Go to solution

Cheers,
I have an issue where my loop takes longer and longer to complete, which makes my program insanely slow. Any tips on why that might happen and what I can do to improve it will be most welcome!
I am using a NI PCI-6259 and a NI SCB-68 to control 4 components and a detector. These 4 components can be given the value 1 or 0. My program is supposed to run through these 2^4 possibilities n times. For every new iteration n, however, the time it takes to run it increases with about 10-20%. 
The BondeDetector.vi is the program I would like to run n times. switch_HS.vi is the sub.vi switching the 4 components, and I suspect this is where my error is. This suspicion is based both on running the program in debugging mode, but also from observations of the components behaviour.
The last part the measureV.vi measures the intensity on the detector.
I hope I have provided enough information and that some of you might be able to help me out.

Sigurd

0 Kudos
Message 1 of 3
(2,312 Views)
Solution
Accepted by topic author Sig_Bor

You're repeatedly opening tasks each iteration of your loop. (Multiple times per iteration) This requires memory allocations that are not freed until the application closes. Instead, create the task once, and stop and start it as needed. So setup your switch_HS vi to take in 3 tasks that were created outside the loop. 

 

Look at the help for any of the create channel functions for more info on this. 

Message 2 of 3
(2,281 Views)

Understood!
Thanks a lot, Paul!

Message 3 of 3
(2,249 Views)