Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Software timed Pulse width modulation using DAQ USB-6009 (posted in other area but never got a response.) Please HELP

First, a brief history:

I am using a gecko step driver G203v.  Here is the spec for the STEP input (it is what I am having trouble with)

-5V logic outputs with 2.5mA minimum source drive current. The STEP input’s maximum rated frequency is 350kHz with a 50% duty-cycle waveform. The
G203V steps the motor on the 0 to 1 logic (positive) edge of the STEP signal. 


 I am using a USB 6009 DAQ.


I seem to be having some trouble outputing to the step input of the driver.


I can output a T/F to the disable input on the driver and this is working great (First step to lock the motor)


Next I want to send  0/1 digital output to the step input (keeping the duty cycle at 50% and changing the frequency to increase the speed of the motor).

However, I am having trouble accomplishing it.  The current should be strong enough from the DAQ (so says the spec's for the 6009) so I am thinking this is not the problem.  


With the first program I have attached I hooked up my ends to the oscilloscope and I could get accurate readings up to 30hz or so...after this I could not ramp up the frequency.  I am assuming this is a software issue.  So, I assummed that the motor was getting too low a frequency for the steps to occur.  Do you think this is correct?


I have no idea how to accomplish this but I was trying to get it to output a digital signal so I built something that I thought could work.


I have attached two codes.  The first one called "Short Version for step motor" and the second version called "Pray this works".  


When I hooked up an oscilloscope to the second program I could have it output up to about 250hz (a lot better) but again there is some software issues that are creating noise in my square wave and there is a lot of extra noise which could alter how the driver filters the signal.    


Can anyone shed some light into:


1. Why the first one is not allowing me to get my motor to step and what would correct this?


2. Would the second program "Praythisworks" work in my situation ? and how come I still cannot get the motor to step?



3. Why does the square wave that is coming from the DAQ have so much noise and is there a way to clean this up? If I hook up a function generator to my step driver I could easily get it to step so I am not sure what the problem is. 


Any suggestions please comment 


Anyone Please help...thank you, thank you,



Download All
0 Kudos
Message 1 of 7



I would recommend that you take a look at some of our DAQmx tutorials found here and here.  These will really get you off to a good foundation for a lot of the topics I am going to discuss below.


1)  I am not exactly sure about your specific motor but hopefully when you get it programmed correctly it will start working.  In this program you have two DAQ assistants inside of a while loop in addition to other code and a wait.  All of this will contribute to slower loop times.  If you are looking to get faster performance you really need to start implementing some of the tecniques shown in the links above.  Meaning you should start using the actual daqmx vis (you can right click on the DAQ Assistant and select generate code).  You also might want to consider using 2 or even 3 different while loops so that all of your code will run in parallel.


2) The reason you are getting a better rate in the second program is simply that you have less going on inside the while loop.  You currently have it configured to a 1 Sample On Demand rate.  Why is this?  Once again use actual DAQ code it will significantly increase your performance while also giving you more control over your acquisition.


3)  If you would like to purchase a function generator we have many of these available.  Becasue of the low cost of the 6009 many of the extra features of an expensive bench top instrument would not be as simple to replicate.  If you do get one of the devices linked above this will be a simpler process.

Jason Daming
Applications Engineer
National Instruments
0 Kudos
Message 2 of 7

Jason, thanks for the reply.  What I do not understant is that


