LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using while loops within while loops?

Hi, within my program i developed i have many while loops within while loops. the reason for this is that i needs the loops to be independent of each other for using different rates of data collection, controling external switches by relays etc. My problem is that the longer my program runs for the harder it is for it to stop, even inserting a application stop or exit does'nt help. It just tends to stop responding and the only reliable way i can stop the program is to use the close. Any insights greatly appreciated.

Stuart
0 Kudos
Message 1 of 9
(3,700 Views)
1) How can while loops that are stacked one inside the other be independent of each other? An example (vi) of what you mean would be helpful.

2) A loop, that does not have an outside reason to suspend (like waiting for an I/O interrupt) will cycle very quickly, consuming all the power of the CPU. It is wise to have a "wait(ms)" call, even with 1 ms as argument it helps sometimes a lot.

3) Even if you have loops in parallel (where they would be truely independent) it will be neccessary to have a common STOP button or-ed together with the other terminating criteria to have a central control to stop.

Gabi
7.1 -- 2013
CLA
0 Kudos
Message 2 of 9
(3,700 Views)
Hi. I don't understand why you want to put many while loops in a single while loop. It makes more sense to me if you put all those while loops with a common stop in a sequence instead. As long as the loops are still running, the system will stay in that sequence.
Or if an outside while loop is really required, which I doubt, put more delay on it. Hope this helps.

Dan
0 Kudos
Message 3 of 9
(3,700 Views)
Hi, yes i mean loops in parallel. Could not remember the name for it. the reason i using so many while loops is that i use field point. The field point is a point to point device, so can not be streamed as in daqs. And when i control the field point modules i need each of them to respond in a different way e.g. slightly different sample rates etc. so i use parallel loops to make the devices independent of each other.

Stuart
0 Kudos
Message 4 of 9
(3,700 Views)
Hi Stuart
I read again your question.
Do you mean that the longer your program is running, the more time it takes to stop the execution once you hit a "stop button" that effects your while continuation ?
If you really have such a central "button" it might be a problem with memory. D you have a way to monitor the memory usage, like with the Windows task manager ?

If you have a problem with memory, check what is going into your loops. Labview has sometimes not very obvious ways to create local variables or references, that are not automatically destroyed.

Again a sample vi would help. It's just that I have only LV 6.0.

Gabi
7.1 -- 2013
CLA
Message 5 of 9
(3,700 Views)
Are you using memory over time? You can check this on a 2000 or XP machine in the task manager. You might have a memory lead from opening references repeatedly without closing them. This would explain sluggish behavior over time. You should also check to see if you are building large arrays. This will also slow your machine over time.
Message 6 of 9
(3,700 Views)
Hi, tried the task manager route and found that my program was using 98-100% cpu usage. I thought it may be the chart buffers in one of while loops that could be causing this, as i have five. But i removed them and still got the the same outcome. the thing i can not work out i have a new developed on the same principles as the first, but this program uses normally 2% of cpu usage. Any more comments u could suggest to help me.

Thanks stuart
0 Kudos
Message 7 of 9
(3,700 Views)
Thanks Gabi, it turned of to be a problem with the field point software side.Nothing to do with the while loops.

Thanks Stuart
0 Kudos
Message 8 of 9
(3,700 Views)
"Thanks Jeremy, it turned of to be a problem with the field point software side.Nothing to do with the while loops.

Stuart
0 Kudos
Message 9 of 9
(3,700 Views)