From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

How to create a stop button for a case structure VI

Solved!
Go to solution

I tried putting a while loop around everything in my case structure but the stop button attached to the while loop didn't stop it. I tried adding it to the end of my flat sequence frames but that still didn't stop it. Every time the stop button is reset and so is the vi inside inside of the case structure. What am I doing wrong.

0 Kudos
Message 1 of 6
(3,251 Views)

The use of the Stop control in While Loops, and examples of Case Statements and the Principle of Data Flow are thoroughly covered in the first few chapters of all LabVIEW Tutorials, including those on the first page of this Forum.

 

Here's a question you might want to consider -- Why do you have a While loop?  Is it to allow you to have differing problems to answer?  Why do you have a choice between addition and multiplication?  When do you want to make this choice, at the beginning of the Program (and stick with it) or every problem?  Is this what you are doing with your code?

 

Bob Schor

 

 

0 Kudos
Message 2 of 6
(3,207 Views)

I guess I should of explained my project a bit. Using a case structure, a loop, and flat sequence frames I have to create two separate case structures, one that presents an addition problem of two numbers between 0-20 allows the user to answer the problem then displays the answer and shows you in some way if you got it correct. The VI is supposed to reset and present you with a new addition problem repeatedly until you hit a stop button. Another case structure needs to be made for multiplication problems with two numbers between 0-12 and have all the other features of the addition problem. I figured out how to do everything but create the stop button. I've re-read my books chapter on while loops but I still don't know what I'm doing wrong. It seems to me like the while loop doesn't include what is inside of the flat sequence frames.

0 Kudos
Message 3 of 6
(3,189 Views)
Solution
Accepted by topic author benm92

Turn on Highlight Execution and you will see that the Stop button terminals are read in parallel with everything else in the loop.  So you will have to go through another problem before it will stop.  The solution is to add another sequence frame at the end and put the reading of your stop terminal in there.  This way, the button's value won't be read until the end of the code in the loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(3,136 Views)

thankyou

0 Kudos
Message 5 of 6
(3,100 Views)

I can't open your code because I've not yet installed LabVIEW 2019, but this sounds like a good opportunity for a state machine. You should only need one loop for everything that you're doing.

0 Kudos
Message 6 of 6
(3,091 Views)