01-24-2022 01:14 PM - edited 01-24-2022 01:49 PM
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
01-24-2022 01:34 PM
01-24-2022 01:35 PM - edited 01-24-2022 01:41 PM
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!
01-24-2022 01:43 PM - edited 01-24-2022 01:49 PM
I know that I programmed it, thanks for reminding.
i'm searching for a solution and not my missing knowledge.
Thanks, helped a lot!
01-24-2022 01:49 PM
01-24-2022 01:51 PM
Greagory thanks, but how I start reading only when the Start button pressed?
01-24-2022 02:47 PM
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.
01-25-2022 01:45 AM
@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.
01-25-2022 07:50 AM - edited 01-25-2022 07:51 AM
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.
01-26-2022 01:02 AM - edited 01-26-2022 01:05 AM
@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.