Applied Robotics/Mechanisms and Actuation/DC Stepper Motor

Stepper Motor Basics
A stepper motor is a DC motor that consists of a polyphase coil stator and a permanent magnet rotor. These motors are designed to cog into discrete commanded locations and will hold their position as current is ran through the motor. Every stepper motor will have a fixed number of steps per rotation that can be stepped through by changing the direction of the applied magnetic field in the motor. Rotation is achieved by continuously stepping the motor with a short delay in between steps. The shorter the delay, the higher the RPM.

Stepper motors work well for simple open loop position control applications where high torque and low RPM are needed. As speed increases, stepper torque greatly decreases, and excessively small step timing can lead to missed steps due to motor inertia.

Controlling a stepper motor requires a state machine that will commutate, or change the direction of the magnetic field in the motor, and apply a time delay in between steps to control motor velocity. This is typically done using a timer on a microcontroller and 4 I/O lines to control the current and therefore the magnetic field direction.

Unipolar stepper motors
utilize center-tapped coils and switching elements that only draw current in one direction to change the current direction in the motor. These motors require twice the winding length for unipolar drive compared to a comparable bipolar stepper, and are thus less powerful for their weight than bipolar steppers. These motors typically have two center tapped phases.

Bipolar stepper motors
utilize a single coil per phase and require the control electronics to switch current directions through the coil, typically with a single H-bridge per phase. Unipolar motors can also be driven in a bipolar fashion by leaving the center tap of each phase disconnected. These motors typically have two phases.

Unipolar Stepper Driver
An efficient unipolar stepper driver can be built from 4 N-channel MOSFETs controlled by microcontroller I/O pins. Each of the coil center taps is connected to a positive voltage that the motor is rated for and each of the phase coil ends is connected to a different MOSFET drain. Each step is controlled by turning on one of the MOSFETs at a time. Note: If the MOSFETs will be directly driven off of microcontroller I/O levels, it is critically important that they are logic-level FETs that will turn on at 5V.



Bipolar Stepper Driver
A bipolar stepper driver can be built using a 4-channel high current driver, such as an L293, SN754410, or L298 motor driver IC. Each of the outputs should have a pair of fast acting catch diodes to prevent damage to the driver IC from flyback voltages that occur as a result of motor inductance during switching. Each phase of the stepper motor is connected to two of the output drivers, forming two H-bridges and allowing for current to be driven bidirectionally through the two phases. Only one phase should be active at a time for a standard control scheme, so the output driver enables will have to be turned on and off in addition to controlling the direction of the output drivers.



Stepper Control Code
Stepper control can be done on an AVR microcontroller using either a delay statement (good for simple testing, but terrible for accurate timing and program efficiency), or with a timer/counter and an interrupt (slightly more complicated, but much better efficiency wise). The following code shows how to utilize a timer counter on an ATmega device along with a simple state machine and I/O lines. Reversing direction just involves stepping in the opposite direction. This code can be used to control an L29x type motor driver to drive a bipolar stepper or a pull-down driver to control a unipolar stepper.

The basic step sequence is as follows for both types of two-phase stepper motor.

Off the Shelf Stepper Solutions
As an alternative to creating your own stepper driver/controller, a number of low-cost off the shelf products exist for controlling small steppers. Texas Instruments, Allegro, ST Microelectronics, and ON Semiconductor all make specialty microstepping driver ICs that operate on a simplified logic interface and provide a finer granularity of stepper control than the basic concept outlined above. A number of hobbyist vendors, such as Sparkfun and Pololu, carry breakout boards for these types of stepper drives.