Showing results for 
Search instead for 
Did you mean: 

Create a Start Button for the VI and stop automatically


Hi Everyone


I have gone through the forum for the appropriate solution to my case of creating a "Start" button instead of clicking on "Run" but i could not find one,


My final aim is to build an EXE file so that user would not be using the labview "Run" to execute the file. Instead it is  using the "Start" button to execute the EXE file.


My VI is run through a sequence and my Ideal final code is as the following step




1) Press the  "Start" button that i created

2) "Start" button lit up

3) My code will run ===> My DAQ assistant will record 15000 data points then it stop. Proceed to some calculation and it will auto save all the data. Code End.

4)"Start" button dim down (To indicate this measurement has stopped and everything is completed)


User will press the "Start" button to restart the whole sequence from Step 1 to 4.


My problem encounters in Step 1,2 and 4


Please help me on this. Thank you




0 Kudos
Message 1 of 7



First, your executable program will run when you launch it but it may not do anything except wait for the "Start" button to be pushed.


From your description it sounds like you should be using a state machine architecture for your program.  A sequence structure is almost always a poor choice for programs of this type.  There are examples in LabVIEW and many threads in the Forum about state machines.  The states might be something like this:


Idle state - wait for Start

Start - illuminate Start button

Acquire -  get data points

Calculate - analyze data

Save - save the data or analysis results

End session - dim Start button and set everything to standby

Error - handle or report any errors 

Shut down - Release DAQ tasks, close files, stop program execution 


When the program runs it goes to the Idle state and  stays there until the Start button is pushed or until the user shuts down the program.  If Start is pressed it goes through the Start, Acquire, Calculate, Save, and End session states, then back to Idle.



Message 2 of 7

Although I agree with Lynn about the state machine, and I don't know what your vi looks like, it is possible to create a start button without having to re-write your entire code.  Before I tell you how, I strongly recommend that you use a state machine as Lynn suggested.  But since you may be pressed for time and can't afford to re-write your code, I'll give you a band aid:


Just put one large case structure around your whole block diagram.  The True case should contain all of the code, the False case should be empty.  Then put a while loop around the case structure.  Create a start button and set to latch when released (or pressed).  Wire the start button to the case question mark.  Put in a 100mS delay outside the case structure but inside the while loop.  Put a True constant inside the True case and wire it to the right side of the case.  Right click on the terminal and select Use Default if Unwired.  Then wire that terminal to the while loop stop sign.


When your run your exe, the while loop will run and the start button will be false, and the false case will execute.  So the loop and false case will run again and again until the start button is true.  Then the code inside the True case will execute.  When done, the True constant from the True case will stop the loop, ending the program.


Again, if you have time, re-write into a state machine.  First state reads the start button.   If start is not pressed, make the next state the same as the current one.  If start is true, make the next state the one that starts your program.  This is the proper way to code and is accepted by Labview experts worldwide.


- tbob

Inventor of the WORM Global
Message 3 of 7
Don't forget to hide run button by go to File>>VI Properties>>Windows Appearance, and enable VI to run when opened from File>>VI Properties>>Execution.
0 Kudos
Message 4 of 7

Thank you Everyone



I shall improve my knowledge on State Machine and be implemented in all my future projects. Currently, i am using a XControl to fulfil my task. Hope it turns out well 😄


0 Kudos
Message 5 of 7

Hey pengxin,


State machine is one of the design pattern but not universal.. It is mainly used for decision making algorithms having their state defined in state diagram.. but there are other architecture also so have look on them and use best suited one, not only state machine in all future projects Smiley Happy..


some of regular used architectures other then state machine are :


1) Master/Slave : used mainly to decouple the asynchronous process ..

2) Producer/Consumer : it is also used for decouple plus parallel processing..


there are more like Queued msg handler, demon etc etc.. u can read about all on NI website.. I just put few i use frequently..


Hope it helps





0 Kudos
Message 6 of 7

MR tbob....

 U r suggestion perfectly working....heartly thank u......


0 Kudos
Message 7 of 7