05-03-2016 08:48 AM
Hi. How to stop vi using stop button in front panel? I tried using stop button inside while loop but when vi is running and if i press button on front panel the vi will not stop. I have to stop manually. My vi have two event structures. I have even tried quit buton. The button will stay pressed but vi won't stopDoes the program wait till both get executed for the stop button to work.
I have attatched different variation of vi.
Thank you.
Solved! Go to Solution.
05-03-2016 09:06 AM
Hi madara,
your stop button doesn't work, because your Event Structure doesn't have a timeout case and it executes only when the "Insert Step: Value Change" event happens (so it doesn't check whether you pressed the button or not).
So you can either configure a timeout case, or configure another event triggered by the value change the stop button.
It is also generally not a good idea to have two Event Structures in one loop, because they will block each other.
05-03-2016 09:12 AM
You're emisunderstanding the EVENT structure.
Your code says to:
A... Wait on an event. If it's the INSERT STEP button, do some stuff, else do nothing.
B... Wait on another event. If it's the OK button, do some stuff, else do nothing.
C... Check the STOP button. if it's ON, stop, else go to A
Except it won't necessarily do them in that order.
You need to have ONE event structure inside the WHILE loop, and have 3 cases:
INSERT STEP value change
OK value change
STOP value change.
Examples should help you out.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-03-2016 09:16 AM
You only need one event structure in your program. Add an event in it for pressing the quit button and stop your while loop with that even.
Remove the sequence structure. It is not needed.
Move your VISA init function outside of the while loop because you only need to do that once.
Move the VISA close outside the while loop. You only need to do that once.
Don't EVER use the Exit Labview function.
05-03-2016 09:35 AM
Don't EVER use the Exit Labview function.
I dislike dogmatic statements. To be clear, the EXIT LABVIEW function does have a clear and valid use. This isn't it, but it is useful.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-03-2016 09:37 AM
@CoastalMaineBird wrote:Don't EVER use the Exit Labview function.
I dislike dogmatic statements. To be clear, the EXIT LABVIEW function does have a clear and valid use. This isn't it, but it is useful.
Opinions are like noses......
05-03-2016 10:30 AM
@CoastalMaineBird wrote:Don't EVER use the Exit Labview function.
I dislike dogmatic statements. To be clear, the EXIT LABVIEW function does have a clear and valid use. This isn't it, but it is useful.
On the other hand, the red button to eject the warp core is also useful, and you would probably use it just slightly less than the Stop Sign. 😉