From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start/Stop button with reset

Hello everyone I am trying to create a button that will not only start and stop my VI but also reset it in between each state. So that I can use the button to start my program and stop/reset it. I have attached my vi below.

 

Thank you

0 Kudos
Message 1 of 6
(3,408 Views)

Easiest way would be to drop a "Default values → Reinitialize all to default" invoke node on your diagram.

You'll want to make sure it runs before everything else on your block diagram except possibly your "sequencing of states" control.  Probably want to put a sequence structure around everything and wire the error output of this into it from the outside.

Reinitialize all to default.png

0 Kudos
Message 2 of 6
(3,396 Views)

(Please don't continually start new thread for the same discussion. You can append to your original thread so readers have better context.)

 

You cannot efficiently create a button to "start" a VI (well, yes you can, but it is silly!), that's why you need a state machine.

You can use many mechanisms to top stop all loops and reset the value once all loops have stopped. What have you tried?

 

Your upper code will stop after all loops have executed, but the lower loops will run indefinitely without user interaction. One stop button should be enough for everything.

Message 3 of 6
(3,394 Views)

so I am able to use a stop to stop everything however even with the renit to default It does not reset all of the booleans and therefore the daq assistant is still receiving a signal and therefore my device remains on even after the vi has been stopped. any suggestions on how I can stop not only the program but also the daqs

0 Kudos
Message 4 of 6
(3,367 Views)

One thing you desperately need to do is eliminate as many local variables as you can.  

 

Look at the top While loop.  You have one bit where you make the binary array "x=y?", then write that to an indicator.  Then below that, you get "x=y?" from a local variable, and that creates a result that you wire into "Pump".  Then below that, you read "Pump" and write it to "Numeric in binary 4".  Then above that you read "Numeric in binary 4" and write that to some other stuff that writes to the DAQ.  

 

That's 4 separate parts of code that all should be flowing right in to each other, but instead they run in a random order which can really mess things up.

 

You need to only use local variables as an absolute last resort.  And you've got 4 loops running in parallel, so your timing is all over the place.

 

My advice: Find a tutorial online that explains how LabVIEW uses the "Dataflow" paradigm to work, as you clearly don't quire get that part of it yet.  Additionally, look up how a state machine works, like Altenbach suggested.

Message 5 of 6
(3,358 Views)

thank you

0 Kudos
Message 6 of 6
(3,299 Views)