LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a "Start" button

Highlighted

Hi,

 

I have tried to add a "start" button to my VI without much success. I'm using LabView 8.5.1.

  

Currently, my VI is configured as follows:

I have a flat sequence structure with three "frames". The first two prompt the user for a filename and a location to save a log file to (these are in separate "frames") and configure the log file accordingly. The third frame is the bulk of the programme, running within a While loop.

 

I would ideally like a "Start" button that doubles up as a Stop button and stops the While loop from executing when pressed (and obviously, initiates the whole VI when it is a Start button!).

 

I have tried creating an "OK' button on the front panel, wiring this to the "enable" input of the "Enter Filename" block and also taking the wire outside the sequence structure, passing it through a "Not" block and re-entering into the sequence and while loop and terminating in the "stop if true" block within the while loop. However, whenever I run the VI within the developer environment by clicking the "Run" arrow, it instantly jumps to the "choose file path" dialogue, in the second frame, irrespective of the status of the Start/Stop button.

 

 

I hope this is clear enough. If you don't understand what i'm asking, please post and I'll attempt to clarify!

 

Thanks for the help 🙂 

0 Kudos
Message 1 of 16
(3,648 Views)
Highlighted

Seems to some basic stuff!!! but made complex by your explanation...

Just post the vi forum will solve it.

With regards,
JK
(Certified LabVIEW Developer)
Give Kudos for Good Answers, and Mark it a solution if your problem is solved.
0 Kudos
Message 2 of 16
(3,645 Views)
Highlighted

For that u need to change the architecture to State machine to contol ur states.

http://zone.ni.com/devzone/cda/tut/p/id/3024

ur flat sequence executes ur code sequentially u cant stop ur programme middle of the execution.

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
Message 3 of 16
(3,644 Views)
Highlighted

Try this:

 

The switch mechanical action is "Switch When Pressed" to give you the Start/Stop action.  The loop will stop when the stop button goes from True to False.  You'd put your code in the True case of the Case Structure and leave the False case empty and Bob will be your uncle.  You'll need to add something to make sure that the button is off when the VI starts (perhaps an Invoke Node at the beginning or end). 

 

Message Edited by jcarmody on 05-26-2009 05:55 AM
Jim
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

Download All
0 Kudos
Message 4 of 16
(3,630 Views)
Highlighted

Hi Thomas,

 

You might want to use an event structure (if you have at least the full LV version)

The following picture is not complete but shows the idea.

 

 

 

Regards.

Message Edited by Mathieu Steiner on 05-26-2009 01:59 PM

0 Kudos
Message 5 of 16
(3,602 Views)
Highlighted

Get rid of the Stacked Structure and use either a State Machine or an Event Structure (better) as proposed earlier.

You can use the same button for Start / Stop.  Simply wire boolean output to a shift register and use a NAND (AND + invert) to alternate the output.  

 

R

______________________________________________________________________
Message 6 of 16
(3,596 Views)
Highlighted

Ray.R wrote:

Get rid of the Stacked Structure


I think it is the Flat Seq Struct, Ray... Smiley Very Happy

- Partha ( CLD until Oct 2021 🙂 )
0 Kudos
Message 7 of 16
(3,587 Views)
Highlighted

Old age has affected my eyesight..  Oops..  Well being 1/2 blind doesn't help  😄  I should change my avatar (again)

 

Thanks Partha..  😉

 

______________________________________________________________________
0 Kudos
Message 8 of 16
(3,557 Views)
Highlighted

Hi,

 

I tried jcarmody's suggestion but unfortunately it didn't work. I've attached the basic layout of my VI (it's very complex so have left everything out of the inner loops). Half of the method works fine, as in the VI doesn't start until  I click the "Start" button, but when I click the button again, it doesn't stop the script. I'd guess the problem is something to do with how I've wired everything up to the inner While loop.

 

If anyone  could shed some light on this it'd be much appreciated 🙂

 

 

Thanks! 

0 Kudos
Message 9 of 16
(3,546 Views)
Highlighted
The boolean wire that stops the inner most while loop gets its value from outside the loop.  So it will run exactly 1 time if that wire is True,  or run forever if that wire is False, because the value on that wire never changes inside the loop.  You need to get the value of the stop button inside the while loop.  One way is using a local variable of the stop button, but I don't normally recommend that.
0 Kudos
Message 10 of 16
(3,541 Views)