LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping a program

I want to use a stop button to end a loop, and preferably have it sitting
dormant, until switched...
Is there anyway that I can do this, so that as soon as it is pressed, it
will be recognized and exit the loop?

Alternatively, how do I make it the last thing in the loop checked, before
the while condition is checked? (It forms a major part of the while
condition).

Thanks in advance for any help


--
Slade Squire
Programmer
Rectifier Technologies Pacific
0 Kudos
Message 1 of 4
(2,829 Views)
If i have understood you well, you want a vi that will stay asleep untill you hit a button and then execute some code and exit.

You can put a case structure inside the while loop, and wire the stop button to the case, from this case, put a boolean constant wired to the loop terminal control, and make it true when stop is false, and false when stop is true.

This way, if you don't hit the button, nothing will happen, and if you hit it, code inside the case will be executed and while loop stopped.

Hope this helps
0 Kudos
Message 2 of 4
(2,829 Views)
Sorry, I phrased it badly.
I have a while loop running the program, and inside the while loop, I have a
case structure, using a run button to start execution. Inside the case
structure I have another while loop, which goes until the stop button is
pressed.

My problem is, that the stop button's value is read at the start of the
while loop, instead of the end. I'm using more case structures inside the
while loop, some of these take twenty or thirty seconds (or more) to
execute. I would like to be able to break out of these case structures
immediatley, (if possible) or else read the stop button after they have
finished executing.

Otherwise, I end up doing another cycle of the while loop before it stops,
which is not what I want.


--
Slade Squire
Programmer

Rectifier Technologies Pacific
0411 201 209

"Gorka Larrea" wrote in message
news:506500000005000000C3330000-993342863000@exchange.ni.com...
> If i have understood you well, you want a vi that will stay asleep
> untill you hit a button and then execute some code and exit.
>
> You can put a case structure inside the while loop, and wire the stop
> button to the case, from this case, put a boolean constant wired to
> the loop terminal control, and make it true when stop is false, and
> false when stop is true.
>
> This way, if you don't hit the button, nothing will happen, and if you
> hit it, code inside the case will be executed and while loop stopped.
>
> Hope this helps
0 Kudos
Message 3 of 4
(2,829 Views)
I think your best option is to use a case structure, a while loop with a shift register wired to a case structure, depending on your action, the shift register gets one value or another, that will decide which state execute next, avoiding your last loop to be repeated, and having more control over your app.
Hope this helps
0 Kudos
Message 4 of 4
(2,829 Views)