Showing results for 
Search instead for 
Did you mean: 

How can I stop and restart a .vi with a single front panel button?

Go to solution

Hey guys, a newbie here.


I have a .vi with a stacked sequence. The first few frames are hardware initialization and settings (LIN master node) and the data the hardware should transmit (frame response table). In the next frame there's a loop in which the hardware sends and recieves data (LIN monitor). If I want to change the initialization, settings or data values, I have to stop the .vi and restart it. I was wondering if there is a simple way of doing this with a single click (a button on the front panel).


An alternative would be to put another loop outiside the whole stacked sequence and then run it a single time with a push of a button (the inner loop should let the outer one restart), is that possible?


I hope I made any sense. Thanks for any suggestions.


0 Kudos
Message 1 of 11


 Can you post your vi?

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 2 of 11

It has about 100 custom subVIs, I don't think posting it would be of much use. Basically, the vi goes like this:


stacked sequence: do A -> do B -> do loop until "stop".


I'd like a way to start again from the beginning of the sequence ("do A") without stopping and restarting the VI (or doing this with a single button).

0 Kudos
Message 3 of 11
Sounds like you need a State Machine.  It's pretty easy to implement.
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 11
Do what Jim suggested and try to work with a State Machine; you can find a template at File -> New.. and in Design Patterns, you should be able to find the Standard State Machine template. Try to work with it and post your test VI if you get stuck somewhere.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 5 of 11

Tomaz79 wrote:


I'd like a way to start again from the beginning of the sequence ....

Take the great advice given. Think of a State Machine as LabVIEW's only way to do a GoTo statement, or even a GoSub statement with a Return.


Message 6 of 11
Accepted by topic author Tomaz79
Ideally, redoing the code with a state machine would be the best way to go, if only so that you can add this powerful tool to your toolbox. That being said, wrapping your existing code in a while loop, with its own stop button to stop the program, will work if executing the entire sequence is ok. Where you might run into problems with this is if there is a step in the sequence that shouldn't be executed again, then it would require wrapping that sequence frame's code in a case statement that executes only the first time through. If you have the time, learning how to use a state machine would be a real benefit, really taking your LabVIEW knowledge to the next step, if you pardon the pun.
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5

LabVIEW Champion

Message 7 of 11

Thanks for the suggestions, I'll try it and report back.



0 Kudos
Message 8 of 11

It turned out that wrapping everything in a while loop was all I needed for this case. I also learned how to use a state machine so thanks to all of you guys for the help!



0 Kudos
Message 9 of 11

hi guys this my vi file how should i stop and restart the program 

Download All
0 Kudos
Message 10 of 11