1. The driver input has 3 main inputs (1. DISABLE/ENABLE,  2. STEP, and 3. DIRECTION).  I can easily get the DISABLE/ENABLE input to work by implementing TRUE/FALSE Boolean (It outputs a 1/0) to that input of the driver.  So I am pretty sure I need to do the same for the STEP and DIRECTION inputs (as I understand from the dirver's directions).  So, to answer your questions


Since I am using the USB 6009 (no hardware counter) my only option is to use (1 sample on demand) in both of the programs that I linked.  I simply do not get a choice of anything else.  


Hence, why I had to do software timed digital output.


As for purchasing something more expensive...I am a grad student and my budget is not big which is why I looked at the 6009 as a basic multiDAQ that could do analog and digital.


Even if I just use DAQmx digital write it still does not make this program faster or the most important part make my motor step.  


So I am still lost.  


The simplest thing I want to do is output digital 1/0 to the STEP input of the driver and if I remove the two other DAQ assistants in the first program and just have one DAQ assistant, to one channel, in one while loop I still cannot get the motor to step which is why I wanted to try making it step using the second program and still no luck.


I understand that I am limited with this DAQ but I am trying to make it work and I have been told by many that I should be able to only that the output wont be very reliable.  


Thanks for your answers but I am still lost and not sure what to do.  


Any other thoughts or assitance would be appreciated.

0 Kudos
Message 3 of 7



Please post your code using the DAQmx VIs that isn't working, I can't believe it doesn't make the code any faster!


I wasn't implying that you had to purchase something better and definately understand budget concerns but comaping this device to an FGEN is...flattering towards the 6009.


So neither step nor direction works?  How long does the pulse need to be?  What does the signal the 6009 is outputting look like compared to that of the FGEN on a slow speed?

Jason Daming
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7

Hi JSC81,


How about trying this example:

Using SW-Timed Digital I/O to Control a Stepper Motor with DAQmx



The screenshot on the community page was from an earlier revision of the code, I just modified slightly it so you can now set the high and low time of your pulses.  You could do the conversion if you want to specify frequency and duty cycle instead.  The knob is meant so you can set the position of your stepper motor--you can take this out if you don't need it and just tell the loop how many times to run (1 pulse for each iteration) and what direction to turn. 



Here's the signal I was getting out of my 6251 when setting a 100ms high and low time (the entire graph represents 1 full second of data):





Not bad for SW-timed. Smiley Wink



If you have any questions about the code don't hesitate to ask.  If the above example STILL doesn't allow your motor to step, we may want to probe the line when all connections are made and see if we are getting the 0-5V output we would expect.  The USB 6009 can drive up to 8.5 mA on a single channel (up to 102 mA across all channels).



Best Regards,


John Passiak
0 Kudos
Message 5 of 7

John, thanks for your reply. 


I am clueless why this isnt working properly.  I must have something either programmed incorrectly or something with the current is not right.  


So this is where I am now.  I tested 3 programs including the one you pointed me to.  I hooked up an oscilloscope to the output lines to test the output and they are a bit noisy so I am not sure if this could impact the output signal from the DAQ to the Driver.


The person was correct that using strictly DAQmx instead of DAQAssistant will increase the speed of the program so this helped me increase the speed of the program however I still cannot get my motor to step.



The Voltage that I am outputing which is measured by the occilloscope is about 6V peak to peak, this seams okay.  I also confirmed this with a multimeter. 


I thought it could possibly be the output from the DAQ so I checked multiple channels and still nothing.


Not sure what the possible cause of this could be. 


1. Is it possible it is the way I am outputing the signal?


2. Can it be the current? If so, this is pretty difficult to check coming out of the DAQ. 


3. Can if be that it is not getting the proper signal and that what I see as my square wave is not really what the driver is receiving?


Please help if you can...I am in need of some Guru help.



0 Kudos
Message 6 of 7



1)  Some devices can be very picky about getting a perfect signal, but most have such a wide tolerance that anything resembling the correct signal will register as it works on rising edges.  I would probably ask the manufacturer what their tolerance of the signal is?


2)  It is very possibly the current.  Why do you say it is so difficult?  Can you double check the current specs this device needs?


3)  If the DAQ device is outputting the correct signal to an oscilloscope then LabVIEW is working correctly and the problem either resides in the intensity of the signal (like current) or some other problem getting this devices working (like connections or different specifications of the device).  Either way we are really reaching the point where it might be best to talk to someone from the company that makes the step driver.

Jason Daming
Applications Engineer
National Instruments
0 Kudos
Message 7 of 7