LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

hold button for a few seconds to do "turn on", how can I do it in event structure

Solved!
Go to solution

Hi, LabVIEW friends

 

I want to let user click and hold a  button for a few seconds in order to turn on an equipment. Using shift register and history element I can make it work. I am wondering how to implement it with Event structur and case. Which event I should choose? mouse up?

I attached the test code as well. 

 

thank you.

 

hold_bottun.png


CQ
0 Kudos
Message 1 of 5
(3,577 Views)
Solution
Accepted by topic author CQ_Li

I'm sure there are many possible solutions, but here's one way to do it with an event structure. The button's mechanical action is "Switch until released." Pushing the button turns off the output, and sets the event structure timeout to some amount of time. The timeout event switches the output to true. Any other event sets the timeout value back to -1. Unfortunately it looks like the snippet tool messed up the image, so the VI is attached as well.

Hold for ON.png

Message 2 of 5
(3,566 Views)

Thank you very much, nathand. it is a very good solution. 

 

I have another question then. if I already have timeout event handling some other process, how can I do the same "hold" thing? or can I have two "timeout" event (maybe not)?

 

best regards

 

CQ


CQ
0 Kudos
Message 3 of 5
(3,502 Views)

CQ_Li wrote:

I have another question then. if I already have timeout event handling some other process, how can I do the same "hold" thing? or can I have two "timeout" event (maybe not)?


 

It depends a little bit what is happening in the other timeout and how often it executes.

 

In the simples sceanrio, you can place a case structure in the timeout case and wire the current switch until released button terminal to the case selector. Place the current timeout code in the TRUE case and the other timeout stuff in the false case.

0 Kudos
Message 4 of 5
(3,489 Views)

CQ_Li wrote: 

I have another question then. if I already have timeout event handling some other process, how can I do the same "hold" thing? or can I have two "timeout" event (maybe not)?


Here's a way you can simulate an additional timeout using a notifier and a user event. This has the same behavior as the previous version.

HoldForOn.png

Message 5 of 5
(3,443 Views)