LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure gets triggered twice

Solved!
Go to solution

I noticed that if the booliean button is set to "switch until released" or "latch until released", a button press will trigger the event twice. Of course for the "switch...", we have to set the value back to false to bounce back the button. The other four mechanical actions will trigger event only once. This is not the desired behavior for me, and I need to use the "switch until released". Any way I can work around this? Thanks.

0 Kudos
Message 1 of 26
(6,980 Views)

There is no way around triggering the event twice with that mechanical action but you can put a case structure inside the event with the button value wired into it.  If true, execute your code.  If FALSE, do nothing.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 26
(6,976 Views)

The attached file can show this kind of behavior. This is for sending command repeatedly while holding down a button, but I just realized a swift button press will send two commands.

0 Kudos
Message 3 of 26
(6,963 Views)

@guangdew1 wrote:

The attached file can show this kind of behavior. This is for sending command repeatedly while holding down a button, but I just realized a swift button press will send two commands.


No, it does not. A quick press&release will send no command, because you'll release before the 500ms timeout at which point the boolean is back to false and the timeout is back to infinite. The timeout event never executes.

 

(It would help to keep all discussions in one thread, and, as I said, don't ever attach modified code under the same name as one of my original attachments.)

0 Kudos
Message 4 of 26
(6,944 Views)

Part of the event data is going to be "New Value". You can use this data (found on the left side of the event structure) to determine what action to take.

0 Kudos
Message 5 of 26
(6,941 Views)

My previous attached example didn't send command twice. This attached file shows this kind of behavior, try press the dial buttons then press the back space "BS" button. Thanks.

0 Kudos
Message 6 of 26
(6,929 Views)

@guangdew1 wrote:

My previous attached example didn't send command twice. This attached file shows this kind of behavior, try press the dial buttons then press the back space "BS" button. Thanks.


And it does exactly as you programmed it.  If you are just switching the value back programmatically like that, you should just use a Latch When Released.


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 7 of 26
(6,923 Views)

I used "switch until released" because I want to have the capability to back space repeatedly while hold down the button, even though this function is not added to it yet. I want to the button to back space once when pressed briefly and keep on back space when hold down the button.

0 Kudos
Message 8 of 26
(6,916 Views)
Admittedly I am a bit late to the party, but I am confused. You start talking about "switch until released" which is a mechanical action for a Boolean input, and switch in midsentence to backspace actions, which is a key on the keyboard.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 26
(6,897 Views)

Mikeporter, this is all about buttons on the front panel. Back space is the "BS" button on the lower right corner. 

0 Kudos
Message 10 of 26
(6,891 Views)