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: 

Initialize a numeric variable and change it based on push button commands

Solved!
Go to solution

@SegFault1119 wrote:

I added 200 as you did in your example VI and it's working now.

 


The right way would be to add an event for the stop button and place the terminal inside it (or add a stop event to an existing event, like I did above). It is incorrect to add a timeout case to poll the stop button if that is the only purpose for the timeout case.

 

Also note that latch action booleans should have their terminal inside their respective event. This way they correctly reset when the event happens.

0 Kudos
Message 11 of 17
(820 Views)

Here's one possibility to simplify your code. One single event case is sufficient, making the code much more readable.

 

Events.png

 

 

0 Kudos
Message 12 of 17
(812 Views)

 

 "It is incorrect to add a timeout case to poll the stop button if that is the only purpose for the timeout case."

When placing an event structure inside a while-loop, does the loop iterate/increment if no event occurs? 

Your simplified program is easier to follow for me. Though my program will have more than 2 buttons but I think I know how to modify it. 

 


 

0 Kudos
Message 13 of 17
(800 Views)

SegFault1119 wrote:

When placing an event structure inside a while-loop, does the loop iterate/increment if no event occurs?


Data flow dictates that the loop cannot iterate until everything inside has completed.  So if no event is being generated, the event structure will sit there idle waiting.  So the loop will not iterate until an event is generated and handled by the event structure.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 17
(789 Views)

@SegFault1119 wrote:

Though my program will have more than 2 buttons but I think I know how to modify it. 


Again, make sure not to over-complicate things. Best would be a radio-button control, but if you want to use individual latch action buttons as you did in your last code, easiest would be to build the buttons into an array and use "search array" to see which one is true. There are many ways to do all that, make sure it is scalable!

0 Kudos
Message 15 of 17
(783 Views)

Thanks for the tips. I think radio button function works for my program because I want all the buttons disabled when one button is pressed.

0 Kudos
Message 16 of 17
(757 Views)

"disabled" means that the other buttons can no longer be operated. In a radiobutton control, only one can be true, but you can switch at any time. If you want to disable some elements, you need property nodes.

 

Note that a radiobutton container can contain any number and style of Boolean controls.

 

0 Kudos
Message 17 of 17
(755 Views)