LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop and start while loop on order

Hallo everyone,

 

I have this small IV, it means nothing but I want to know if it's possible to control each while loop. what I wish to do is to press the boolean button, then the while loop starts running and when i press it again the loop stops but when I press it again it works again, not that the program stops running at all. not only that but I need it for both loops. so i run one and stop the other then stop one and run the other and so on...

 

I dont know if this is possible and its not necessary to be done with loops, I just wrote loops because this is what I can do and understand, if there are any other possibilities then please feel free to share it with me.

0 Kudos
Message 1 of 5
(2,773 Views)

I would start out with some turorials, because you seem to have severe misconceptions about dataflow.

 

The sequence structure make no sense and has no purpose. Delete it.

If your controls should be read during execution, they belong inside the while loop. Currently, they are read once at the start of the program and then never again. All you get is the stale value stored inside the tunnel.

 

A toplevel loop should always spin. What you need is a state machine. Place the code inside each while loop in a case structure and make the other case empty (typically containing a small wait). Wire the boolean to the case and switch between the two states at will during execution.  You probably only need one single while loop containing both case structures. Add a stop button to the loop termination and only press it if you are done with execution.

 

Of course once you go the basics worked out, you might want to look into event structures to avoid polling.

0 Kudos
Message 2 of 5
(2,768 Views)

First, the sequence frame in your code is not necessary. You should remove it.

 

As for your question I would recommend you look at the examples for the producer/consumer architecture. Your producer would be a while loop with an event structure. This would be used to handle the UI such as the button press. Your consumer loops (based on your code you would have two of them) would have a simple state machine that will run when required. Take a look at the examples and then ask any questions you may have regarding that architecture.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 5
(2,765 Views)

Perhaps something like this.

0 Kudos
Message 4 of 5
(2,719 Views)

@paul_a_cardinale wrote:

Perhaps something like this.


I don't think we need to involve such a huge amount of code and new concepts (timed loop, notifiers, subVIs, clusters, arrays, event structures, etc.),  to solve such a simple problem. (This might turn off a beginner!).

 

Here's what I would do. 😄

 

 

Download All
0 Kudos
Message 5 of 5
(2,710 Views)