06-09-2008 10:27 PM
Newbie question - Would someone help to provide an example VI or advice how to make a USB-6009 digital output blink/toggle (go high/low) a set number of times at some set nominal rate?
The front panel would have controls to setup for say 120 blinks at say 60 hertz and select USB-6009 Dev1/port0/line0:1 (or 2, 3, 4,..., 7). Then pushing the 'run' button would cause the chosen output to toggle between high and low states (at aproximately 50% on then 50% off) for 120 times at roughly 60 times per second, taking about two seconds to run (software loop timed).
This should be easy, but not yet for me... Thanks!
06-10-2008 03:35 PM
06-10-2008 09:35 PM
S_Hong,
Thanks! Your starter example worked great. I'd seen the Write Dig Chan.vi example, but didn't know how to put a wrapper around it to make it blink.
I have adapted your VI to test drive a small stepping motor for the first time. I'm using the blinking USB-6009 output (+5VDC to 0 VDC) as a "STEP" command pulse train input to an EasyDriver board for the stepping motor. The EasyDriver has 8 microsteps per full step and the motor is 200 full steps per rev, so 1600 steps equals one full revolution. The "Rate (Hz)" control on the front panel makes a very crude speed selector based on software loop timing. At slow speeds rotation is rather clunky but becomes smoother at higher speeds until it tops out at about 2000 Hz and 18 RPM on the motor. I have no accel/decel ramp on the motion profile at this time, but the stepping motor keeps up with the pulse train at these slow speeds. I was able to add indicators on the font panel to show the elapsed time for the move and RPM for the stepping motor shaft. Setting it for 1600 steps (1 rev) and 2000 Hz rate then pressing "Run Once" causes one motor shaft revolution in about 3.2 something seconds equivalent to 18.something RPM. Pressing "Run Continuously" causes the motion to repeat, with a brief pause and recalculation of the elapsed time and RPM after each cycle. There is some tens of milliseconds differences between runs showing the variability of the loop timing. Optimization of the motion profile will come later. It is just fun to see it turn at this point.
I've attached an updated VI with my additions. My next step (no pun intended) will be to add a second USB-6009 output bit to set the stepper's "DIR" command (0=CW, 1=CCW). That will still be a challenge at my knowlege plateau.
Credit for the EasyDriver board goes to Bruce Shapiro at http://greta.dhs.org/EasyDriver/. The EasyDriver and stepping motor can both be bought cheap from Spark Fun at http://www.sparkfun.com/commerce/categories.php. These are fun sites to visit if you are into such things.
Thanks again, akedb-78
06-11-2008 11:32 AM
Hi aekdb-78,
In order to write to multiple digital I/O lines, you must write the data in an array and pass it to the DAQmx Write.VI. Note that you must modify the type of write you will be performing to a Digital 1D Bool NChan 1Samp. You can see the changes I've made in the attached sample code.
There are great online tutorials on our website you can use to get better acquainted with our DAQmx drivers if you still need help.
http://zone.ni.com/devzone/cda/tut/p/id/5434
S_Hong
06-12-2008 10:06 PM
06-12-2008 10:06 PM
06-12-2008 10:06 PM
06-12-2008 11:04 PM
S-Hong,
Thanks, but it is not working for me. I've read tutorials and tried assorted things and don't understand it yet.
I see the new "Direction" control and changes in your last VI. I selected my USB-6009 Dev1/port0/line7 to be the "STEP" input and get Error -200524 occurred at DAQmx Write (Digital 1D Bool NChan 1Samp 1Line).vi:1, Number of Channels in Task: 1, Number of Channels in Data: 2.
The front panel "Direction" control should manually toggle to write a maintained state (1 or 0) out to my USB-6009 Dev1/port0/line6 to be the "DIR" input to the EasyDriver board. The "Rate" and "Steps" controls then make USB-6009 Dev1/port0/line7 blink as the pulse train to rotate the stepping motor.
I tried making a NI-DAQmx Task, named "TestRunStepMotorTask" configured with two channels, named "DigitalOut_7_Step" and "DigitalOut_6_Step", one sample on demand, and saved it OK fine in NI-DAQmx. I went back into the TestRunStepMotor(Modified).vi block diagram and browse select that task name into task fields in the DAQmx Output, Start, Write, and Clear functions. Then I got lost trying to group digital lines into one digital channel, or separate them into multiple digital channels.
I left it broke in the attached vi, in hopes you will provide the insight/fix to get me back on track.
Thanks for your help...
06-13-2008 02:20 PM
Hi aekdb-78,
The reason why your are getting this error is because you may not have specified the right channels for your DAQmx Create Channel VI. You can fix this problem by setting the Lines on your front panel to "Dev#/port0/line6, Dev#/port0/line7" or ""Dev#/port0/line6:7", where # should be your device number in Measurement & Automation Explorer (MAX). The order in which you write your channels will correspond to the order in which the data is written in your data array.
However, if you decide to create a DAQmx Task in MAX instead, then you can simply bypass the Create Channel VI and wire it straight to the DAQmx Start VI since all the channels and type of task is already defined in your DAQmx Task.
S_Hong
06-13-2008 07:57 PM
S_Hong,
Thanks! I got it now. I was making it too hard. I appreciate your help.
aekdb-78