Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling stepper motors with C/C++

Hello,
I have two stepper motors and two drives. And I want control them using Visual C/C++ in 6025E.
i can  find some examples for CW direction pulses (i used CTR0&CTR1 port with VC DigPulseTrain-Cont.c)
   (CW pulses related only freq , so If i want to chang freq,  i used "DAQmxSetCOPulseFreq")
 
But I cannot find method for CCW direction pulses that want only continuos voltage or pulse.
 
How can i make them?
 
 
 
0 Kudos
Message 1 of 4
(8,023 Views)
DAQ boards are primarily designed for measurement tasks. They can be used for control tasks, too but this typically requires the use of a real-time system. This is also necessary if there is no control loop involved but other real-time tasks like monitoring limit-switches and following error. Additionally it will be impossible to generate velocity ramps for acceleration/deceleration  with counters while still being able to control the motor position. Without these ramps the maximum velocity that you can reach with your motor will be extremely limited.

Controlling a motor is much easier by using a motion control board. These boards take care of all real-time tasks onboard and it's much simpler to command the motor. E. g. for a straight line move you just need to load parameters for acceleration, velocity and target position. Then you send the start command to the motor and the rest is done by the board.

E. g.  the PCI-7332 provides two stepper modes: Step & Direction (= 1 pulse output and 1 static I/O line for fwd and rev direction) and CW/CCW mode (= 2 pulse outputs, one for fwd, one for rev). Especially the latter mode can't be done with a DAQ board for two axes as this would require four counters.

Please understand that this is not meant to be a marketing/sales post but I have seen people wasting weeks to program a motion control application with a DAQ board with poor results...
A motion control board might be slightly more expensive than a DAQ device but the price difference pays off quickly by saving a lot of time when developing the application.

Best regards,

Jochen Klier
National Instruments Germany
0 Kudos
Message 2 of 4
(7,997 Views)
Thanks for your advice, Jochen.
 
But I have cost problem. I'm just sophomore at college. Also, I borrowed 6025E from lab. Actually, I have bought 6009. But I didn't know that 6009 doesn't offer counter function. If I knew about motion board, I bought that.
 
I'm plan to make a small robot with two wheels and streo vision. My part is stepper motor control. I am using two CTR output for CW pulse in 6025E. I'm trying to use anlalog output AO0&AO1 for CCW pulse. But I can't find that function.
Could you help me more?
 
Garden.
 
 
 
p.s. I'm also poor to use English. Sorry.
 
 
 

메시지가 08-07-2006 03:12 AM에 Garden에 의해 편집되었음

0 Kudos
Message 3 of 4
(7,995 Views)
Garden,

this will become a tough one. For robot control you will need good position control and accel/decel ramps. You could use AO0 and AO1 to generate pulsetrain waveforms. Please have a look at the shipping NI-DAQmx examples for waveform generation. You will have to precalculate squarewave-waveforms and output them with the AOs. Those waveforms could contain accel/decel ramps, but again, your counters are not capable to do that while still doing position control.

Again this sounds like you are going to invest a lot of time into a poor solution. Please note that NI offers a good amount of discount for academic applications. The PCI-7332 is a high performance board with a lot of features. That's why it's priced in the mid-range rather than in the low-cost range. There are a lot of external stepper control modules from other vendors available, too, that provide much less features but that are cheap. These modules are typically interfaced through RS232 and they accept serial commands. They are available in a lot of electronics shops. So if you don't get a budget for a PCI-7332 please consider to use this type of modules. The PCI-6025E is really a bad choice for your task.

Jochen


0 Kudos
Message 4 of 4
(7,988 Views)