LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware push button acting as mechanical switch (latch when released)

Solved!
Go to solution

Hello,

 

I have a simple question. How can I have a hardware push button (momentary switch fed into DAQ board as a digital input) exhibit the same characteristics as a boolean with its mechanical action set to Latch when released?

 

Is it possible to do that?

 

Thanks,

r15

 

 

0 Kudos
Message 1 of 4
(3,779 Views)

You can buy a spring-loaded mechanical switch, but you need to hold it down long enough for your code to read that input at least once.  You'll need to add some logic to your code that so it only reads one "on" value, then waits for the switch to go "off" before reading "on" again.  EDIT: more specifically, if you want "latch when released behavior," you should check for the transition from "on" to "off" which is the point at which the switch is released.  So, save the previous state in a shift register, and whenever the shift register is true and the current value is false, that's when the button was released.

0 Kudos
Message 2 of 4
(3,775 Views)

Is the code implemented easier when a "latch when pressed" behavior is required?

 

The problem I am facing is that when I press the hardware button, the indicator "element" is incrementing as long as the button is pressed. I need it to only increment one time until I release the button and press it again.

Hence, everytime I press the button (no matter how long I keep it pressed), I want the indicator to increment only once to count the number of times the button is pressed.

 

I attached the VI below to make things clearer.

0 Kudos
Message 3 of 4
(3,769 Views)
Solution
Accepted by topic author r15

@r15 wrote:

Is the code implemented easier when a "latch when pressed" behavior is required?


No, it's identical code, just a matter of whether you're looking for the transition from false to true (latch when pressed), or from true to false (latch when released).  The "Boolean Crossing PtByPt" VI (Signal Processing -> Point by Point -> Other Functions PtByPt) will detect either one and is probably the easiest solution, you can just wire the digital input to it and select the appropriate transition.

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