LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to I trigger an event based on the status of a pushbutton?

Solved!
Go to solution

I am trying to trigger an event based on the ON/OFF status of a pushbutton.  When I click the pushbutton to the ON position, I want the event structure in a loop to trigger on each iteration until the pushbutton goes back to the OFF position, either manually or programatically.  Is there an easy way to accomplish this?

 

Many thanks.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 13
(4,160 Views)

Add the timeout event to your button event, keep the timeout in a shift register, and set the timeout to a short value if the boolean is true and to -1 (infinite) if the button is false.

0 Kudos
Message 2 of 13
(4,154 Views)
Solution
Accepted by topic author diarmaede

Is an event structure absolutely necessary?  This is so simple with just a case structure, as in figure 1.  If you have to use an event structure, you could put the case structure with the pushbutton inside the Timeout event, as shown in Figure 2.

 

22270iC1C355BA71FC4E1B

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 13
(4,130 Views)

Here's what I had in mind... (LV 8.5).

 

 

Message 4 of 13
(4,117 Views)

I ended up going with code that looked similar to the code tbob posted.  Thanks!

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 5 of 13
(4,086 Views)

altenbach,

 

Thanks very much!  Your code is not the perfect solution to my current needs, but I saved it for future reference.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 6 of 13
(4,084 Views)

How about using the Mouse Down event on your Push Button in the event structure?  

0 Kudos
Message 7 of 13
(4,055 Views)

 


@JHourigan wrote:

How about using the Mouse Down event on your Push Button in the event structure?  


Why?

 

0 Kudos
Message 8 of 13
(4,047 Views)

If I want to simply detect a button push event. I set the mechanical action of the boolean button to switch-until-released. Then I use the mouse down event structure on that button to detect the event.  It avoids having to include a case structure logic to address the state of the boolean in an Value Change event structure. The button immediately returns to the false condition after release.

0 Kudos
Message 9 of 13
(4,033 Views)

 

Well, lets read the original question:

@diarmaede wrote:

I am trying to trigger an event based on the ON/OFF status of a pushbutton.  When I click the pushbutton to the ON position, I want the event structure in a loop to trigger on each iteration until the pushbutton goes back to the OFF position, either manually or programatically.


 

I cannot see anything about "switch until released", only "click to ON" and "OFF manually or programmatically". That seems to be a plain switch action.

@JHourigan wrote:
If I want to simply detect a button push event. I set the mechanical action of the boolean button to switch-until-released. Then I use the mouse down event structure on that button to detect the event.  It avoids having to include a case structure logic to address the state of the boolean in an Value Change event structure. The button immediately returns to the false condition after release.
So far you are not dealing with the OFF handling at all, which seems to be a requirement. There must be more to it that you mention to get this working as intended. The value of the boolean needs to be constantly monitored anyway, so it might be difficult to do things without a case structure. I am still confused about the logic of it all ....
You should really include a small working example VI so we can see what you are talking about. 😉 Thanks!

 

 

0 Kudos
Message 10 of 13
(4,015 Views)