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: 

Boolean switch until released using an event structure

Solved!
Go to solution

I am using a boolean control with the mechanical action set to switch until released, I want the button to go back to the original state.

 

I am using it in an event structure set to trigger on a value change. The action of pushing the button is generating two events, one of the on state and one for when it returns to the off state.

 

How do I control this so that only one event is triggered and the second event that is queued up is ignored, I would like the button to go back to the original state and not execute code twice.

 

Thanks

 

Jim

0 Kudos
Message 1 of 6
(5,008 Views)

You can use the value from OldVal or NewVal in the event case and a conditional structure to mask it off.  Do you really need switch until released functionality?  That's intended to give you two events, as the click and release are different actions.  Switch when released might be a better fit for you if you only want one event.


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 2 of 6
(5,005 Views)

Use Latch When Released.

Message 3 of 6
(5,001 Views)

Switch when released does not switch the button back after it have been read. 

I prefer Latch when released - they switch back automatically when terminal is read AND (not but) they do not allow local variables.

0 Kudos
Message 4 of 6
(4,998 Views)
Solution
Accepted by topic author Jim_Glanz

Right, I should have said latch.  Be sure to put the button control somewhere it'll be read to reset the latch.  It doesn't need to be wired to anything, just read.  Sitting inside the event case is fine if you're not using it anywhere else.


--Using LV8.2, 8.6, 2009, 2012--
Message 5 of 6
(4,989 Views)

That solved it for me, thanks for the speedy response

 

Jim

Message 6 of 6
(4,984 Views)