LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to immediately (or nearly so)stop my vi, using a stop botton on the front panel.

If there is I don't know how I would do it. Any way that I can think of to stop the vi from running still allows the for loops to execute. I suspect that this can't be avoided without rewriting my vi to avoid for loops. I was also wondering, is there a way to run my vi and have it stop, on its own, when it is finished. Presently it does nothing when it is finished, but the run button stays pressed until the vi times out. Can I avoid this?
Download All
0 Kudos
Message 1 of 4
(2,788 Views)
you can use a event-handler in one of the loops, connecting a timeout value of 0 will not slow down you vi.
add a event handler for "value changed" for your stop-button and within the handler you call the "vi cancel" method, to cancel the pending operation.

sure it is not a clean way...but i think the only one that works with your vi.

you should take attention that the event handler take place where you can safely cancel your vi.
0 Kudos
Message 2 of 4
(2,788 Views)
You can't stop a FOR loop with a button. It executes until the FOR count is done. Change the FOR loops to WHILE loops. Here you can use a button to stop the loop. Do this for ALL FOR loops.
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 4
(2,788 Views)
What you're wanting is something similar to the stop button on the toolbar. It is not good programming practice to perform such a shutdown of your program. While you could wire the button to the stop function in a parallel loop I would not recommend this. You should always plan for a proper shutdown of the program.

Your program is very hard to read, but it appears that the sequence structure on the left is serving no purpose. There is no reason to believe that the code in the for loops will run at the same rate as that in the while loop unless you are timing the loops. A Local Variable does not ensure synchronization. If that's what you need then you should use one of the synchronization functions. Even at that the sequence structure is not needed. It
is also hard to understand the relationship between your two loops. The for loop will execute and then end whereas the while loop will continue running until you press the stop button. No data will be sent to the subvi after the initial run of the for loops. If you'll clean up your vi perhaps we can be of more assistance.
0 Kudos
Message 4 of 4
(2,788 Views)