LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timed boolean switches with case structure

Solved!
Go to solution

I am trying to implement a control for a switch that when toggled, turns a "key signal" on for 2 seconds, and then turns off, as soon as the key signal has been on for two seconds the VI should send say that the switch has been enabled.  I cannot get this to work how I want. I think there might be a way to do this with a state machine, but I do not know much about them.

0 Kudos
Message 1 of 4
(3,149 Views)
Solution
Accepted by topic author aem64

Hi,

 

I changed your Boolean to latch so it would snap back to the off position.  This stops the VI from entering the on case over and over till turned off.  Then I added two shift registers to hold the indicator values. 

 

I guess my bias is that you would want to continue to run in the While loop, going back to the "OFF" case.   If you expand this to a state machine, you might have multiple cases, the shift registers would provide the "flag" status access to the other cases.

 

This is only one method, it matches you request.  How would you fit this into a larger design?

 

2seconds.png

 

Copy snippet to desktop, drag onto VI.

 

 

Did you want the keyturn to turn on for the two seconds, and then have the enabled LED turn on?   If so you have to move the location of the indicator into the time target while loop, this will allow it to turn on while the time target loop is timing two seconds.

-------
Mark Ramsdale
-------
0 Kudos
Message 2 of 4
(3,143 Views)

Mark's solution is much simpler.

 

I have attached statemachine  for the same problem

0 Kudos
Message 3 of 4
(3,140 Views)

Hi Fabtro

 

Nice straightforward solution using an event structure rather than polling,  and is a state machine.

 

Mark

-------
Mark Ramsdale
-------
0 Kudos
Message 4 of 4
(3,135 Views)