03-16-2016 04:34 AM
Hello all,
I'm quite new to LabVIEW and am running into some trouble trying to write a VI for controlling the position of a 12V DC motor for a linear actuator. I am trying to write a program in which the user inputs a desired stroke length of an actuator, and depending on whether the desired position is greater or less than the current position (read from an analog input from a potentiometer), the actuator will retract or extend until a stop condition is met (desired position input = current position output).
I was initially unsure if I could write a program that functions this way without deriving a mathematical controller(?), but I thought I would try it first. So far, I have written a VI that can read a voltage from the potentiometer and converts this to stroke length. I also made a separate VI that was able to turn the motor on and off with a Boolean switch. I am using the DAQ USB 6008 and a ULN2003a transistor array to power SPDT relays to switch the motor on and off in either direction.
However, when trying to combine these VIs to follow the logic mentioned above (if desired position > current position, output digital signal to one relay or if desired position < current position, output digital signal to other relay, until desired position = current position), I run into an error (# channels in the data does not match the # channels in the task) I think because the analog input from the potentiometer is reading samples continuously whereas the digital output expects an input start control of either 1 true or 1 false... Continuous samples are needed here though in order for the stop condition to be satisfied at the right time. This VI is attached.
I also tried to put the DAQ assistant in a case structure where the true included the DAQ assistant and nothing in the false case, but the output channel produced a signal for either case.
Any help is greatly appreciated!
03-16-2016 04:41 AM
Hi caro,
don't use ExpressVIs and their DDT wires when you don't know what you are working with…
LabVIEW comes with a lot of example VIs explaining how to use simple DAQmx functions. Try them!
For a start you could convert the DDT wire coming out of first DAQAssistent into an 1D array to learn how to handle data (correctly)…