01-29-2014 04:11 PM
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
Solved! Go to Solution.
01-29-2014 06:08 PM
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.
01-29-2014 06:22 PM
This will do what you want:
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.
01-30-2014 02:41 PM
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.
01-30-2014 03:05 PM
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:
You need to decide which button sets which bit. I haven't checked the logic of your latch algorithm yet.
01-30-2014 03:30 PM
Thank you so much, It works!