LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to stop multiple "for" loops by using just one stop button?

My program runs several "for" loops to sample data from multiple channels at certain frequency. I want to use one STOP button to set all loop condition to FALSE to stop them. I couldn't figure out how to do that. Help please.
0 Kudos
Message 1 of 4
(3,111 Views)
1. You cannot stop a for loop. It will run until the specified number of iterations has been completed.

2. Are your loops running in parallel or one after the other?

3. While loops can be stopped. Use them in place of for loops. Use a local variable, a functional global or action engine, or queues to pass the "Stop" command to the loops.

4. Can you put multiple channels into one data acquisition task and then separate the data later? Perhaps only one loop or a Producer/Consumer design is appropriate.

Lynn
Message 2 of 4
(3,107 Views)
Lynn has provided very good suggestions..
 
It appears you you need some form of while loop instead of FOR Loop..
Message 3 of 4
(3,100 Views)
I am pretty sure you already have WHILE loops, because FOR loops don't have a loop condition terminal as you already seem to have. 🙂
 
Lynn provided a great answer already.
 
He did not mention yet another possibility: event structures. See e.g. my example in this old thread:
Message 4 of 4
(3,086 Views)