LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can two parallel while loops have the same stop control?

Hi Guys,

 

Can  two while loops in parallel be stopped by the same control? I dont think I can create a Property node of a stop from one while loop and use it for the other. Is there any way to do this? All ideas welcome. Thanks!

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 1 of 23
(7,900 Views)
Yes.  You can use a property node for value of the stop button in one while loop to stop the other.  Or better yet, use a local variable.  However you won't be able to set the mechanical latching of the stop button to latching.  You will need to set it to switching.  And if you want it to snap back to False, create another local variable and wire a False to it so that it executes once both while loops have finished.
Message 2 of 23
(7,894 Views)

If you use a Stop button you need to change the mechanical action from a latch-type to a switch-type. Then you can use a property node or local variable in the other loop to read the state of the button. You will need to make sure to set its value to false at the beginning of the program.

Message 3 of 23
(7,892 Views)
Wow for the quick reply. THanks guys!! 🙂
I may not be perfect, but I'm all I got!
0 Kudos
Message 4 of 23
(7,874 Views)

Maybe some kind of overkill, but you should also learn about parallel loop design patterns.

I haven't sneaked into this webcast, but at least the title fits exactly what i recommend you to learn about.....

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 5 of 23
(7,872 Views)
I have been looking to remodel this existing program that someone else had written and now my plan was to use Parallel looping design to modeify it. State machines was something I was looking to learn but was putting it off for a while because I was busy with other stuff. This video is a good start I needed. Thanks Norbert! 🙂
I may not be perfect, but I'm all I got!
0 Kudos
Message 6 of 23
(7,864 Views)

smercurio_fc wrote:
If you use a Stop button you need to change the mechanical action from a latch-type to a switch-type. Then you can use a property node or local variable in the other loop to read the state of the button. You will need to make sure to set its value to false at the beginning of the program.

 

If you want to keep the latch mechanical action (it makes things much easier!), you can use event structures in each loop. No locals or property nodes needed.
 
Message 7 of 23
(7,840 Views)

I like Altenbach's solution with the event structures.  It may get tricky if you code scales up and you need to implement state machines.

 

Depending on your code architecture, you can also consider notifiers or using the queue (especially if you already use a queue). 

 

Message 8 of 23
(7,818 Views)

Good point re: the mechanical latch setting of the stop button.

 

Yep, I like to stop loops with the error output of Notifiers or Queues - especially sense just about any dual-loop scheme I do will contain a Notifier or Queue anyway. See picture - bottom loop stops when top loop stops.

 

Message Edited by Broken Arrow on 04-12-2010 12:37 PM
Richard






Message 9 of 23
(7,794 Views)

Ray.R wrote:

I like Altenbach's solution with the event structures.  It may get tricky if you code scales up and you need to implement state machines.


 

The main advantage is the fact the all loops can stopped quickly, e.g. even if the loop rates (=timeouts) are very long (e.g. seconds to minutes).
Message 10 of 23
(7,772 Views)