ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Driving Stepper Motor Faster

I have an NI USB-6008 DAQ that I am driving from Visual Basic Express using the .NET framework. I am using one of the digital outputs to drive a "step" signal into a stepper motor controller. As a test I have adjacent lines in the visual basic code to send a logical one followed by a logical zero to the step output and I wind up with a pulse around 3ms in duration with no intervening code. This would mean around 6 ms minimum between pulses.

I understand that there are a lot of protocol steps, operating system calls etc to go through in getting the command across the USB and ultimately to the digital output but this seems very slow to me. Is there a way I can speed this up?
0 Kudos
Message 1 of 10
(4,733 Views)
I have just been looking on the forum and found the following post. I think the upshot is that I need to buy a better DAQ.
 
 
Anyone got any ideas?
0 Kudos
Message 2 of 10
(4,718 Views)

Hi jarra,

 

The USB-6008 does not have any correlated I/O, which means that any triggering or timing used to generate digital outputs is going to be software timed.  Therefore, the operating system handles all of the resources necessary to perform your I/O, and you’re bound to have much slower data rates than with hardware timed I/O. 

 

National Instruments has an entire product line of motion controllers that could be used to drive a motor.

 

However, if you’re looking for something more versatile, I would suggest a device from our M Series multifunction data acquisition line.  These devices contain digital I/O, analog I/O, and counters that can be used for synchronization and other advanced I/O operations.

 

With a better idea of your application (required number of analog/digital I/O lines, price, etc.), I could recommend a specific M Series device.  Post back if you have further questions. 

 

I hope this helps!

 

 

Ed W.

Applications Engineer

National Instruments

Message 3 of 10
(4,706 Views)
Thanks for the reply Ed.

Do you have any idea what kind of improvement I could expect by using a different language e.g. Visual c++ rather than Visual Basic. Or another way of asking - what is your view of where the 3ms is being consumed and how much of this would be language dependent?

With regard to my requirements, I need :-
2 differential analog inputs (12 bit resolution should be ok)
1 true analog output (i.e. not PWM)
Ability to drive stepper motor with controlled acceleration and deceleration up to a speed of around 3000 steps per second
Driver support for Visual Basic
Ideally USB interface but could be PCI


0 Kudos
Message 4 of 10
(4,699 Views)
Oh sorry I forgot a key requirement:-

Cost = as cheap as possible 😉
0 Kudos
Message 5 of 10
(4,695 Views)

Hi jarra,

 

I would expect the C++ to run faster than Visual Basic, but I couldn’t give you any specifications on the speed differences between the two languages.

 

Otherwise, the NI PCI-6221 looks like a good choice for your application.  It is part of our M Series product line, and it meets most of the requirements that you’ve listed in your last post.  There is also a USB M Series line, but these devices tend to be higher priced than their PCI counterparts. 

 

Ed W.

Applications Engineer

National Instruments

Message 6 of 10
(4,669 Views)
As an experiment I am going to try the same thing in Visual C++ to see what kind of performance improvement I get but I can not find any examples on the CD or on-line. Can someone point me to some examples of using Visual C++ to configure digital output via DAQmx.
0 Kudos
Message 7 of 10
(4,656 Views)
As long as you are running a compiled program, you probably won't see much difference whether you use Visual Basic, C++, .net, LabVIEW, or anything else. No matter which language you use, you are calling into the same DAQmx dll and using on-demand digital I/O is slow. Also, no matter which language you use, the OS is going to do whatever it wants and periodically interupt your program so that the 3ms period could easily stretch out to many times that value. The only way to get a faster and more repeatable period is to use a digital I/O board with hardware timing.
0 Kudos
Message 8 of 10
(4,639 Views)

Hi jarra,

 

Dennis is exactly right about the hardware timing. 

 

However, if you still want to try using Visual C++, there are plenty of C examples in the following folder.

 

\Program Files\National Instruments\NI-DAQ\Examples\VisualC

 

The examples just use the C programming language, but you could simply add the user interface manually.  On the other hand, since Windows tends to give high priority to visual processes, adding the visual components to the code may end up slowing down the data acquisition.

 

All in all, if you want any kind of deterministic digital output timing, you will need a device with hardware timing like the ones I suggested in the previous post.

 

Ed W.

Applications Engineer

National Instruments

Message 9 of 10
(4,629 Views)

Hi Guys,

Just to close this thread, I did the experiment with Visual c++ and it was 3 times faster i.e. achieved 2ms period with VC++ rather than 6ms period with VB. i.e. no great improvement as you were indicating. I am going to evaluate whether I can live with the slower speed and in parallel look further into the more suitable products mentioned.

Thanks for your help.

0 Kudos
Message 10 of 10
(4,590 Views)