User Tools

Site Tools


info:controlling_stepper_motors

Table of Contents

Stepper Motors

There is an Arduino library called Stepper. This makes it nice and easy to work with steppers, without mucking around writing low-level code yourself, so I would recommend using it. The documentation on the Arduino website includes some hardware wiring “reference designs” for both unipolar and bipolar stepper motors.

Unipolar

A unipolar stepper motor typically has 5 or 6 wires (depending on whether the two centre taps are internally connected together or not), but a bipolar stepper motor has 4 wires, so that's how you can identify them. If you don't know which wires are which, you can use resistance measurements to identify them.

With a unipolar stepper motor, you only need to have current flowing through the coils in one direction. Therefore, you can use a set of 4 transistors (or a Darlington transistor array chip like a ULN2003) to drive the four coils from an Arduino, and that's relatively straightforward to set up.

Bipolar

A bipolar stepper motor has only 4 wires. It's a bit harder to control a bipolar stepper motor, since you need to control current flowing backwards and forwards in both directions in the motor's two coils.

This means that you need a pair of H-bridge circuits. You can either use 2 discrete H-bridge circuits (usually matched) and drive the motor via PWM, or you can use a driver chip that uses 'step and direction' inputs. Most people end up using driver chips as 'step and direction' setups use only 2 I/O pins per stepper, whereas driving the motor with PWM uses a lot more I/O pins.

Depending on exactly how much current the stepper motor needs, H-bridge chips like the SN754410 or L293 can be convenient choices to do this job. (If you don't know exactly how much current the stepper motor coils will draw… you can determine it if you know the voltage supply and the motor's windings' resistance.) There are also a number of Allegro H-bridge chips, such as the A3977, A3979, A4983 or the A4988. Pololu make a carrier board for the A4983 and the A4988 (same pinout) that has become increasingly popular. As an alternative, someone has produced an open source design for a carrier for the A3979 that uses the same pinout config as the A4983/A4988 carrier from Pololu.

Most H-Bridge chips can be driven by a pair of pins marked “Step” and “Direction”, where you set the direction and then toggle the step to step one step (or part thereof if you're in a microstepping mode) in that direction. Most of these chips have an enable which can be used to enable/disable the motor, as well as options for microstepping. Note that changing microstepping modes during movement could lead to inconsistent stepping. Step position should also not be assumed to stay the same when the motor has been disabled, for similar reasons (eg: effects of force or gravity on whatever the motor shaft is attached to).

Many systems that use stepper motors will use endstops (micro switches or opto-electronic sensors) to detect a limit for movement, to avoid damage to the device/motor/electronics.

hbridge.jpg

Single H-bridge circuit using transistors - designed to be run via PWM (not Step/Direction)

info/controlling_stepper_motors.txt · Last modified: 2012/07/12 09:25 by cchs_admin