From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My stop button is not working

Solved!
Go to solution

I have this Vi with two while loops. The stop button of the inner loop is working perfectly. When I press it, it get out of the loop. Then, If I press the other stop button of the bigger while loop, it does not work. Any ideas about why this happens?

 

0 Kudos
Message 1 of 17
(6,081 Views)

Because you have the stop button OUTSIDE your loop.

wrong.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 17
(6,070 Views)

Of course it does not stop that while loop, since that stop button is outside of that while loop. You need to understand data flow: when your VI starts to execute, that Stop button value is only read once, and never again. So the stop condition can never get True.

 

By the way, you should go through the Core 1 tutorial, and learn how to design a proper State Machine, which would result in a clear and logical code. The best indicator of "design went Mad Max" is when you see lots of Flat Sequence structures and multiple Stop buttons in a VI (and when it is so big, that I need to buy a new monitor to see the whole block diagram).

0 Kudos
Message 3 of 17
(6,067 Views)
Solution
Accepted by topic author lcf2014

Move the Stop button's terminal inside of the while loop and wire it to the Loop Condition.

 

Having the terminal outside of the while loop causes LabVIEW to read the value once at initial execution of the VI. The while loop will always read False on the wire whether the button is pressed or not.

 

Having the terminal inside the loop makes LabVIEW read the current Boolean value at every loop iteration.

 

Break, step, and probe to see this in action.

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
0 Kudos
Message 4 of 17
(6,062 Views)

I've tried to put it inside and it is not working. I've put it outside because I saw this tutorial in labview and it is telling to put the stop button outside the loop.

 

http://www.ni.com/getting-started/labview-basics/pt/execution-structures

 

I have another version of this program with state machine, but my professor likes to use this version, so I have to fix it.

0 Kudos
Message 5 of 17
(6,061 Views)

It is listed as a common mistake. Not how to do it right. Read the text!

Message 6 of 17
(6,055 Views)

ah Ok. I didnt understand it well. Anyway, I've moved the stop button and it is still not iterating the loop. I think it is stuck at that structure near mover button. I've tried to put the stop button inside but it worked once and then it was not working again.

0 Kudos
Message 7 of 17
(6,049 Views)

Quite frankly your code is just wrong on so many levels the stop button is the least of your worries.

 

Granted it may work but as this issue has shown, you really need to learn the basics before you tackle a program of this magnitude.

 

Here's a big list of free online training

https://decibel.ni.com/content/docs/DOC-13978

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 17
(6,039 Views)

I've used local variable in the structure that it was stuck and now it works! Thanks, guys. 

0 Kudos
Message 9 of 17
(6,037 Views)

Move the stop button control to inside the while loop.  This way the while loop will look and read the button control on each loop iteration (see image attached).  They way that you have it it will only read the button control once when the .vi starts the while loop section of the .vi

 

0 Kudos
Message 10 of 17
(6,019 Views)