LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[begginer] start button executing sub vi only once

Solved!
Go to solution

Hi, I'm very confused by, what it looks, very simple task.

I have a piece of code and I need to plug it to "start" button which will execute it once when button is pressed, execute once again if I press the button again and so on.

I tried with "while" loop and true/false button connected to it but, as you know, code inside the loop executes itself continously as long it's true which is incorrect, it doesn't stop when it should.

I woul'd like it like that: Press start->code in block executes once and thats it, no more unsless I press the button again..

 

Please advice.

ps: I attached piece of vi I need to connect with button. It actually works as inteded but I fail to make it executable with button.

 

 

0 Kudos
Message 1 of 8
(7,580 Views)

You should surround your code with an event case structure in a loop, with the case being value change of your front panel control.

Message 2 of 8
(7,560 Views)
Solution
Accepted by topic author JohnnyB.

An event loop is the way to go but since you're a beginner; this is the basic, simple way:

run once.JPG

 

You need to right-click the button and change the mechanical action to latch when pressed (or released) to run just once.  If you set it to switch it will toggle.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 3 of 8
(7,553 Views)

Very simple.  See the attached code. I've added a loop, case structure, run button, and stop button.

 

Edit:  My code is exactly what Niquist published.  Remarkable.

 

- tbob

Inventor of the WORM Global
Message 4 of 8
(7,551 Views)

 


@tbob wrote:

Very simple.  See the attached code. I've added a loop, case structure, run button, and stop button.

 

Edit:  My code is exactly what Niquist published.  Remarkable.

 


Great minds think alike, tbob!  Smiley Very Happy

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 5 of 8
(7,539 Views)
0 Kudos
Message 6 of 8
(7,505 Views)

Please, Can you post this VI in LabVIEW 2009??

Thanks

0 Kudos
Message 7 of 8
(7,067 Views)

Here you go, 2009 version. note that one file is missing.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 8 of 8
(7,065 Views)