Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling a Stepper Motor Drive for Constant Velocity with a DAQ Device

Overview

This example was written to control a stepper motor drive using the digital output lines of a general purpose DAQ device. The example can be used to control any stepper motor drive which uses step/direction control signals with a DAQ card that can output at least three compatible digital signals, including a hardware-timed pulse train.

Description

This example sets up three digital output tasks using the DAQmx API. One digital line is used to enable the stepper motor drive, while the other two select the direction and generate the required step pulse.

Requirements

Software

  • LabVIEW 2011 or compatible
  • NI-DAQmx 9.3.5 or compatible

Hardware

  • Compatible DAQ Device (minimum three suitable digital outputs)
  • Compatible Stepper Motor Drive (using Step/Dir inputs)

Note: Please consult your hardware's specifications or manufacturer to be sure that your DAQ device's digital output lines operate within the voltage and current range specified by your motor drive. It is possible to damage your equipment if used incorrectly.

Steps to Implement or Execute Code

First, select which digital output lines you will be using to generate the required control signals. You must select the line you are using for each signal in the appropriate front panel control. You must also verify the steps/revolution setting of your stepper motor drive and confirm that the 'Step Pulse Train Frequency' control is set accordingly to achieve your desired velocity. This VI will control a stepper drive for constant velocity. For example, if your stepper motor drive is set to use 200 steps/revolution, a setting of 200 in the 'Step Pulse Train Frequency' will correspond to 1 revolution/second or 60 RPM.

After selecting which digital lines are being used for which signals and confirming the desired steps/revolution setting, verify all connections to the stepper drive and run the VI. Clicking the 'Enable Drive' Boolean will enable the stepper motor axis, and toggling the 'Clockwise/Counterclockwise' Boolean will select the direction of motion.

This example does not include support for feedback or velocity profile smoothing. These more advanced features will require additional programming or the use of a dedicated motion controller.

Again, please be careful and consult your device manufacturer if necessary before attempting to use this code.

**This document has been updated to meet the current required format for the NI Code Exchange.**

Comments
Member mohk
Member

i am new and using smiulated daqmx.

which driver r u using??

Member example_scrub
Member

NI DAQmx is the correct driver to use.  Simulated devices don't actually write data to anything, and input data is purely simulated.

Member Adi_adarsh
Member

Which driver we should use when we are controlling stepper motor with a DAQ?

Member Sammid
Member

I was using this code to run my stepper motor. I could control the direction of the motor few days ago. But now it is running only in anticlockwise direction. Can anyone please let me know the reason?

Contributors