LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to create a latching push button using digital inputs

Solved!
Go to solution

Hi everyone,

I'm writing a program to control a motor with 3 push buttons, Up, Down and Stop. I want the Up button to latch when pushed and delatch when Stop or Down are pushed. I've tried the Resettable Latch.vi example program from this website but no luck. It seems like the output  from the AND gate is indeterminate. I've attached my program, Any help would be great! Thanks

 

 

0 Kudos
Message 1 of 6
(4,407 Views)

The big problem I see is that you are using arrays instead of single booleans.  Your DAQ assistant is going to output an array but you only need the element that corresponds to the particular digital line you are interested in.  Assuming all the buttons are connected to the same DAQ module you should be able to scan all of them at once and index just the elements you want.  Also, when writing to the motor you're inputting an array and you'll need to assemble it so the correct elements are set to TRUE and FALSE.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
Message 2 of 6
(4,378 Views)

This will do what you want:

eg.png

 

This will work as long as the Action setting on the "Up" button is set to "Switch When Pressed". Ideally one would use an Event Structure to handle each button bit I wanted to keep it super simplified and show you how using a while loop can manage these button states. Do not use the feedback nodes. 

Message 3 of 6
(4,373 Views)

Thank you but I'm sorry I don't understand. This is my problem:

 

How do I get a momentary switch, connected to a digital input on myDAQ, to latch and drive a digital output?

 

I can't figure out how to convert the array element out of the DAQ assistant to a simple Boolean output.

0 Kudos
Message 4 of 6
(4,328 Views)
Solution
Accepted by topic author EngineeringGirl

Use Index Array to get the single boolean you want from the array.  If you don't wire an index it will give you element 0.  Using this you could have all the switches wired to different pins of the same register on your DAQ device.  Then you could read one byte and sort out which bit does what.  You also need to build the individuale booleans into an array before writing to the DAQ.  Here's a quick example:

 

Latch Example.png

 

You need to decide which button sets which bit.  I haven't checked the logic of your latch algorithm yet.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
Message 5 of 6
(4,318 Views)

Thank you so much, It works!

0 Kudos
Message 6 of 6
(4,304 Views)