LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to stop parallel loops at the same time, from any loop?

If there is a vi with two or more parallel while loops, what would be a good method to simultaneously stop parallel loop execution, from any of the parallel loops? My intent was to try and do this without local variables, so I used notifiers. This seems like an ok method for two loops, but how about for n loops?

In addition, my code has a flaw. I use an OR block to compare the stop status of each of the loops. This works fine most of the time, but if both loops are triggered to stop at the same time,the boolean result will be false, causing the loops to never stop. How can this be avoided?

Thanks,

Curt
0 Kudos
Message 1 of 4
(3,627 Views)
I think you have the right idea, notifiers are one of the better ways to stop parallel loops. You can simplify things by using 1 notifier for everything. I modified your VI to use 1 notifier, it will set the notifier to True ONLY if the loop is stopping, then it stops. The other loop will read the notifier status, and stop based on it the next time it executes.
I also changed the second loop to stop and notify if it has an error (that is usually a good idea, especally if you have I/O or other things that can cause problems)
I also changed the switch mechanical action, that will eliminate the problems for your second question.
The VI's attached are written in Labview 7.0
P.S. If you have 7.1, the Queues are polymorphic, meaning that the typecast operat
ions are NOT needed!
0 Kudos
Message 2 of 4
(3,627 Views)
On the mechanical action of the switch, by having it set to Switch Until Released, you can click on the second Stop button very fast and it will not stop the vi. That is because you pressed the mouse button down (state=true) and released it (state=false), all during the 250 msec timer period. It is best to set the switch action to either Latch when Pressed or Latch when Released. That way, the switch stays latched until the program reads its state. You can press and release during the 250 msec window, and the state will remain true until the 250msec is up and the vi reads the state. This will always stop the vi. Change the 250 msec to 1000 and you can better illustrate the result.
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 4
(3,627 Views)
dnuff,

Thanks for the answer. I relized that I only needed one notifier soon after I posted the question. I will check out the changes that you made.

thanks again... curt
0 Kudos
Message 4 of 4
(3,627 Views)