Beruflich Dokumente
Kultur Dokumente
Guide Contents
Guide Contents
What is a Stepper Motor?
A 4-phase unipolar motor.
Types of Steppers
Motor Size
Step Count
Gearing
Shaft Style
Wiring
Coils and Phases
Unipolar vs. Bipolar
6
6
7
8
9
10
11
12
5-Wire Motor
6-Wire Motor
8-Wire Motor
12
13
13
Driving a Stepper
Simple Unipolar Driver
Simple Dual H-Bridge Driver
Adafruit Motor Shield V2
Advanced CNC Controllers
Matching the Driver to the Stepper
Know the Driver Specifications
Know the Motor Specifications
Obey the Law!
Running Above the Law?
Chopper Drives
15
16
17
18
19
21
22
22
23
23
24
FAQ
Resources
Adafruit Industries
2
3
26
28
https://learn.adafruit.com/all-about-stepper-motors
Page 2 of 28
Stepper motors are DC motors that move in discrete steps. They have multiple coils that are
organized in groups called "phases". By energizing each phase in sequence, the motor will rotate,
one step at a time.
With a computer controlled stepping you can achieve very precise positioning and/or speed control.
For this reason, stepper motors are the motor of choice for many precision motion control
applications.
Stepper motors come in many different sizes and styles and electrical characteristics. This guide
details what you need to know to pick the right motor for the job.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 3 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 4 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 5 of 28
Types of Steppers
There are a wide variety of stepper types, some of which require very specialized drivers. For our
purposes, we will focus on stepper motors that can be driven with commonly available drivers.
These are: Permanent Magnet or Hybrid steppers, either 2-phase bipolar, or 4-phase unipolar.
Motor Size
One of the first things to consider is the work that the motor has to do. As you might expect, larger
motors are capable of delivering more power. Stepper motors come in sizes ranging from smaller
than a peanut to big NEMA 57 monsters.
Most motors have torque ratings. This is what you need to look at to decide if the motor has the
strength to do what you want.
NEMA 17 is a common size used in 3D printers and smaller CNC mills. Smaller motors find
applications in many robotic and animatronic applications. The larger NEMA frames are common in
CNC machines and industrial applications.
The NEMA numbers define standard faceplate dimensions for mounting the motor. They do not
define the other characteristics of a motor. Two different NEMA 17 motors may have entirely
different electrical or mechanical specifications and are not necessarily interchangeable.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 6 of 28
Step Count
The next thing to consider is the positioning resolution you require. The number of steps per
revolution ranges from 4 to 400. Commonly available step counts are 24, 48 and 200.
Resolution is often expressed as degrees per step. A 1.8 motor is the same as a 200
step/revolution motor.
The trade-off for high resolution is speed and torque. High step count motors top-out at lower RPMs
than similar size. And the higher step-rates needed to turn these motors results in lower torque than
a similar size low-step-count motor at similar speeds.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 7 of 28
Gearing
Another way to achieve high positioning resolution is with gearing. A 32:1 gear-train applied to the
output of an 8-steps/revolution motor will result in a 512 step motor.
A gear train will also increase the torque of the motor. Some tiny geared steppers are capable of
impressive torque. But the tradeoff of course is speed. Geared stepper motors are generally limited
to low RPM applications.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 8 of 28
Shaft Style
Another thing to consider is how the motor will interface with the rest of the drive system. Motors are
available with a number of shaft styles:
Round or "D" Shaft: These are available in a variety of standard diameters and there are
many pulleys, gears and shaft couplers designed to fit. "D" shafts have one flattened side to
help prevent slippage. These are desirable when high torques are involved.
Geared shaft: Some shafts have gear teeth milled right into them. These are typically
designed to mate with modular gear trains.
Lead-Screw Shaft: Motors with lead-screw shafts are used to build linear actuators.
Miniature versions of these can be found as head positioners in many disk drives.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 9 of 28
Wiring
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 10 of 28
There are many variations in stepper motor wiring. For our purposes, we will focus on steppers that
can be driven with commonly available drivers. These are Permanent Magnet or Hybrid steppers
wired as 2-phase bipolar, or 4-phase unipolar.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 11 of 28
5-Wire Motor
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 12 of 28
6-Wire Motor
8-Wire Motor
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 13 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 14 of 28
Driving a Stepper
Step in time, step in time
Come on, mateys, step in time
Step in time
Step in time, step in time
Step in time, step in time
Never need a reason, never need a rhyme
We step in time, we step in time
"Step In Time"
Robert B. Sherman and Richard M. Sherman
Driving a stepper motor is a bit more complicated than driving a regular brushed DC motor. Stepper
motors require a stepper controller to energize the phases in a timely sequence to make the motor
turn.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 15 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 16 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 17 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 18 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 19 of 28
Synthetos Forums
http://adafru.it/dod
Tiny G Wiki
http://adafru.it/doe
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 20 of 28
Now we come to the most important part: making sure that your motor and driver are compatible.
Mismatched motors and drivers can result in disappointing performance. Or worse: damage to the
motor and/or controller.
If you choose unwisely, you might meet this guy:
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 21 of 28
"Peak" current ratings are not applicable to stepper motors. Always go by the "continuous"
current rating.
https://learn.adafruit.com/all-about-stepper-motors
Page 22 of 28
better to calculate yourself from the above parameters using Ohm's Law.
These formulas should be strictly applied for all "constant voltage" stepper controllers. This
includes both V1 and V2 Motor Shields from Adafruit, and virtually all other L293D based
controllers.
But some motors have very low coil resistance. Strictly following those formulas, the drive voltage
will be less than 5v and performance will not be good. This type of motor is not a good match for a
constant-voltage driver. These steppers require a more specialized controller.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 23 of 28
Lenz's Law (http://adafru.it/ikC), that current will be in the reverse direction of the current creating
the field. This reverse current is known as "Back Electromotive Force" or "Back EMF".
This Back EMF increases the "impedance" or effective resistance of the coil. So Ohm's
Law (http://adafru.it/ikD) still applies - but to this impedance, not to the simple phase resistance.
This impedance limits the current flow through the coil at the beginning of each step.
Chopper Drives
A Chopper or "Constant Current" drive compensates for the back EMF by driving the motor with a
higher voltage. It is not unusual to drive stepper motors at several times their rated voltage using a
chopper drive.
To keep things safe at these higher voltages, the chopper drive also monitors the current being
delivered to the motor and "chops" it before it exceeds a pre-set level.
By starting at a higher voltage, the chopper drive is able to deliver more current to the coils at the
start of the step, increasing the available torque. In addition to adding torque at slower speeds, this
also allows for higher top-speeds.
Selecting a chopper driver and configuring it for a specific motor requires a good understanding of
both the motor and the controller.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 24 of 28
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 25 of 28
FAQ
Will this motor work with my shield?
You need to know the motor specifications as well as the controller specification. Once you have
that information, check the "Matching the Driver to the Stepper" page to see if they are
compatible.
It's a NEMA 17, so it should work, right?
NEMA frame-size standards only define the dimensions of the mounting faceplate. To figure out
if it is compatible, you need to know the electrical specifications of the motor.
What if there are no motor specifications?
See Jason on reverse engineering the stepper wire pinouts (http://adafru.it/aOI). That will tell you
the phase resistance. For phase current, you can estimate based on motors of similar design
and similar phase resistance.
When in doubt, it is always better to err on the safe side and use a lower current!
What size motor do I need for my project?
Most motors have torque (http://adafru.it/doj) specifications - usually in inch/ounces or
newton/centimeters. One inch/ounce means that the motor can exert a force of one ounce at
one inch from the center of the shaft. For example, it could hold up one ounce using a 2"
diameter pulley.
When calculating the torque required for your project, be sure to allow extra torque required for
acceleration (http://adafru.it/dok) and to overcome friction. It takes more torque to lift a mass
from a dead stop than it does to simply hold it up.
If your project requires a lot of torque and not much speed, consider a geared stepper.
How do I connect my motor to the Motor Shield?
For motors purchased from Adafruit, there are wiring instructions listed in the product
descriptions.
For other motors, check the motors spec sheet if available.
If you don't have a spec sheet, check Jason on reverse engineering the stepper wire
pinouts (http://adafru.it/aOI).
Will this power supply work with my motor?
First make sure it does not exceed the voltage rating for the motor or the controller.* You can
usually run a motor at a lower voltage, although you will get less torque.
Next, check the current rating. Most stepping modes energize two phases at a time, so the
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 26 of 28
current rating should be at least twice the current per phase for your motor.
* This applies to constant voltage drivers. For chopper drive controllers, check the instructions for
your controller.
Adafruit Industries
https://learn.adafruit.com/all-about-stepper-motors
Page 27 of 28
Resources
There is a lot of excellent information on the web about stepper motors. Here are some of our
favorite links:
Wikipedia (http://adafru.it/aOF)Stepper Motor Page (http://adafru.it/aOF)
RepRap Stepper Motor Page (http://adafru.it/dol)
Jones on Stepper Motors (http://adafru.it/aOH)
Jason on reverse engineering the stepper wire pinouts (http://adafru.it/aOI)
Adafruit Industries
Page 28 of 28
AN907
Stepping Motors Fundamentals
Author:
Reston Condit
Microchip Technology Inc.
Dr. Douglas W. Jones
University of Iowa
INTRODUCTION
Stepping motors fill a unique niche in the motor control
world. These motors are commonly used in measurement and control applications. Sample applications
include ink jet printers, CNC machines and volumetric
pumps. Several features common to all stepper motors
make them ideally suited for these types of
applications. These features are as follows:
1.
2.
3.
4.
5.
EXAMPLE 1:
Winding 1:
1001001001001
Winding 2:
0100100100100
Winding 3:
0010010010010
time
DS00907A-page 1
AN907
Figure 1 illustrates the most basic variable reluctance
stepping motor. In practice, these motors typically have
more winding poles and teeth for smaller step angles.
The number of poles can be made greater by adding
windings, for example, moving to 4 or 5 windings, but
for small step angles, the usual solution is to use
toothed pole pieces working against a toothed rotor.
Variable reluctance motors using this approach are
available with step angles close to one degree.
FIGURE 1:
FIGURE 2:
UNIPOLAR STEPPER
MOTOR
VARIABLE RELUCTANCE
STEPPER MOTOR
The difference between a permanent magnet stepping
motor and a hybrid stepping motor lies in how the multipole rotor and multi-pole stator are constructed. These
differences will be discussed later.
EXAMPLE 2:
Winding 1a: 100010001000
Winding 1b: 001000100010
Unipolar Motors
time
Note:
EXAMPLE 3:
Winding 1a: 110011001100
Winding 1b: 001100110011
Winding 2a: 011001100110
Winding 2b: 100110011001
time
DS00907A-page 2
AN907
Unlike in the first sequence described, two winding
halves are energized at one time in the second
sequence. This gives the motor more torque, but also
increases the power usage by the motor. Each of the
above sequences describes single stepping or
stepping the motor in its rated step size (in this case 30
degrees). Combining these two sequences allows for
half stepping the motor. The combined sequence is
shown in Example 4 (24 steps per revolution).
FIGURE 3:
EXAMPLE 4:
Winding 1a: 11000001110000011100000111
Winding 1b: 00011100000111000001110000
Winding 2a: 01110000011100000111000001
Winding 2b: 00000111000001110000011100
time
This method moves the motor in steps that are half its
rated step size. It is important to note that the torque
generated by the motor during this sequence is not
constant, as alternating steps have one and two halves
of a winding energized respectively.
Figure 2 illustrates the most basic unipolar motor. For
higher angular resolutions, the rotor must have more
poles. Permanent magnet rotors with 100 poles have
been made, and this pole count is commonly achieved
for hybrid rotors, using toothed end-caps on a simple
bipolar permanent magnet. When the rotor has a high
pole count, the stator poles are always toothed so that
each stator winding works against a large number of
rotor poles.
EXAMPLE 5:
Terminal 1a:
+ 0 -
Terminal 1b:
Terminal 2a:
0 + 0
Terminal 2b:
Terminal 1a:
+ + -
Terminal 1b:
- + + -
Terminal 2a:
+ +
Terminal 2b:
+ + -
0 + 0
- 0 + 0
0 + 0
0 + 0
- 0 + 0 -
0 + 0
0 + 0
-
0 +
time >
Bipolar Motors
Bipolar stepping motors are composed of two windings
and have four wires. Unlike unipolar motors, bipolar
motors have no center taps. The advantage to not
having center taps is that current runs through an entire
winding at a time instead of just half of the winding. As
a result, bipolar motors produce more torque than
unipolar motors of the same size. The draw back of
bipolar motors, compared to unipolar motors, is that
more complex control circuitry is required by bipolar
motors.
0 + 0
0 + 0
- + + -
- + + -
+ +
- + +
-
+ +
+ +
+ +
-
time >
DS00907A-page 3
AN907
Combining these two sequences into one sequence
will half step the motor so that it moves in 15 degree
increments. The sequence for half stepping the motor
is shown in Example 6 for one revolution or 24 steps.
FIGURE 4:
EXAMPLE 6:
Terminal 1a:
+ + 0 - - - 0 + + + 0 - - - 0 + + + 0 - - - 0 +
Terminal 1b:
- - 0 + + + 0 - - - 0 + + + 0 - - - 0 + + + 0 -
Terminal 2a:
0 + + + 0 - - - 0 + + + 0 - - - 0 + + + 0 - - -
Terminal 2b:
0 - - - 0 + + + 0 - - - 0 + + + 0 - - - 0 + + +
time >
Note:
Bifilar Motors
The term bifilar literally means two threaded. Motors
with bifilar windings are identical in rotor and stator to
bipolar motors with one exception each winding is
made up of two wires wound parallel to each other. As
a result, common bifilar motors have eight wires
instead of the four wires of a comparable bipolar motor.
Bifilar motors are driven as either bipolar or unipolar
motors. To use a bifilar motor as a unipolar motor, the
two wires of each winding are connected in series and
the point of connection is used as a center-tap. Winding
1 in Figure 4 shows the unipolar winding connection
configuration. To use a bifilar motor as a bipolar motor,
the two wires of each winding are connected in either
parallel or series. Winding 2 in Figure 4 shows the
parallel connection configuration. A parallel connection
allows for high current operation, while a series
connection allows for high voltage operation.
Hybrid Motors
Hybrid motors share the operating principles of both
permanent magnet and variable reluctance stepping
motors. The rotor for a hybrid stepping motor is multitoothed, like the variable reluctance motor, and
contains an axially magnetized concentric magnet
around its shaft (see Figure 5). The teeth on the rotor
provide a path which helps guide the magnetic flux to
preferred locations in the air gap. The magnetic
concentric magnet increases the detent, holding and
dynamic torque characteristics of the motor when
compared with both the variable reluctance and
permanent magnet types.
In terms of stepping the motor, hybrid motors are driven
like unipolar and bipolar motors. Refer to the previous
sections Unipolar Motors and Bipolar Motors
for a description of how to make a hybrid motor turn.
FIGURE 5:
DS00907A-page 4
AN907
CHOOSING A MOTOR
DS00907A-page 5
AN907
Functional Characteristics
Even when the type of motor is determined, there are
still several decisions to be made before selecting one
particular motor. Torque, operating environment,
longevity, physical size, step size, maximum RPM
these are some of the factors that will influence which
motor is chosen.
STEP SIZE
One of the most crucial decisions to make is the step
size of the motor. This will be determined by the
resolution necessary for a particular application. The
most common step sizes for PM motors are 7.5 and 3.6
degrees. This corresponds to 48 and 100 steps per
revolution respectively. Hybrid motors typically have
step sizes ranging from 3.6 degrees (100 steps per
revolution) to 0.9 degrees (400 steps per revolution).
Some stepping motors are sold with gear reductions
which provide smaller step angles than are possible
with even the finest stepping motors. Gear reductions
also increase the available torque, but because torque
falls with stepping rate, they decrease the maximum
rotational speed.
TORQUE
Torque is a critical consideration when choosing a
stepping motor. Stepper motors have different types of
rated torque. These are:
Holding torque The torque required to rotate the
motors shaft while the windings are energized.
Pull-in torque The torque against which a motor
can accelerate from a standing start without
missing any steps, when driven at a constant
stepping rate.
Pull-out torque The load a motor can move
when at operating speed.
Detent torque The torque required to rotate the
motors shaft while the windings are not
energized.
Stepping motor manufacturers will specify several or all
of these torques in their data sheets for their motors.
DS00907A-page 6
AN907
FIGURE 6:
Torque (N-m)
30
25
20
PULL-OUT
15
PULL-IN
10
5
0
0
500 1000 1500 2000 2500 3000 3500 4000 4500 5000
Speed (Steps Per Second)
LONGEVITY
Another factor to consider when choosing a motor is
the longevity of the motor. Some of the questions asked
should be:
How long does the motor need to work properly?
What environmental hazards will the motor be
subjected to?
What heat will the motor operate at?
Is the motors operation continuous or
intermittent?
Stepper motors by their very nature are more robust
than other types of motors because they do not have
brushes that will wear out over time. Typically, other
components in a particular system will wear out long
before the motor ever will. However, all stepper motors
are not created equal and even the best motors will fail
if the proper considerations are not made. The
following are some design guidelines that influence
motor longevity:
Ball bearings vs bronze bushings Ball bearings
last longer than bronze bushings and do not
generate as much heat, but they cost more.
Motors that run near their rated torque will not last
as long as those that do not. Motors should be
chosen so that they will run at 40-60% of their
torque rating.
Protect the motor from harsh environments.
Exposure, humidity, harsh chemicals, dirt and
debris will all take their toll on a motor.
Ensure adequate cooling. Motors generate heat
and this must be dissipated. For motors that
include an integral heat sink, ensure adequate
circulation of cooling air. Other motors are
designed to be cooled by conduction to the
chassis on which the motor is mounted. Hybrid
motors that sue rare-earth magnets are
particularly heat sensitive.
Variable Reluctance
Variable reluctance motors have multiple windings,
typically three to five, which are all tied together at one
end. The windings are turned on one at a time in a
particular sequence to turn the motor.
Figure 7 shows the basic circuit for driving a variable
reluctance motor. Note the diodes across the windings.
As with all inductive loads, as voltage is switched on
across a winding, the current in the winding begins
ramping up. When the switching MOSFET for the
winding is turned off a voltage spike is produced that
can damage the transistor. The diode protects the
MOSFET from the voltage spike assuming the diode is
adequately sized.
DS00907A-page 7
AN907
FIGURE 7:
To
Controller
Unipolar
The basic control circuit for a unipolar motor, shown in
Figure 8, is similar to that for a variable reluctance
motor. Note the extra diodes across each of the
MOSFETs. These are necessary because the inductor
is center tapped in unipolar motors. When one end of
the motor winding is pulled down, the other end will rise
and visa versa. These diodes prevent the voltage from
falling below ground across the MOSFETs.
FIGURE 8:
To
Controller
To
Controller
B
DS00907A-page 8
AN907
Bipolar
The basic circuit for driving the windings of a bipolar
motor is the H-bridge, shown in Figure 9. An H-bridge
can be configured to allow current to flow in either
direction across a winding. Referring to Figure 9,
current will flow from left to right in Winding 1 when
MOSFETs Q1 and Q4 are turned on while Q2 and Q3
are off. Current will flow from right to left when Q2 and
Q3 are on while Q1 and Q4 are off.
Note:
FIGURE 9:
Q5
Q7
To Controller
Q2
Winding 1
B1
C1
D1
Q4
Q6
Winding 2
Q8
A2
B2
To Controller
Q3
Q1
A1
C2
D2
DS00907A-page 9
AN907
MICROSTEPPING
In order to understand the fundamentals of microstepping, its necessary to look at the torque exerted by a
stepper motor as it turns. Figure 10 shows a graph of
torque verses rotor position for an ideal two-winding
stepper motor. Note the sinusoidal shape of the waveforms; in real motors, these waveforms will only be
approximately sinusoidal, and the sum of the torques
from the two windings will not be the perfect arithmetic
sum of the torques with just one or the other winding
powered.
FIGURE 10:
Holding Torque
1st Winding
2nd Winding
+3S
Combined
Windings
+6S
Angular Position
EQUATION 1:
T1 = Hsin(((/2)/S))
where T1 = torque of the first winding
H = holding torque
S = step angle, in radians
DS00907A-page 10
EQUATION 2:
T2 = Hcos(((/2)/S))
A technique referred to as sine-cosine microstepping
adjusts the current in each winding so the net torque is
constant. In an ideal motor, the torque produced by
each winding is proportional to the current in that
winding, and the torques add linearly. Saturation and
fringe-field effects make real motors non-ideal, but in
practice, they are close enough that we can ignore
these nonlinearities. As a result, if we want to hold the
motor rotor at the angle , we can do so by setting the
currents through the motor windings to the values given
in Equation 3 and Equation 4.
AN907
EQUATION 3:
I1 = IMAX cos(((/2)/S)/)
EQUATION 4:
I2 = IMAX sin(((/2)/S)/)
These equations assume that the current in the
windings will not exceed IMAX. The next section will talk
about current limiting considerations.
A second way to implement microstepping maximizes
torque in a bipolar stepping motor, though the torque is
not constant while the motor turns. In this method, one
winding is energized while the current flow in the other
winding is ramped down, reversed and then ramped up
Current
FIGURE 11:
1st Winding
+3S
+6S
+9S
2nd Winding
DS00907A-page 11
AN907
In an ideal motor, microstepping can be used to achieve
arbitrarily fine angular resolution, but in practice friction
and departures from the ideal sinusoidal torque versus
shaft angle curve make this impractical. In practice, it is
rarely worthwhile to subdivide each motor step into
more than 32 microsteps, and even this is generous!
Using 32 microsteps per step, we can step in
increments of 0.23 degrees using an inexpensive
permanent magnet motor with 7.5 degrees per step.
We could achieve the same resolution using 1:32
reduction gearing, but this introduces backlash and it
reduces the maximum speed. Compared to microstepping, gearing has the benefit of increasing the torque
and position-holding stiffness of the motor.
Microstepping Limitations
The previous discussion assumed an ideal two winding
stepping motor. There are several factors that affect the
linearity of microstepping in real motors. The first
limitation is static friction in the system. Figure 10
shows a graph of torque verses position of the motor
shaft. Figure 12 shows this same graph (for one
winding) with the dotted lines representing the effect
static friction has on the system. Redrawing the graph
in Figure 12 to show only the available torque for a
single winding results in the graph shown in Figure 13.
Note the resulting dead zone between the zones of
available torque. Also note that the magnitude of torque
overall is less than the ideal case.
Holding Torque
FIGURE 12:
+1S
+2S
+3S
+4S
+5S
+6S
+7S
+8S
+7S
+8S
Angular Position
Holding Torque
FIGURE 13:
+1S
+2S
+3S
+4S
+5S
+6S
Angular Position
DS00907A-page 12
AN907
The dead zone has an impact on microstepping
because it limits the angular resolution of the stepping
motor. It also makes it impossible to produce perfectly
smooth transitions between steps.
Another limitation to microstepping is the fact that the
torque verses position curve is not perfectly sinusoidal
for real motors. The toothed shape of the rotor and
other physical characteristics of the motor contribute to
this. Figure 14 shows a plot of actual position vs.
expected position for a typical motor.
FIGURE 14:
CURRENT LIMITING
Stepping motors are often run at voltages higher than
their rated voltage. Although this is not necessarily the
case for very small stepper motors, high torque stepper
motors need to run at higher voltages in order for the
motor to reach its full potential. Increasing the voltage
supplied to a motor increases the rate at which current
rises in the windings of the motor. The more responsive
current in the windings, the greater the torque and
speed characteristics of the motor. This section will
explain why performance is boosted and what role
current limiting plays in this process.
FIGURE 15:
RESISTIVE-INDUCTIVE
WINDING MODEL
t = t1
R
Motor/Winding
L
FIGURE 16:
Current
WINDING CURRENT VS
TIME
dI (t = 0) = V
L
dt
IMAX = V
R
IMAX
Time
t = t1
dI (t = t ) = V
1
L
dt
DS00907A-page 13
AN907
The current rises exponentially until IMAX is reached.
Current as a function of time is given by:
EQUATION 5:
I(t) = (V/R) (1 - e-t R/L)
The instantaneous rate that current rises when voltage
is first applied is given by:
EQUATION 6:
dI/dt(t = 0) = V/L
Ohms law governs the maximum current level.
In-series Resistance
The first way to increase the supply voltage without
exceeding IMAX is to connect a power resistor in series
with each winding of the motor. Figure 17 shows this
circuit. In the circuit shown, the magnitude of the supply
voltage is tripled (2V). This requires that a power
resistor equivalent to two times the internal resistance
of the winding (R) be added. This brings the total
resistance of the circuit to 2R. Notice the resistance
and voltage are increased proportionally so that
Equation 3 is still satisfied and IMAX is unchanged (i.e.,
IMAX = 2V/2R = V/R).
FIGURE 17:
EQUATION 7:
IMAX = V/R
EQUATION 8:
I(T) = (V/R) E-(T-T1) R/L
The instantaneous rate that the current drops when
voltage is removed is given by:
EQUATION 9:
dI/dt = -V/L
These equations show that current rises and falls for a
given winding as a function of the supply voltage and
the internal resistance of the winding. It is important to
understand this relation when applying a higher than
specified voltage to a stepping motor. The reason it is
important is that the current in the windings of a
stepping motor must never exceed the maximum
specified current (IMAX)(1). Running a motor at high
voltage but not taking into consideration current
limitations can be very detrimental to motor life, the
driver circuitry, and the well being of people who come
in contact with the motor (the motor gets really hot!).
V +-
V +-
FIGURE 18:
Current
CURRENT VS TIME
IMAX = V = 2V
R
2R
2
1
Time
DS00907A-page 14
AN907
Another drawback of using a power resistor is that it
does not optimize the rise time of the current in a
winding. Referring to Equation 5 again, increasing
resistance has an adverse affect on the rise time.
Though increasing the voltage supply and resistance
proportionally produces a better rise time than not
increasing either, it would be ideal to increase the
supply voltage without adding resistance in series with
the winding. So how can the supply voltage be
increased without the addition of resistance and the
current still not rise above the motors rated IMAX? The
answer is to use two supply voltages.
FIGURE 20:
FIGURE 19:
V +V +-
Current
2V
R
IMAX = V
R
2
Time
Chopper Control
V +-
CURRENT VS TIME
EQUATION 10:
D = VNOMINAL/VSUPPLY
Where VNOMINAL = IMAX/r
A comparison of current and the voltage applied to the
winding over time is shown Figure 21.
DS00907A-page 15
AN907
FIGURE 21:
Winding Current
Time
Supply Voltage
As Figure 21 indicates, the voltage supply is switched
on until IMAX is reached. Thereafter, the voltage is
modulated to limit the current in the winding to IMAX.
Time
EQUATION 11:
VCONTROL = RSENSE IMAX
In practice, the sense resistor should be as small as
possible while still allowing VCONTROL to be easily
measurable. Values of VCONTROL between 0.6 volts
(one silicon diode drop) and 5 volts are common, and
sense resistances on the other of 1/2 or 1 ohm are
common. Generally, the voltage across RSENSE should
not exceed 10% of the supply voltage! For very high
current motors, current sensing using Hall-effect
sensors and other advanced technologies can greatly
reduce losses from current sensing.
DS00907A-page 16
AN907
FIGURE 22:
CHOPPER CIRCUIT
VSUPPLY
To Control A
B To Controller
RSENSE
Comparator
VCONTROL
TABLE 1:
Step
Angle
Voltage
Current
Resistance
Inductance
Holding
Torque
Rotor
Inertia
Number
of Leads
Deg
A/Phase
Ohm/Phase
mH/Phase
kg-cm
g-cm2
LEAD
kg
1.8
1.8
4.5
0.4
0.96
16
570
1.4
Weight
DS00907A-page 17
AN907
Notice the voltage specification 1.8V. Running the
motor at this voltage will yield terrible performance in
terms of speed and torque. High performance
stepping motors are intended to be driven at higher
voltages with current limiting considerations.
As discussed earlier, motor windings have some
internal resistance (R). This resistance is a function of
wire diameter, the number of turns and the resistivity of
the winding material. This resistance is ultimately what
determines the maximum current that a winding should
be subjected to. The power loss of a winding is given
by:
EQUATION 12:
PLOSS = R IMAX2
The maximum current allowed in a motor winding must
not overheat the motor, it must not drive the magnetic
circuits into saturation and it must not produce motor
fields that are sufficient to demagnetize the motor rotor.
In a well designed permanent magnet motor, when
both motor windings are run at IMAX and the motor is
properly mounted and ventilated, it will be very close to
both its thermal and magnetic limits. This is why it is so
critical that the drive circuitry should never permit
currents exceeding IMAX.
The voltage specification given on motor data sheets is
simply the maximum voltage across a motor winding
that will produce a current equal to IMAX given the
internal resistance of the winding. As stated earlier,
IMAX is the critical specification for a motor that should
not be exceeded. The voltage specification for a motor
is simply the voltage that will produce a current equal to
IMAX given the internal resistance of the winding.
Equation 7 shows this relation. Referring to Table 1,
multiplying current per phase by the ohms per phase
results in the rated voltage.
BASIC MICROCONTROLLER
STEPPING MOTOR CONTROL
This section discusses using PIC microcontrollers for
stepper motor control. There are several peripherals
available on Microchip parts that make controlling a
stepping motor more precise. Any PIC microcontroller
can be used to control a stepper motor. However,
depending on the complexity of the control desired (i.e.,
microstepping and current limiting), it can be very
advantageous to choose a microcontroller with select
peripherals that will take care of most of the stepper
motor overhead.
DS00907A-page 18
Note:
AN907
FIGURE 23:
Winding2
Winding1
CCP1 13
VDD
20 VDD RB1 22
8 VSS CCP2 12
19 VSS RB2 23
PIC16F73
FIGURE 24:
VDD
RC3 7
1
VDD RA1 5
14 VSS
8
RC7
6
RB1
VDD
1 1A
2 1B
3 2A
4 2B
5 3A
6 3B
PIC16F684
8 4A
9 4B
14
VDD
1Y 13
2Y 12
3Y 11
4Y 10
GND
7 TC4469
Winding2
U2
U1
Winding1
VSUPPLY
DS00907A-page 19
AN907
COMPARATORS
REFERENCES
The current limiting section discussed how comparators can be used in chopper circuits. Several PIC
microcontrollers have on-chip comparators that can be
used to accomplish this task. The comparators can be
used to chop the input directly in hardware or can
generate a software interrupt in the microcontroller
indicating IMAX has been reached. When an interrupt is
generated, the PIC microcontroller can modulate the
voltage across the winding so that the average voltage
equals the nominal voltage for the phases of the
stepping motor. This functionality can be accomplished
by a CCP or ECCP module.
A/D CONVERTERS
The same functionality just discussed can also be
accomplished by feeding the output of the sense resistor into a PIC A/D converter by way of an operational
amplifier. The way this works is the A/D converter is
read continually by the microcontroller. When the value
generated by the A/D converter indicates IMAX is
reached, the microcontroller will modulate the voltage
across the winding so that Vnominal is maintained.
Note:
CONCLUSION
Stepper motors are ideally suited for measurement and
control applications. The step resolution and
performance of these motors can be improved through
a technique called microstepping. Stepping motor performance can also be improved by driving these motors
at a voltage greater than what they are rated for. If
higher voltage is used to boost performance, then
current limiting considerations must be taken into
account.
PIC microcontrollers are able to drive all the different
types of stepping motors: variable reluctance,
permanent magnet and hybrid. Single-stepping, halfstepping, microstepping and current limiting are all
stepper motor drive techniques that are well within the
utility of PIC microcontrollers. The CCP, ECCP and
comparator modules available in Microchips microcontroller line allow for the implementation of the more
advanced stepping motor control techniques, namely
microsteppng and current limiting. In summary, PIC
microcontrollers are an ideal choice for stepping motor
control.
DS00907A-page 20
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip's Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart and rfPIC are registered
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
AmpLab, FilterLab, microID, MXDEV, MXLAB, PICMASTER,
SEEVAL, SmartShunt and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Application Maestro, dsPICDEM, dsPICDEM.net,
dsPICworks, ECAN, ECONOMONITOR, FanSense,
FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP,
ICEPIC, Migratable Memory, MPASM, MPLIB, MPLINK,
MPSIM, PICkit, PICDEM, PICDEM.net, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, rfLAB, Select Mode,
SmartSensor, SmartTel and Total Endurance are trademarks
of Microchip Technology Incorporated in the U.S.A. and other
countries.
Serialized Quick Turn Programming (SQTP) is a service mark
of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
2004, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
DS00907A-page 21
China - Beijing
Korea
Corporate Office
Unit 706B
Wan Tai Bei Hai Bldg.
No. 6 Chaoyangmen Bei Str.
Beijing, 100027, China
Tel: 86-10-85282100
Fax: 86-10-85282104
China - Chengdu
Boston
China - Fuzhou
Atlanta
Chicago
333 Pierce Road, Suite 180
Itasca, IL 60143
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
4570 Westgrove Drive, Suite 160
Addison, TX 75001
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Tri-Atria Office Building
32255 Northwestern Highway, Suite 190
Farmington Hills, MI 48334
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
2767 S. Albright Road
Kokomo, IN 46902
Tel: 765-864-8360
Fax: 765-864-8387
Los Angeles
18201 Von Karman, Suite 1090
Irvine, CA 92612
Tel: 949-263-1888
Fax: 949-263-1338
San Jose
1300 Terra Bella Avenue
Mountain View, CA 94043
Tel: 650-215-1444
Fax: 650-961-0286
Toronto
6285 Northam Drive, Suite 108
Mississauga, Ontario L4V 1X5, Canada
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Australia
Suite 22, 41 Rawson Street
Epping 2121, NSW
Australia
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
Singapore
Taiwan
Kaohsiung Branch
30F - 1 No. 8
Min Chuan 2nd Road
Kaohsiung 806, Taiwan
Tel: 886-7-536-4818
Fax: 886-7-536-4803
Taiwan
Taiwan Branch
11F-3, No. 207
Tung Hua North Road
Taipei, 105, Taiwan
Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
EUROPE
China - Shanghai
Austria
Durisolstrasse 2
A-4600 Wels
Austria
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark
China - Shenzhen
China - Shunde
Room 401, Hongjian Building, No. 2
Fengxiangnan Road, Ronggui Town, Shunde
District, Foshan City, Guangdong 528303, China
Tel: 86-757-28395507 Fax: 86-757-28395571
China - Qingdao
Rm. B505A, Fullhope Plaza,
No. 12 Hong Kong Central Rd.
Qingdao 266071, China
Tel: 86-532-5027355 Fax: 86-532-5027205
India
Divyasree Chambers
1 Floor, Wing A (A3/A4)
No. 11, OShaugnessey Road
Bangalore, 560 025, India
Tel: 91-80-2290061 Fax: 91-80-2290062
Japan
Benex S-1 6F
3-18-20, Shinyokohama
Kohoku-Ku, Yokohama-shi
Kanagawa, 222-0033, Japan
Tel: 81-45-471- 6166 Fax: 81-45-471-6122
France
Parc dActivite du Moulin de Massy
43 Rue du Saule Trapu
Batiment A - ler Etage
91300 Massy, France
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Germany
Steinheilstrasse 10
D-85737 Ismaning, Germany
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Italy
Via Quasimodo, 12
20025 Legnano (MI)
Milan, Italy
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands
P. A. De Biesbosch 14
NL-5152 SC Drunen, Netherlands
Tel: 31-416-690399
Fax: 31-416-690340
United Kingdom
505 Eskdale Road
Winnersh Triangle
Wokingham
Berkshire, England RG41 5TU
Tel: 44-118-921-5869
Fax: 44-118-921-5820
01/26/04
DS00907A-page 22
Freescale Semiconductor
Application Note
AN2974
Rev. 1, 06/2005
Introduction
This application note is for novices who want a general quick-start guide showing how to control a stepper
motor. Because stepper motors can be used in a variety of ways and are driven by a variety of devices,
there is a great deal of information available about how these motors work and how to use them. To
reduce confusion, the focus of this application note is on stepper motors that can be driven by
microcontrollers. This document includes basic information needed to get started quickly, and includes a
practical example that is simple and easy to implement.
STEPPER MOTOR
HCS12
MICROCONTROLLER
CONTROL
1a)
CONTINUOUS ROTATION
DC MOTOR
HCS12
MICROCONTROLLER
CONTROL
1b)
Permanent-magnet (PM) stepper motor This kind of motor creates rotation by using the
forces between a permanent magnet and an electromagnet created by electrical current. An
interesting characteristic of this motor is that even when it is not powered, the motor exhibits some
magnetic resistance to turning.
Variable-reluctance (VR) stepper motor Unlike the PM stepper motor, the VR stepper motor
does not have a permanent-magnet and creates rotation entirely with electromagnetic forces. This
motor does not exhibit magnetic resistance to turning when the motor is not powered.
Freescale Semiconductor
What is Inside?
What is Inside?
Generally, a stepper motor consists of a stator, a rotor with a shaft, and coil windings. The stator is a
surrounding casing that remains stationary and is part of the motor housing, while the rotor is a central
shaft within the motor that actually spins during use. The characteristics of these components and how
they are arranged determines whether the stepper motor is a PM or VR stepper motor. Figure 2 and
Figure 3 show an example of these internal components.
SIGNAL B
CURRENT
i
+
S
N
SIGNAL A
COIL
WINDING
ROTOR SHAFT
COMING OUT OF
PAGE
PERMANENT MAGNET
DISK WITH TWO POLES
DIRECTION OF
MAGNETIC FIELD
Taking a closer look, the rotor in PM stepper motors is actually a permanent-magnet. In some cases, the
permanent magnet is in the shape of a disk surrounding the rotor shaft. One arrangement is a magnetic
disk which consists of north and south magnetic poles interlaced together. The number of poles on the
magnetic disk varies from motor to motor. Some simple PM stepper motors such as the one in Figure 2
only have two poles on the disk, while others may have many poles. The stator usually has two or more
coil windings, with each winding around a soft metallic core.
When electrical current flows through the coil windings, a magnetic field is generated within the coil. The
metallic core is placed within the coil windings to help channel the electromagnetic field perpendicular to
the outer perimeter of the magnetic disk.
What is Inside?
Depending upon the polarity of the electromagnetic field generated in the coil (north pole, out of the coil,
or south pole, into the coil) and the closest permanent magnetic field on the disk, an attraction or repulsion
force will exist. This causes the rotor to spin in a direction that allows an opposite pole on the perimeter
of the magnetic disk to align itself with the electromagnetic field generated by the coil. When the nearest
opposite pole on the disk aligns itself with the electromagnetic field generated by the coil, the rotor will
come to a stop and remain fixed in this alignment as long as the electromagnetic field from the coil is not
changed.
VR stepper motors work in a very similar fashion. Figure 3 shows some of the physical details that
characterize its operation. In a VR stepper motor, the surrounding coils that are physically located
opposite of each other are energized to create opposite magnetic fields. For example, in Figure 3a), coil
C produces a south-pole magnetic field, and coil C produces a north-pole magnetic field. The magnetic
fields produced by the coils pass through the air gap and through the metallic rotor. Because the magnetic
fields attract each other, the metallic rotor spins in a direction that brings the nearest edges (2 and 4) of
the rotor as close as possible to the pair of energized coils (C and C). Like the PM stepper rotor, the VR
stepper rotor will remain aligned to the coils as long as coils C and C are energized and the magnetic
fields are not changed. To move to the next state and continue this rotation, coils C and C must be deenergized, while coils A and A must be oppositely energized to attract rotor edges 1 and 3 respectively.
The same process occurs with coils B and B to attract rotor edges 2 and 4 respectively, and so on.
Figure 3 shows how the rotor spins as the coils are energized and de-energized. This is an example of a
3-phase VR motor.
1
4
3b)
4
3
2
C
3a)
3c)
From the examples discussed earlier, we can see that if the electromagnetic fields in both the PM and VR
stepper motors are turned on, off, and reversed in the proper sequence, the rotor can be turned in a
specific direction. Each time an electromagnetic field combination is changed, the rotor may turn a fixed
number of degrees. As these state changes in electromagnetic fields take place more rapidly, on the order
of milliseconds, the rotor can rotate faster, smoother, and sometimes more quietly. Because of the
mechanical limitations of the system, the rotor can only rotate effectively up to certain speeds.
An external device, such as an HCS12 microcontroller (or, MCU), is very good for controlling the
electromagnetic sequences by directing the flow of current through the coil windings. To do this, software
can be written and loaded into an HCS12 MCU.
Freescale Semiconductor
NOTE
The orientation of the rotor prior to energizing a single coil may be
unknown. It is possible that, for example, the rotor could be positioned, as
shown in Figure 7c), when attempting to align itself, as in Figure 7a).
Figure 7c) is the worst case starting position for the desired alignment,
shown in Figure 7a). It is even possible that initially the rotor may not turn
because the magnetic forces of the coil could be equally divided over
pushing and pulling the north and south pole of the PM disk. If this happens,
then moving to the next sequential step by energizing both coils should help
jolt the rotor free.
+5V
0V
PORT PIN
SIGNAL a
+5V
COIL
SIGNAL
A
time
PORT PIN 0 V
SIGNAL a
time
+5V
COIL
SIGNAL
B
0V
PORT PIN
SIGNAL b
+5V
4a)
0V
PORT PIN
SIGNAL b
time
time
6
+5V
0V
COIL SIGNAL A
time
5V
+5V
0V
COIL SIGNAL B
time
5V
4b)
While coil signal A is positively energized, the next transition occurs in coil signal B. Coil signal B rises
and positively energizes coil B, creating its own electromagnetic field. Electric current flows into terminal
b and out of terminal b. The north-pole of both coils now share an attraction for the south-pole of the disk,
causing the disk to realign (rotate) itself between shared attractions. The same action takes place with
the south-pole of the coils and north-pole of the PM disk.
Freescale Semiconductor
For the next transition, coil signal A falls to zero, leaving the signal in coil B to dominate the alignment of
the PM disk.
In summary, coils A and B take turns controlling the PM disk. Before one coil releases full control of the
disk, it shares control of the disk with the other coil. This temporary sharing creates a half-step in the
transition of control from one coil to the next (half-stepping) and allows smaller, discrete turns to be taken
by the motor. Although stepper motors are often used for their ability to make discrete movements, they
can also be used for smooth movements. In an ideal case, the waveforms that would allow the smallest
incremental change would actually be sinusoidal to ensure the smoothest transition between full steps.
In such a case, the distinction between states and specific steps become blurred. This implementation
may be well suited for applications that seek to reduce or eliminate the discrete movement of the motor,
which also reduces noise and vibration. This technique is often referred to as microstepping. Although the
digital waveforms in this example are not sinusoidal, their similarities to a sinusoidal waveform can still
be noted by comparing Figure 4 and Figure 5. A series of electromagnet changes over the period of both
signals continue to work together in this fashion to rotate the PM disk.
+5V
COIL SIGNAL A
0
Smooth state transitions
produce smooth rotor
movement for stepper
motors.
time
5V
+5V
COIL SIGNAL B
0
time
5V
Freescale Semiconductor
3
0
2
0
a a
1 0
1 0
STEPPER MOTOR
a
With an appropriate algorithm, we can use pins U[3:0] of the HCS12 to produce the waveforms needed
to drive a stepper motor. The general flow of the algorithm can be similar to the flow of a state machine,
which is to set the bits in register U to a particular state or configuration, wait a discrete amount of time,
and set the bits in register U to the next state. For each change in the microcontroller register state, a
change is produced in the waveform that causes the motor to rotate a fixed amount. The period of time
required between register states will vary depending upon the motor and the performance desired, but is
usually on the order of milliseconds. If the delay between changes to the microcontroller register states
is too short, the motor will not physically be able to move fast enough to keep up with the register state
changes. A delay that is too long could create a motor response with noticeably rigid movements and
choppy noises with each step. However, for the purpose of this application note, it may be helpful to have
a long delay between register states because it allows easy observation of the motor response and
movement due to microcontroller register changes.
An easy way to begin driving the motor is to focus on getting the motor to move a single step at a time,
in the direction desired instead of many steps at once. Tracing through an algorithm with a software
debugger, if a debugger is available, is a way of slowing the algorithm down so the response of the motor
can be observed. After motor movement has been achieved, direction reversal can be accomplished by
switching the microcontroller connections to one of the motor coils.
Figure 7 illustrates example microcontroller register contents from state 0 to state 3, It also shows the
matching PM stepper motor configuration that might occur in that state. Figure 7 also corresponds with
the graph in Figure 4 and the drawing in Figure 6.
STATE 1
5
b
3
0
b
2
0
a a
1 0
1 0
STATE 2
5
b
3
1
b
2
0
STATE 3
5
b
2
0
b
3
1
a a
1 0
0 0
b
2
0
b
3
1
a a
1 0
0 1
7b)
COIL SIGNAL B
b +
b
a
+
N
COIL
SIGNAL A
COIL SIGNAL B
b +
b
i
7a)
COIL SIGNAL B
b +
b
i
COIL
SIGNAL A
a a
1 0
1 0
COIL SIGNAL B
b +
b
a
COIL
SIGNAL A
COIL
SIGNAL A
7c)
7d)
STATE 0
Below is an example of a program that performs half-stepping and can be used to drive a stepper motor.
The code turns the motor a number of steps (100 half-steps) in one direction, and then turns the motor
back the same number of steps in the opposite direction. One of the advantages of the code below is that
it can be easily modified to keep track of a motors position. It also has the advantage of having the port
states stored in sequential order in an array. Simply cycling through the states sequentially and placing
the state values on port pins will cause a stepper motor to move. This is written in C.
#define NUM_OF_STATES 8 //There are 8 different states in this particular example.
#define DELAY_MAX 2000 //The maximum # of counts used to create a time delay.
void main(void)
{
/*******************CREATE VARIABLES*******************/
int i; //Used in a for loop
//This array actually contains the state values that will be placed on Port U.
//State #0 corresponds to a value of 0x06, state #1 corresponds to a value of 0x02, etc.
char state_array[NUM_OF_STATES] = {0x06, 0x02, 0x0A, 0x08, 0x09, 0x01, 0x05, 0x04};
int steps_to_move; //The # of rotational steps the motor will make.
char next_state;
//Used to select the next state to put in register U.
/********************SET UP PORT U********************/
DDRU = 0xFF;
//Writing 0xFF to DDRU sets all bits of Port U to act as output.
PTU = 0;
//Init Port U by writing a value of zero to Port U.
/******************************************************/
steps_to_move = 100; //Set the # of steps to move. An arbitrary positive # can be used.
next_state = 0;
PTU = state_array[next_state];
Freescale Semiconductor
{
next_state = 0;
}
PTU = state_array[next_state]; //Place new value in Port U. Rotation may be observed
for(i = 0; i < DELAY_MAX; i++)
{
//Wait here for a while.
}
next_state++;
//Increment next_state. Cycling though the states causes rotation
//in one direction. Decrementing states causes opposite rotation.
steps_to_move--;
}
//The following code rotates the motor back in the opposite direction.
steps_to_move = 100;
while (steps_to_move > 0)
{
if (next_state < 0)
{
next_state = (NUM_OF_STATES - 1);
}
PTU = state_array[next_state];
for(i = 0; i < DELAY_MAX; i++)
{
//Wait here for a while.
next_state--;
steps_to_move--;
}
} //End of Main
11
WITH FEEDBACK
DETECTION
(FEEDBACK)
MICROCONTROLLER
OR
MOTOR DRIVER
MOTOR
ROTOR
OR
GEAR
OTHER
SYSTEM
Freescale Semiconductor
13
Freescale Semiconductor
15
AN2974
Rev. 1, 06/2005
Limits to system
performance
Torque and output power
The output torque and power from a
stepper motor are functions of the
motor size, motor heat sinking, working duty cycle, motor winding, and
the type of driver used. In applications with low damping, the usable
torque from the stepper motor can be
drastically reduced by resonances.
70
4.8W
60
4,5
50
3
40
30
1,5
20
10
0.8W
0
0
500
1000
1500
Full-step stepping rate [Hz]
Torque PBL3770:
Torque L/R
2000
0
2500
Figure 1. Pull-out torque and output power for a 57 mm PM stepper driven by a unipolar L/R-driver and a PBL 3770A bipolar
constant current driver.
Motor is no-load
unstable for
stepping rates
above 325Hz.
4.5
3
40
30
1.5
20
10
0
0.8W
0
0
500
1000
1500
Full-step stepping rate [Hz]
Pull-out Torque
Efficiency
Output Power
Drawbacks
Lowest motor output power.
Applications
Low speed and low power applications were the motor mainly is
used to produce a torque.
Normally only used with small size
motors.
Cost
In high-volume applications, the major
cost is the hardwareincluding
power supply, driver, wiring, motor,
and gearing. In this case, the engineering cost is less important. In many
applications, it is possible to lower the
total system cost and increase the
performance by using a more-complex
driver (with a slightly higher cost) and
less-costly motor and power supply.
In low- and medium-volume applications, the engineering cost becomes
a larger part of the total cost. In this
case the flexibility and high integration of a constant current driver can
help save engineering time and cost.
Dynamic characteristics
In applications were the stepper must
move from one position to another
then stop in the shortest possible
time, the settling time becomes a very
important factor. If the system is
designed properly, the settling time
can be kept to a minimumif not,
the settling time can easily require
several hundred milliseconds.
To get good dynamic behavior in
an open loop system, it is important
to have the correct gear rate and
precise control of the motor running
and holding torque. With welldesigned gearing, it is possible to
handle variations in both load inertia
and friction.
Performance of drivers
In the following section, the performance of some commonly-used driver
configurations are compared when
they drive a 57mm 7.5-degree PMstepper motor. Driving voltage/
currents are selected so the stand-still
motor losses are kept at maximum
rated 7 W. The performance curves
show the pull-out torque, output
power (at the motor shaft), and the
system efficiency. Efficiency is defined
as the mechanical output power from
the motor divided by the input power
to the driver. For each driver, features
and drawbacks are also listed.
Unipolar constant voltage
This is the classic low-end driver. It
offers the lowest price for the driver
electronicsonly four transistors are
used. To drive small-sized motors, a
transistor array of ULN 2003 or
similar type can be used. For midsized motors, power darlington
transistors, or transistor arrays can be
used. In figure 2, the performance of
this type of driver is shown. A motor
winding with 100 ohm phase
resistance has been selected. This
gives good control of winding current
and low losses in power transistors.
With this driver, the motor has
problems with no-load instabilities at
stepping rates above 325Hz.
20
10
0
1.7W
0
0
500
1000 1500
Full-step stepping rate [Hz]
Pull-out Torque
Efficiency
Output Power
Drawbacks
Low or very low efficiency. Lower
efficiency the higher Rext/R ratio.
Applications
Low and medium speed and low
power applications.
2.5W
30
1.5
20
10
0
0
500
1000
1500
Full-step stepping rate [Hz]
Pull-out torque
Efficiency
Output Power
Drawbacks
Applications
Drawbacks
Only 70% of holding and low speed
torque compared to bipolar constant
current.
Power transistors have to withstand
twice the maximum supply voltage.
Winding leakage inductance have
to be considered when snubbing
circuit is designed.
6 lead wires add cost and space for
motor connectors and flexible
cables.
Applications
High speed and medium power
applications.
6
4.8W
70
60
4.5
50
40
30
20
1.5
10
0
0
0
2500
1250
Full-step stepping rate [Hz]
Pull-out Torque
Efficiency
Output Power
Drawbacks
Applications
Drawbacks
Same as for the bipolar constant
current, plus:
Applications
For small and medium size motors
highly integrated drivers are
available.
High speed and high power
applications.
Applications were increased
resolution is required.
Applications were resonance free
low speed characteristics is needed.
Performance of motors
The maximum output torque and
power from a stepper motor is limited
by the power losses of the motor. For
low stepping rates, most of the losses
are related to resistive losses in the
motor winding. At higher stepping
rates the hysteresis and eddy-current
losses become the major ones.
Especially for low-cost tin-can PMsteppers, these losses can be high
because of the absence of laminations
and the use of low performing
magnetic materials of the stator and
rotor flow path.
From the above driver comparisons,
we can see that the maximum torque,
efficiency, and output power from a
given motor is achieved with the bipolar chopper driver. We will now
examine the performance of some
commonly-used stepper motor types
when they are driven with a bipolar
chopper drive.
A drop in performance, similar that
of the 57mm PM-motor used above,
can be expected when other types of
drivers are used.
57mm PM motor
PM-motors are a cost-effective alternative in many low- and mediumperforming applications. The motors
uses slide bearings and a simple
mechanical design to keep cost low.
Compared to hybrid motors, the life
expectancy is shorter, step accuracy
and efficiency is lower. The slide
bearing can also cause problems if a
belt drive is applied directly to the
motor shaft.
The 57mm PM-motor is. for instance, suitable to use as paper feed
and carriage drive motor in mediumperformance matrix or daisy printers
and in typewriters. Other applications
are fax machines, sewing machines,
valve controls, and plotters.
Other popular PM-motor sizes are
35mm and 42mm. 20mm, 25mm and
63mm motors are also common PM
motor sizes. The 20mm motor is popular as a head driver in 312" floppydisk drive applications. Commonlyavailable full-step angles are 7.5 and
15 degrees but others are also available (9, 11.25, and 18 degrees, for
examples).
In figure 6, the performance of this
motor is shown again. The power loss
120
12W
12
100
10
80
AA
A
A
A
A
A
A
AA
A
A
A
A
AAAA
A
60
4.8W
40
37%
20
0
500
1000
1500
Pull-out Torque
0
2500
2000
Power losses
Figure 6. Performance curves for a 3.75 ohm bipolar 57 mm PM-motor driven by PBL
3770A constant-current driver. Power losses in motor and driver are also shown
(Chopper voltage 20 V, winding current 960 mA).
120
12
100
10
80
60
40
20
0
AA
AA
A
A
A
AA
A
A
A
A
AA
A
A
A
AA
AA
AA
A
8
7.3W
65%
4
2
1000
2000
3000
4000
0
5000
Pull-out Torque
Efficiency
Output Power
Power losses
Figure 7. Performance curves for a 25 ohm bipolar 42 mm square hybrid stepper driven
by PBL3770A constant-current driver (Chopper voltage 40V, winding current 280mA)
160
140
120
100
80
60
40
20
0
0
31W
32
28
24
20
16
12
8
4
0
5000
AA
A
A
AA
A
A
A
A
AA
A
A
A
AA
AAAA
A
AA
A
66%
1000
65%
2000
3000
4000
Pull-out torque
Efficiency
Output Power
Power losses
Figure 8. Performance curves for a 2.8 ohm bipolar 57 mm hybrid stepper (length 42mm)
driven by PBL 3770A constant-current driver (Chopper voltage 40V, winding current
75mA).
Holding torque [mNm]
450
Hybrid holding torque
Hybrid DC-losses
PM holding torque
300
PM DC-losses
150
0
0
DC-losses [W]
18
12
284mNm
84mNm
200
400
600
1400
1600
1800
Figure 9. Holding torque and DC-loss as functions of winding currents for a 57mm PM
motor and for a 57mm hybrid motor.
Designing a system
Analyzing the load
When designing a stepper motor system, the first question to ask is What
12
120
100
10
8.4W
80
AA
AAA
A
A
A
A
A
A
A
A
AA
AA A
AAA
A
60
4.3W
40
34%
20
0
0
500
1000
1500
0
2500
2000
Pull-out Torque
Efficiency
Output Power
Power losses
Figure 10. Performance curves for a 3.75ohm bipolar 57mm PM-motor driven by
PBL3770A constant-current driver. (Chopper voltage 20V, winding current 480mA).
12.1W
120
12
100
80
60
40
20
10
AA
AA
AA
AA
AAAA
AAAA
AAAAA
AAA
AA AA
AAA
A
0
0
5.5W
6
4
34%
500
1000
1500
2000
2500
Pull-out Torque
Efficiency
Output Power
Power losses
Figure 11. Performance curves for a 3.75ohm bipolar 57mm PM-motor driven by
PBL3770A constant-current driver. (Chopper voltage 25V, winding current 600mA).
10
Selecting concept
After analyzing the load, we know the
output power needed, the maximum
and minimum stepping rates, and the
resolution needed.
Depending on the importance of
the different demands and the ability
to fulfill them, the designer has a
range of options in combining motor
gearing and driver in a system.
The design is normally an iterative
process, with calculation and experimentation. If highest-performance or
lowest-cost for a given performance is
essential, it is a good idea to compare
a few different combinations of motor
driver and gearing.
A higher-step-rate driver and a
smaller motor, together with a
suitable gearing, often gives better
performance in efficiency and
output powerthan a large motor
driving the load directly.
Motor selection
Output power
This is the most important design
criteria in getting the best price/
performance of a stepper motor
system. Compare the power requirements of the load with the data given
above, or with the data in the manufacturers data sheet. If the manufacturers data sheet is used be aware
of the big differences in performance
of the stepper motors due to different
drivers. Also remember that measuring stepper motor pull-out and pullin torque is tricky. The measurement
is easily influenced by inertia and
resonances in the measuring system,
and the inertia and damping of the
application is normally different. As a
result, the pull-out curves in the data
sheet are not always valid for an actual
application.
Mechanical aspects
The physical dimension and weight of
the motor are important criteria when
a motor is selected. Often the choice
of a smaller motor can make a
Single- or double-sided
Length
Pinions
Winding Resistance
Inductance
Rotor
Type of magnets
hybrid air-gap distance
Driver design
Selecting driver type
The performance curves at the beginning show the effect of the driver on
the system. If only low stepping rates
are used and the use of gearing is not
a solution, the unipolar L/R-driver
offers the lowest cost for the electronics for a given output torque.
As demand for output power from
the stepper increases, more-effective
drivers offer the best price performance ratio. The best motor utilization is achieved with the bipolar
constant current driver and this driver
is the obvious choice for all highpower applications.
For applications in the low- and
medium-power range, several alternatives exists. If system efficiency is
important, then the bipolar constant
current driver is the best choice. This
driver offers higher flexibility in
selecting the motor winding, since
both the chopper voltage and the
current in the winding can be
changed to get the desired pull-out
torque curve from the motor. Powersupply design gets easier and powersupply losses decrease since regulated
supply normally is not needed for
constant current drivers.
If minimum cost for the driver
electronics is the most important
design criteria, rather than the over
all system performance, then the
different unipolar driver can be the
best choice.
120
12
100
10
80
60
40
20
0
0
AAAAAAAAA
AA
A
A A
3.8W
36%
500
1000
1500
2000
2
0
2500
Pull-out Torque
Efficiency
Output Power
Power losses
Figure 12. Performance curves for a 3.75ohm bipolar 57mm PM-motor driven by
PBL3770A constant-current driver. (Half-step mode fast current decay. Chopper voltage
20V, 2-phase-on current 480mA).
100
80
7.3W
60
5.3W
40
4
2
20
0
0
0
1000
2000
3000
Full-step stepping rate [Hz]
4000
5000
Figure 13. Performance as a function of chopper voltage for a 25ohm bipolar 42mm
square hybrid stepper driven by PBL3770A constant-current driver (Chopper
voltage 40/30V, winding current 280mA).
Pull-out 280mA
Pull-out 200mA
Losses 280mA
Losses 200mA
100
80
7.1W
10
8
60
40
20
0
0
1000
2000
3000
Full-step stepping rate [Hz]
4000
5000
Figure 14. Performance as a function of winding current for a 25ohm bipolar 42mm
square hybrid stepper driven by PBL3770A constant-current driver (Chopper voltage
40V, winding current 280/200mA).
11
HALF-STEP MODE:
12
Summing up
The unipolar L/R-driver offers the
lowest cost for the electronics for a
given output torque, if the step rate is
low.
As demand for output power from
the stepper increases, more effective
drivers offers the best price performance ratio. The best motor utilization is achieved with the bipolar
constant current driver and this driver
is the obvious choice for all highpower applications.