08-24-2010 10:44 AM
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.
Solved! Go to Solution.
08-24-2010 10:55 AM
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.
08-24-2010 01:39 PM
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.
08-24-2010 02:45 PM
08-25-2010 03:06 PM - edited 08-25-2010 03:07 PM
I ended up going with code that looked similar to the code tbob posted. Thanks!
08-25-2010 03:08 PM
altenbach,
Thanks very much! Your code is not the perfect solution to my current needs, but I saved it for future reference.
08-26-2010 10:05 AM
How about using the Mouse Down event on your Push Button in the event structure?
08-26-2010 10:54 AM
@JHourigan wrote:
How about using the Mouse Down event on your Push Button in the event structure?
Why?
08-26-2010 11:56 AM
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.
08-26-2010 12:36 PM
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!