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.


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 11 of 17
(171 Views)

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

 

Events.png

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 12 of 17
(163 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
(151 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
0 Kudos
Message 14 of 17
(140 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!


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 15 of 17
(134 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
(108 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.

 


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 17 of 17
(106 Views)