LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot stop VI

Hey, cannot get why stop button is not working.

Please advice

 

update:

 

Im trying to achieve  Click to start reading from usb device with while loop (for reading) and having Stop button to stop the VI.

 

Thanks

 

page 1.PNGpage 2.PNGpage 3.PNG

0 Kudos
Message 1 of 24
(1,793 Views)
The local variable is read when the loop starts, the event triggers when you press the button. Wire the value from the button out to the stop terminal.
0 Kudos
Message 2 of 24
(1,783 Views)

Hi alexela,

 


@alexela wrote:

why stop button is not working.


Because YOU programmed it that way!

 

When the "OK" event is executed your event structure blocks other UI actions (by default), but the loop inside the event waits for another UI action! (This is called "deadlock"…)

Ok, you found that event case option. But you are using the wrong switching modes for your buttons!

The behaviour of your VI should not depend on how long you press a button. Really! (Well, only if that really is required behaviour…)

The VI stops when you press the Stop button - sometimes only on 2nd button press…

 

Did you read the LabVIEW help on the event structure? It mentions to execute event cases as fast as possible to not block any other events! And your loop inside the event clearly violates this rule…

 

The other big problem: don't use "default if unwired" tunnels with any kind of reference wire!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 24
(1,782 Views)

I know that I programmed it, thanks for reminding.

i'm searching for a solution and not my missing knowledge.

Thanks, helped a lot! 

0 Kudos
Message 4 of 24
(1,775 Views)
Move your "serial initialization" outside the loop, to the left. Then run your "Read Serial" inside the timeout event (set timeout to something reasonable). This way you will not need a loop within a loop.
0 Kudos
Message 5 of 24
(1,763 Views)

Greagory thanks, but how I start reading only when the Start button pressed?

 

0 Kudos
Message 6 of 24
(1,761 Views)

You can set the timeout in a shift register, so it starts at "-1", but when you press start it changes to "100" for example.

Capture.PNG

0 Kudos
Message 7 of 24
(1,745 Views)

@alexela  a écrit :

Greagory thanks, but how I start reading only when the Start button pressed?

 


You can switch to a producer/consumer architecture.

For each event you will add an action into a queue to do it in the consumer loop.

Then when needed you can add something into the queue even from the consumer loop to make a continuous reading.

0 Kudos
Message 8 of 24
(1,701 Views)

See if the attached does what you want. It's basically just a combination of what others have recommended.

 

Notice that there are no local variables, and I set the OK and Stop buttons to latch when pressed. 

 

For a simple program like this your current architecture is fine. For larger applications you may want to consider a more advanced architecture.

0 Kudos
Message 9 of 24
(1,672 Views)

@johntrich1971 wrote:

See if the attached does what you want. It's basically just a combination of what others have recommended.

 

Notice that there are no local variables, and I set the OK and Stop buttons to latch when pressed. 

 

For a simple program like this your current architecture is fine. For larger applications you may want to consider a more advanced architecture.


Is there a reason for "latch when pressed"?  Isn't is normally "latch when released"?  The reason being "latch when released" is how buttons normally work - i.e., no action until the button is released.  This subtlety can save you if you click on the button by accident - just hold the click, move the cursor off the button.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 24
(1,627 Views)