Stepper Motor Control
Stepper Motor Control
The use of stepper motors is an ideal solution for any mechatronic system requiring accurately
controlled actuation. They are very popular due to their low cost, high reliability, high torque at low
speeds and a simple, durable construction that operates in many environments. This document will
provide a brief introduction to stepper motors and how to implement a stepper motor control
system using an Arduino controller.
1: Stepper Motors
A stepper motor is a brushless DC electric motor that divides a full rotation into a number of equal
steps. The motor’s position can be controlled to move to and held at any one of these steps without
the need for sensory feedback (open-loop control), as long as the motor is operating within its
torque limits (ie: there is no slipping). Out of the three basic types of stepper motors (variable
reluctance, permanent magnet, and hybrid) the hybrid motor is used the most as it combines the
best characteristics of the other two types. Standard hybrid steppers have 200 rotor teeth and step
at 1.8 degrees. Hybrid stepper motors can be found in disk drives, 3D printers, parallel kinematic
machines etc. If linear motion is required, a stepper motor can be coupled with a lead screw.
Extremely fine resolutions can be obtained (depending on the pitch of the lead screw).
Most stepper motors feature two isolated coil windings. This means that a minimum of 4 wires will
come out of the motor (two for the ends of each coil). Unipolar stepper motors are manufactured
with a central tap for each coil that connects back to the power source (a total of 6 wires). These
central taps can be used to split each coil into smaller coils that can be powered independently. If
the central taps are left disconnected, a 6-wire unipolar stepper motor can be converted to a 4-wire
bipolar configuration. Bipolar motors do not have central taps. The advantage of using motors in the
bipolar configuration is that they produce higher torques as all the motor phases can be used at
once. The disadvantage of bipolar steppers is that they require an additional circuit known as an H-
bridge to reverse the polarity of the circuit (present in stepper motor drivers). Unipolar motors
produce less torque but don’t require the additional circuitry. 4-wire bipolar motors are used more
often because stepper motor drivers are easy to use [1].
The application’s torque and speed requirements govern the choice of a stepper motor. Every
commercially available stepper motor should have a data sheet specific to the model. If the
datasheet is not available on the market site, it can be obtained by simply entering the serial number
into a search engine. The data sheet displays the motor’s torque-speed curves and dimensional
specifications, along with the rated voltage and current. As long as the motor is operated within the
limits of the torque-speed curve, it will function as expected. Figure 1shows a typical torque-speed
curve for a stepper motor. The pull in torque curve shows the maximum stepping rate for various
torque loads at which the motor can start synchronise, stop or reverse. The pull out torque curve
shows the maximum stepping rate of the motor for various torque loads, but it cannot start, stop, or
reverse at those rates. The area between the two curves is known as the slew range, where the
motor operates without synchronism (not controlled motion). It is best to pick a motor that will
operate below the pull in curve.
Figure 1 Stepper motor Torque-Speed curve [1]
Refer Appendix A for a typical stepper motor datasheet. Holding torque refers to the maximum
torque the motor can hold when it is switched on and not moving. Detent torque refers to the
torque that the motor can hold when it is not switched on. The detent torque is naturally much less
than the holding torque. These two values should be taken into consideration when picking a motor.
NEMA Standards:
Stepper motor sizes are made according to NEMA (National Electrical Manufacturers Association)
standards. A NEMA 23 stepper motor, for example, will have a 2,3 by 2,3 inch faceplate. NEMA
codes are an indication only of the size of the faceplate of the motor and can be used only as a rough
estimate of the motor’s power.
The rated voltage of a stepper motor states what the maximum voltage would be if a direct DC
voltage was applied to the winding with the intention of staying within the rated current of the
motor. It is therefore an indication of the impedance of the wiring which means that a higher quality
motor will have a lower rated voltage. Applying any voltage above the rated voltage should allow the
motor to work. The higher the applied voltage, the faster the operation.
The current of a stepper motor is usually given as an Amps per phase value and is an indication of
the maximum current the coils can handle without overheating. Unipolar motors usually have 2
windings split into 4 phases. In bipolar configuration, the two windings would be used as 2 phases.
The grey areas indicate where the resistance was infinite, meaning the wires belong to different
coils. The blue, orange and brown wires are connected to one coil, while the red, grey and white
wires are connected to the other coil. The orange and blue wires should be connected to Phase A (+
and -), and the red and white wires should be connected to Phase B (+ and -). The brown and grey
wires are the centre taps for each coil (they have smaller resistances) and can be ignored when using
the motor in a bipolar configuration.
Another important note: The Enable ports can be ignored as these only need to be used when an
electronic disable of the motor is needed.
3: Power Supplies
Power supplies provide all the current and voltage required by the stepper drivers to drive the
stepper motors. A single power supply may be used to provide power to multiple drivers, provided
that there is enough current to split between them. In most cases, “daisy chaining” as mentioned
requires large and expensive power supplies. A cheaper, simpler alternative would be to use
individual lower amped power supplies for each driver. Appendix C shows a wiring diagram where 3
individual power supplies have been used for 3 separate stepper drivers and stepper motors.
4: Arduino Controllers
Arduino is an open-source electronics platform based on easy to use hardware and software. There
is ample online support for their platforms. We have all used arduinos at some point. On issue with
Arduino may be the signal voltage which is usually 5V. Most electronic components are made to use
a 5V signal. The Arduino DUE, however uses a 3.3V operating voltage. This would be an issue if the
stepper motors or drivers were to be directly powered by the Arduino board. In this case, however,
the 3.3V signal would be fine as most electronic components would still recognize the pulses.
The following program can be used to test and calibrate the rotation directions and steps per
revolution of a stepper motor. The program intends to turn the motor 1 revolution in the positive
direction, then wait 10 seconds, then rotate back 1 revolution in the opposite direction.
If the motor initially moves in the opposite direction than intended, it may be corrected by switching
the polarity of one of the phases connected to the driver. If this solves the initial rotation problem,
but the motor does not change direction after 10 seconds, the other phase’s polarity should be
switched. If the motor moves more or less than exactly 1 rotation at a time, there may be a number
of things affecting it. Either the value for the variable ‘stepsperrev’ is wrong, or the driver DIP switch
settings are wrong. If somehow, the driver does not provide a setting for the exact number of steps
per revolution of the chosen motor, a setting that is a multiple of that value may be used, and should
be compensated for accordingly in the programming code.
#include <AccelStepper.h>
AccelStepper stepper1 (1, 11, 10); //initialize AccelStepper object
int stepsperrev = 200; //number of steps per revolution
int pos1 = 1*stepsperrev; //number of steps needed to move
void setup() {
// put your setup code here, to run once:
stepper1.setMaxSpeed(20*stepsperrev); //set maximum speed
stepper1.setAcceleration(stepsperrev*5);//set acceleration
}
void loop() {
// put your main code here, to run repeatedly:
The next programme does the same thing as the previous programme, for 3 stepper drivers
simultaneously (refer to Appendix C for the wiring diagram of the system that was used with this
program):
#include <AccelStepper.h>
AccelStepper stepper1 (1, 11, 10); //initialize AccelStepper object
AccelStepper stepper2 (1, 9, 8);
AccelStepper stepper3 (1, 5, 4);
int stepsperrev = 200; //number of steps per revolution
int pos1 = 1*stepsperrev; //number of steps needed to move
int pos2 = 1*stepsperrev;
int pos3 = 1*stepsperrev;
void setup() {
// put your setup code here, to run once:
stepper1.setMaxSpeed(20*stepsperrev); //set maximum speed
stepper1.setAcceleration(stepsperrev*5);//set acceleration
stepper2.setMaxSpeed(20*stepsperrev);
stepper2.setAcceleration(stepsperrev*5);
stepper3.setMaxSpeed(20*stepsperrev);
stepper3.setAcceleration(stepsperrev*5);
}
void loop() {
// put your main code here, to run repeatedly:
if ( stepper3.distanceToGo() == 0 &stepper1.distanceToGo() ==0 & stepper2.distanceToGo() == 0)//if all 3
steppers have finished moving
{
delay(10000);
pos1= -pos1;//invert position
pos2= -pos2;
pos3= -pos3;
stepper1.moveTo(pos1);//set new position
stepper2.moveTo(pos2);
stepper3.moveTo(pos3);
}
//stepper1.run();//run stepper 1 step per loop
stepper2.run();
stepper3.run();
Multistepper Class
The MultiStepper class provides a clean way of controlling up to 10 AccelStepper objects at once. It
takes an input array of the desired positions of each stepper and calculates the required constant
speed each motor needs to reach their destinations at the same time. This can be very useful for
parallel kinematic control and linear motions in Cartesian systems. One downfall is that only
constant speed movements are supported. Link:
http://www.airspayce.com/mikem/arduino/AccelStepper/classMultiStepper.html#a383d8486e17ad
9de9f1bafcbd9aa52ee
References
[1] AccuGroup, “Unipolar Stepper Motors Vs Bipolar Stepper Motors,” 2016. [Online]. Available:
https://www.accu.co.uk/en/p/95-unipolar-stepper-motors-vs-bipolar-stepper-motors.
[Accessed 9 July 2018].