04-19-2018 04:46 AM
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
Solved! Go to Solution.
04-19-2018 07:25 AM - edited 04-19-2018 07:26 AM
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.
04-20-2018 09:21 AM
Understood!
Thanks a lot, Paul!