LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping multiple while loop running at different rates to stop using single boolean stop button

Solved!
Go to solution

Hello

 

I have on the block diagram 4 loops doing different tasks. They are indipendent of each other but need to be showing on the single front panel- some of the wonders of labview!

Now I want to have a single stop button which is going to be actually a return button to retun to the main screen by stopping all four loops on the block diagram. I used stop button ( switch when released ) with local variable to stop other three loops. It stops the vi but its not a proper stop where vi stop properly and the grid on the front panel returns. Now all the loops also run at different rates so this isn't necessary that all loops are stopped immediately when one of the loop is stopped. Cant really think of a better way. Any ideas!

 

Kind Regards

Austin

 

Message 1 of 8
(6,192 Views)

If the grid does not show then the vi is not stopped. Does the grid return when you click the abort button? One of your loops is probably still running. Without seeing the code it is hard to say why. But I can say that writing a true to a while loop stop when true terminal does NOT cause the loop to stop. It will stop on that condition only after the code inside it is finished executing. Maybe you have a loop running that is waiting for some data from one of the stopped loops. Have you tried turning on highlight execution?

 

Do you use lots of local variables? Are there any wires connecting your loops together?

=====================
LabVIEW 2012


Message 2 of 8
(6,187 Views)

Do you have Sub VI in any loop and is that sub VI having a loop? In your case outer loop might be stopped but the sub VI might be running if you haven't taken care of the stop condition properly.

Message 3 of 8
(6,182 Views)

@SteveChandler wrote:

If the grid does not show then the vi is not stopped. Does the grid return when you click the abort button? One of your loops is probably still running. Without seeing the code it is hard to say why. But I can say that writing a true to a while loop stop when true terminal does NOT cause the loop to stop. It will stop on that condition only after the code inside it is finished executing. Maybe you have a loop running that is waiting for some data from one of the stopped loops. Have you tried turning on highlight execution?

 

Do you use lots of local variables? Are there any wires connecting your loops together?


One of the biggest issues I have seen people do is to not control when the Stop button is read. They generally have it as a simple read which will take place very early in the execution of the loop. Then either the code in the loops is stuck waiting for something else or the value they were using for the Stop was modified.

 

I prefer to use a named notifier is I am not using a queued state machine. It is far more reliable then reading a local variable. I wrap the check for the notifier in a small VI that will obtain the notifier and check if a notification occurred. I use a timeout of 0 so the program isn't delayed with the check.

 

NOTE: The copy I included here actually has a timeout of 10 on the notification. This actually is an old version and the latest has a timeout of 0.



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
Message 4 of 8
(6,179 Views)

I am calling a subvi from a main vi using a button on a main vi and have chosen the settings as appropriate for subvi nodes by right clicking subvi. So no problem calling vi from the main vi by using button. Then I have a " Return to main" from the subvi front panel. Within this subvi there are loops running at different rates. When I click "Return to main" every thing -control/indicator- stop updating but vi does not close and return to the main.

 

If I put disabled loop around the three loops and let one run at a time. The vi returns to the main and stop properly. But its when I want to stop all four vis using single " Return to main" button that it is not stopping and returning to main. Not sure if using one stop button and three local variables with button set to "switch when released" is the best option.

 

 

 

Message 5 of 8
(6,177 Views)

Have you looked at that vi with highlight execution turned on?

=====================
LabVIEW 2012


Message 6 of 8
(6,174 Views)

You would have got solution by now if you had posted atleast screen shot of block diagram or sharing VI. Looks like a simple problem.

Message 7 of 8
(6,168 Views)
Solution
Accepted by topic author K.Waris

Local variables is ok in this instance, but you'll need to keep the control in switch mode (not latch).

A better solution would be to have all loops as an event structure all listening to Stop Value change. Or have the Stop Value change event generate a user defined Exit-event or similar.

 

/Y

 

 

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 8
(6,160 Views)