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.
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.
11-17-2016 11:16 AM
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?
Solved! Go to Solution.
11-17-2016 11:25 AM - edited 11-17-2016 11:25 AM
Because you have the stop button OUTSIDE your loop.
11-17-2016 11:25 AM - edited 11-17-2016 11:26 AM
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).
11-17-2016 11:27 AM
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.
11-17-2016 11:28 AM - edited 11-17-2016 11:31 AM
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.
11-17-2016 11:30 AM
It is listed as a common mistake. Not how to do it right. Read the text!
11-17-2016 11:33 AM
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.
11-17-2016 11:38 AM
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
11-17-2016 11:39 AM
I've used local variable in the structure that it was stuck and now it works! Thanks, guys.
11-17-2016 11:51 AM
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