You are on page 1of 54

CHAPTER 1

INTRODUCTION

A stepper motor is basically an electromechanical device which converts electrical pulses


into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in
discrete step increments when electrical command pulses are applied to it in the proper
sequence. The motors rotation has several direct relationships to these applied input
pulses. The sequence of the applied pulses is directly related to the direction of motor
shafts rotation. The speed of the motor shafts rotation is directly related to the frequency
of the input pulses and the length of rotation is directly related to the number of input
pulses applied.

1.1: Working of the stepper motor


The stepper motor uses the theory of operation for magnets to make the motor shaft turn a
precise distance when a pulse of electricity is provided. Figure 1.1 shows a typical cross-
sectional view of the rotor and stator of a stepper motor. From this diagram it can be
noted that the stator (stationary winding) has four poles, and the rotor has six poles. The
rotor will require 12 pulses of electricity to move the 12 steps to make one complete
revolution. Another way to say this is that the rotor will move precisely 30° for each pulse
of electricity that the motor receives. The number of degrees the rotor will turn when a
pulse of electricity is delivered to the motor can be calculated by dividing the number of
degrees in one revolution of the shaft (360°) by the number of poles (north and south) in
the rotor.

1
Figure 1.1: Position of the six-pole rotor and four-pole
stator of a typical stepper motor

When no power is applied to the motor, the residual magnetism in the rotor magnets will
cause the rotor to detent or align one set of its magnetic poles with the magnetic poles of
one of the stator magnets. This means that the rotor will have 12 possible detent positions.
When the rotor is in a detent position, it will have enough magnetic force to keep the shaft
from moving to the next position. This is what makes the rotor feel like it is clicking from
one position to the next when rotated manually.

When power is applied, it is directed to only one of the stator pairs of windings, which
will cause that winding pair to become a magnetized. One of the coils for the pair will
become the north pole, and the other will become the south pole. When this occurs, the
stator coil that is the north pole will attract the closest rotor tooth that has the opposite
polarity, and the stator coil that is the south pole will attract the closest rotor tooth that has
the opposite polarity. When current is flowing through these poles, the rotor will now
have a much stronger attraction to the stator winding, and the increased torque is called
holding torque.

By changing the current flow to the next stator winding, the magnetic field will be
changed 90°. The rotor will only move 30° before its magnetic fields will again align with
the change in the stator field. The magnetic field in the stator is continually changed as
the rotor moves through the 12 steps to move a total of 360°.

2
Figure 1.2: Movement of the stepper motor rotor as current is pulsed to the stator.
(a) Current is applied to the top and bottom windings, so the top winding
is north, (b) Current is applied to left and right windings, so the left
winding is north, (c) Current is applied to the top and bottom windings,
so the bottom winding is north, (d) Current is applied to the left and right
windings so the right winding is north.

In Figure 1.2a it ca be noted that when current is applied to the top and bottom stator
windings, they will be magnetized with the top part of the winding being the north pole,
and the bottom part of the winding being the south pole. This will cause the rotor to move
a small amount so that one of its south poles is aligned with the north stator pole (at the
top), and the opposite end of the rotor pole, which is the north pole, will align with the
south pole of the stator (at the bottom). A line is placed on the south-pole piece that is
located at the 12 o'clock position in Figure 1.2a so that to enable the rotation to be noted
as current is moved from one stator winding to the next.

In Figure 1.2b current has been turned off to the top and bottom windings, and current is
now applied to the stator windings shown at the right and left sides of the motor. When
this occurs, the stator winding at the 3 o'clock position will have the polarity for the south

3
pole of the stator magnet, and the winding at the 9 o'clock position will have the north-
pole polarity. In this condition, the next rotor pole that will be able to align with the stator
magnets is the next pole in the clockwise position to the previous pole. This means that
the rotor will only need to rotate 30° in the clockwise position for this set of poles to align
itself so that it attracts the stator poles.

In Figure 1.2c it can be noted that the top and bottom stator windings are energized again,
but this time the top winding is the south pole of the magnetic field and the bottom
winding is the north pole. This change in magnetic field will cause the rotor to again
move 30° in the clockwise position until its poles will align with the top and bottom stator
poles. The original rotor pole that was at the 12 o'clock position when the motor first
started has now moved three steps in the clockwise position.

In Figure 1.2d it can be noted that the two side stator windings are energized again, but
this time the winding at the 3 o'clock position is the north pole. This change in polarity
will cause the rotor to move another 30° in the clockwise direction. The rotor has moved
four steps of 30° each, which means the rotor has moved a total of 120° from its original
position. This can be verified by the position of the rotor pole that has the line on it,
which is now pointing at the stator winding that is located in the 3 o'clock position.

Characteristics

• Holding Torque – Stepper motors have very good low speed and holding torque.
They are usually rated in terms of their holding force (oz/in) and can even hold a position
(to a lesser degree) without power applied, using magnetic 'detent' torque.

• Open loop positioning - Perhaps the most valuable and interesting feature of a
stepper motor is the ability to position the shaft in fine predictable increments, without
need to query the motor as to its position. Stepper motors can run 'open-loop' without the
need for any kind of encoder to determine the shaft position. Closed loop systems-
systems that feed back position information, are known as servo systems. Compared to
servos, stepper motors are very easy to control; the position of the shaft is guaranteed as
long as the torque of the motor is sufficient for the load, under all its operating conditions.

4
• Load Independent - The rotation speed of a stepper motor is independent of load,
provided it has sufficient torque to overcome slipping. The higher rpm a stepper motor is
driven, the more torque it needs, so all steppers eventually poop out at some rpm and start
slipping. Slipping is usually a disaster for steppers, because the position of the shaft
becomes unknown. For this reason, software usually keeps the stepping rate within a
maximum top rate. In applications where a known rpm is needed under a varying load,
steppers can be very handy.

1.2 TYPES OF STEPPER MOTORS


There are basically three types of stepping motors; variable reluctance, permanent magnet
and hybrid. They differ in terms of construction based on the use of permanent magnets
and/or iron rotors with laminated steel stators.

1.2.1 Variable reluctance stepper motors


The variable reluctance motor does not use a permanent magnet. As a result, the motor
rotor can move without constraint or "detent" torque. This type of construction is good in
non industrial applications that do not require a high degree of motor torque, such as the
positioning of a micro slide.

5
Figure 1.3: Variable Reluctance Motor

The variable reluctance motor in the above illustration has three "stator pole sets" (A, B,
C,), set 15 degrees apart. Current applied to pole A through the motor winding causes a
magnetic attraction that aligns the rotor (tooth) to pole A. Energizing stator pole B causes
the rotor to rotate 15 degrees in alignment with pole B. This process will continue with
pole C and back to A in a clockwise direction. Reversing the procedure (C to A) would
result in a counterclockwise rotation.

1.2.2: Permanent magnet stepper motors


The permanent magnet motor, as the name implies, has a permanent magnet rotor. It is a
relatively low speed, low torque device with large step angles of either 45 or 90 degrees.
Its simple construction and low cost make it an ideal choice for non industrial
applications, such as a line printer print wheel positioner.

6
Figure 1.4: Permanent magnet motor

Unlike the other stepping motors, the permanent magnet motor rotor has no teeth and is
designed to be magnetized at a right angle to its axis. The above illustration shows a
simple, 90 degree permanent magnet motor with four phases (A-D). Applying current to
each phase in sequence will cause the rotor to rotate by adjusting to the changing
magnetic fields. Although it operates at fairly low speed the PM motor has a relatively
high torque characteristic.

1.2.3: Hybrid stepper motors


Hybrid motors combine the best characteristics of the variable reluctance and permanent
magnet motors. They are constructed with multi-toothed stator poles and a permanent
magnet rotor. Standard hybrid motors have 200 rotor teeth and rotate at 1.80 step angles.
Other hybrid motors are available in 0.9ºand 3.6º step angle configurations. Because they
exhibit high static and dynamic torque and run at very high step rates, hybrid motors are
used in a wide variety of industrial applications.

7
Figure 1.5: Hybrid motor

1.3: STEPPER MOTOR WINDINGS

1.3.1: Unipolar Motor Winding

Unipolar stepper motors are composed of two windings, each with a center tap. The
center taps are either brought outside the motor as two separate wires (as shown in Figure
1.6) or connected to each other internally and brought outside the motor as one wire. As a
result, unipolar motors have 5 or 6 wires. Regardless of the number of wires, unipolar
motors are driven in the same way. The center tap wire(s) is tied to a power supply and
the ends of the coils are alternately grounded. Unipolar stepper motors, like all permanent
magnet and hybrid motors, operate differently from variable reluctance motors. Rather
than operating by minimizing the length of the flux path between the stator poles and the
rotor teeth, where the direction of current flow through the stator windings is irrelevant,
these motors operate by attracting the north or south poles of the permanently magnetized
rotor to the stator poles. Thus, in these motors, the direction of the current through the
stator windings determines which rotor poles will be attracted to which stator poles.
Current direction in unipolar motors is dependent on which half of a winding is
energized. Physically, the halves of the windings are wound parallel to one another.
Therefore, one winding acts as either a north or south pole depending on which half is
powered. Figure 1.6 shows the cross section of a 30 degree per step unipolar motor.
Motor winding number 1 is distributed between the top and bottom stator poles, while

8
motor winding number 2 is distributed between the left and right motor poles. The rotor is
a permanent magnet with six poles, three north and three south.

Figure 1.6: Unipolar stepper motor

1.3.2: Bipolar Motor Windings

Bipolar stepper 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. Current flow in the winding of a
bipolar motor is bidirectional. This requires changing the polarity of each end of the
windings. As shown in Figure 1.7, current will flow from left to right in winding 1 when
1a is positive and 1b is negative. Current will flow in the opposite direction when the
polarity on each end is swapped.

Figure 1.7: Bipolar stepper motor

9
1.4: DC MOTORS VS. STEPPER MOTORS
 Stepper motors are operated open loop, while most DC motors are operated closed
loop.
 Stepper motors are easily controlled with microprocessors; however logic and
drive electronics are more complex.
 Stepper motors are brushless and brushes contribute several problems, e.g., wear,
sparks, electrical transients.
 DC motors have a continuous displacement and can be accurately positioned,
whereas stepper motor motion is incremental and its resolution is limited to the
step size.
 Stepper motors can slip if overloaded and the error can go undetected.
 Feedback control with DC motors gives a much faster response time compared to
stepper motors.

Advantages
 Accuracy & Repeatability – Ability to position accurately.
 Responsiveness & Quick Acceleration – Step motors have low rotor inertia,
allowing them to get up to speed quickly. This makes step motors an excellent
choice for short, quick moves.
 Excellent torque for their size – Step motors have the highest torque per cubic
inch of any motor.
 Positioning Stability – Unlike other types of motors, step motors can be held
completely motionless in their stopped position.
 Open Loop Control – Open loop control is simpler, more reliable and less
expensive than closed loop control. In closed loop systems, encoders are used to
count the number of steps taken by the motor. The number of steps taken is
compared to the number of step commands given. This feedback is used to make
position corrections or initiate alarm signals. Encoders and their associated
electronics add additional cost to a motion control system. Assuming that a step
motor is properly sized for its load, it should never miss a step, making an encoder
unnecessary.

10
 Cost and Reliability – Step motor technology is reliable and proven. It is the most
cost effective method of precision position control.

Disadvantages
 Resonances can occur if not properly controlled.
 Not easy to operate at extremely high speeds.

1.5: 8051 Microcontroller


A particularly useful feature of the 8051 core is the inclusion of a Boolean processing
engine which allows bit-level Boolean logic operations to be carried out directly and
efficiently on internal registers and RAM. This feature helped to cement the 8051's
popularity in industrial control applications. Another valued feature is that it has four
separate register sets, which can be used to greatly reduce interrupt latency compared to
the more common method of storing interrupt context on a stack.

The 8051 UARTs make it simple to use the chip as a serial communications interface.
External pins can be configured to connect to internal shift registers in a variety of ways,
and the internal timers can also be used, allowing serial communications in a number of
modes, both synchronous and asynchronous. Some modes allow communications with no
external components.

Once a UART has been configured, the programmer needs only to write a simple
interrupt routine to refill the 'send' shift register whenever the last bit is shifted out by the
UART and/or empty the full 'receive' shift register (copy the data somewhere else). The
main program then performs serial reads and writes simply by reading and writing 8-bit
data to stacks.

8051 based microcontrollers typically include one or two UARTs, two or three timers,
128 or 256 bytes of internal data RAM (16 bytes of which are bit-addressable), up to 128
bytes of I/O, 512 bytes to 64 kB of internal program memory, and sometimes a quantity
of extended data RAM (ERAM) located in the external data space. The original 8051 core
ran at 12 clock cycles per machine cycle, with most instructions executing in one or two

11
machine cycles. With a 12 MHz clock frequency, the 8051 could thus execute 1 million
one-cycle instructions per second or 500,000 two-cycle instructions per second. Enhanced
8051 cores are now commonly used which run at six, four, two, or even one clock per
machine cycle, and have clock frequencies of up to 100 MHz, and are thus capable of an
even greater number of instructions per second. All SILabs, some Dallas and a few Atmel
devices have single cycle cores.

Common features included in modern 8051 based microcontrollers include built-in reset
timers with brown-out detection, on-chip oscillators, self-programmable Flash ROM
program memory, bootloader code in ROM, EEPROM non-volatile data storage, I²C,
SPI, and USB host interfaces, PWM generators, analog comparators, A/D and D/A
converters, RTCs, extra counters and timers, in-circuit debugging facilities, more
interrupt sources, and extra power saving modes.

Several assembly compilers are available for the 8051, most of which feature extensions
that allow the programmer to specify where each variable should be stored in its six types
of memory, and provide access to 8051 specific hardware features such as the multiple
register banks and bit manipulation instructions. Other high level languages such as Forth,
BASIC, Pascal/Object Pascal, PL/M and Modula 2 are available for the 8051, but they are
less widely used than C and assembly.

12
CHAPTER 2
THEORY OF THE STEPPER MOTOR

2.1: TORQUE GENERATION


For a motor that turns S radians per step, the plot of torque versus angular position for the
rotor relative to some initial equilibrium position will generally approximate a sinusoid.
The actual shape of the curve depends on the pole geometry of both rotor and stator. For
permanent magnet and hybrid motors, the actual curve usually looks sinusoidal, but looks
can be misleading. For variable reluctance motors, the curve rarely even looks sinusoidal;
trapezoidal and even assymetrical sawtooth curves are not uncommon.
For a three-winding variable reluctance or permanent magnet motors with S radians per
step, the period of the torque versus position curve will be 3S; for a 5-phase permanent
magnet motor, the period will be 5S. For a two-winding permanent magnet or hybrid
motor, the most common type, the period will be 4S, as illustrated in Figure 2.1:

Figure 2.1: Torque vs. Angle

Again, for an ideal 2 winding permanent magnet motor, this can be mathematically
expressed as:

T = -h sin( ((pi/2) / S)Theta)

Where:
T -- torque
h -- holding torque
S -- step angle, in radians
Theta = shaft angle, in radians

13
But remember, subtle departures from the ideal sinusoid described here are very common.
The single-winding holding torque of a stepping motor is the peak value of the torque
versus position curve when the maximum allowed current is flowing through one motor
winding. If you attempt to apply a torque greater than this to the motor rotor while
maintaining power to one winding, it will rotate freely.

Assuming that the torque versus angular position curve is a good approximation of a
sinusoid, as long as the torque remains below the holding torque of the motor, the rotor
will remain within 1/4 period of the equilibrium position. For a two-winding permanent
magnet or hybrid motor, this means the rotor will remain within one step of the
equilibrium position.

With no power to any of the motor windings, the torque does not always fall to zero. In
variable reluctance stepping motors, residual magnetization in the magnetic circuits of the
motor may lead to a small residual torque, and in permanent magnet and hybrid stepping
motors, the combination of pole geometry and the permanently magnetized rotor may
lead to significant torque with no applied power.

The residual torque in a permanent magnet or hybrid stepping motor is frequently referred
to as the cogging torque or detent torque of the motor because a naive observer will
frequently guess that there is a detent mechanism of some kind inside the motor. The
most common motor designs yield a detent torque that varies sinusoidally with rotor
angle, with an equilibrium position at every step and an amplitude of roughly 10% of the
rated holding torque of the motor,

2.1.1: Dynamics of stepper motors


Each time you step the motor, you electronically move the equilibrium position S radians.
This moves the entire curve illustrated in Figure 2.1 a distance of S radians, as shown in
Figure 2.2:

14
Figure 2.2: Torque vs. angle

The first thing to note about the process of taking one step is that the maximum available
torque is at a minimum when the rotor is halfway from one step to the next. This
minimum determines the running torque, the maximum torque the motor can drive as it
steps slowly forward. For common two-winding permanent magnet motors with ideal
sinusoidal torque versus position curves and holding torque h, this will be h/(2 0.5). If the
motor is stepped by powering two windings at a time, the running torque of an ideal two-
winding permanent magnet motor will be the same as the single-winding holding torque.
It should be noted that at higher stepping speeds, the running torque is sometimes defined
as the pull-out torque. That is, it is the maximum frictional torque the motor can
overcome on a rotating load before the load is pulled out of step by the friction. The pull-
in torque, is the maximum frictional torque that the motor can overcome to accelerate a
stopped load to synchronous speed.

In practice, there is always some friction, so after the equilibrium position moves one
step, the rotor is likely to oscillate briefly about the new equilibrium position. The
resulting trajectory may resemble the one shown in Figure 2.3:

Figure 2.3: Shaft angle vs. Time

Here, the trajectory of the equilibrium position is shown as a dotted line, while the solid
curve shows the trajectory of the motor rotor.

15
2.1.2: Torque / Speed Curves
It is very important to know how to read a torque/speed curve because it describes what a
motor can and cannot do. It is also important to keep in mind that a torque/speed curve is
for a given motor and a given driver. Torque is dependent on the driver type and voltage.
The same motor can have a very different torque/speed curve when used with a different
driver. The same motor with a similar drive, similar voltage and similar current should
give similar performance. Torque/speed charts can also be used to roughly estimate the
torque produced using different drivers at varying voltages and currents.

Figure 2.4: Torque vs. speed characteristics of a stepper motor

To get a better understanding of this curve it is useful to define the different aspect of this
curve.

 Holding Torque is the amount of torque that the motor produces when it has rated
current flowing through the windings but the motor is at rest.

 Stop / Start Region is the area on and underneath the pull-in curve. For any load
value in this region, the motor can start, stop, or reverse ―instantly‖ (no ramping
required) at the corresponding speed value.

16
 Slew Range is the area between the pull-in and the pull-out curves, where to
maintain synchronism, the motor speed must be ramped (adjusted gradually).

2.2: MECHANICAL PARAMETERS, LOAD, FRICTION, INERTIA


The performance of a stepper motor system (driver and motor) is also highly dependent
on the mechanical parameters of the load. The load is defined as what the motor drives. It
is typically frictional, inertial or a combination of the two. Friction is the resistance to
motion due to the unevenness of surfaces which rub together. Friction is constant with
velocity. A minimum torque level is required throughout the step in over to overcome this
friction (at least equal to the friction). Increasing a frictional load lowers the top speed,
lowers the acceleration and increases the positional error. The converse is true if the
frictional load is lowered Inertia is the resistance to changes in speed. A high inertial load
requires a high inertial starting torque and the same would apply for braking. Increasing
an inertial load will increase speed stability, increase the amount of time it takes to reach
a desired speed and decrease the maximum self start pulse rate. The converse is again true
if the inertia is decreased. The rotor oscillations of a stepper motor will vary with the
amount of friction and inertia load. Because of this relationship unwanted rotor
oscillations can be reduced by mechanical damping means however it is more often
simpler to reduce these unwanted oscillations by electrical damping methods such as
switch from full step drive to half step drive.

2.3: PHASES, POLES AND STEPPING ANGLES


Usually stepper motors have two phases, but three- and five-phase motors also exist. A
bipolar motor with two phases has one winding/phase and a unipolar motor has one
winding, with a center tap per phase. Sometimes the unipolar stepper motor is referred to
as a ―fourphase motor‖, even though it only has two phases. Motors that have two
separate windings per phase also exist—these can be driven in either bipolar or unipolar
mode.

17
A pole can be defined as one of the regions in a magnetized body where the magnetic flux
density is concentrated. Both the rotor and the stator of a step motor have poles. In reality
several more poles are added to both the rotor and stator structure in order to increase the
number of steps per revolution of the motor, or in other words to provide a smaller basic
(full step) stepping angle. The permanent magnet stepper motor contains an equal number
of rotor and stator pole pairs. Typically the PM motor has 12 pole pairs.

The stator has 12 pole pairs per phase. The hybrid type stepper motor has a rotor with
teeth. The rotor is split into two parts, separated by a permanant magnet—making half of
the teeth south poles and half north poles. The number of pole pairs is equal to the
number of teeth on one of the rotor halves. The stator of a hybrid motor also has teeth to
build up a higher number of equivalent poles (smaller pole pitch, number of equivalent
poles = 360/teeth pitch) compared to the main poles, on which the winding coils are
wound.

Step angle=360 ÷ (Nph × Ph) =360/N

Where,
Nph = Number of equivalent poles per phase = number of rotor poles
Ph = Number of phases
N = Total number of poles for all phases together

The relationship between the number of rotor poles and the equivalent stator poles, and
the number the number of phases that determines the full-step angle of a stepper motor. If
the rotor and stator tooth pitch is unequal, a more-complicated relationship exists.

18
2.4: STEPPER MOTOR DRIVE CIRCUITS
The basic function of a motor driver is to provide the rated current to the motor windings
in the shortest possible time. Driver voltage plays a large part in a step motor’s
performance. Higher voltage forces current into the motor windings faster, helping to
maintain high speed torque.

Two of the most commonly used drivers for step motors are the following:

Constant current drivers are also known as PWM (pulse width modulated) or chopper
drives. In this type of driver, the motor current is regulated by switching voltage to the
motor on and off to achieve an average level of current. These drivers operate using a
high voltage supply, generating a high driver voltage to motor voltage ratio, giving the
motor improved high-speed performance.

Constant voltage drivers are also known as, L/R or resistance limited (RL) drivers. In this
type of driver, the amount of current a step motor receives is limited only by the
resistance/impedance of its windings. For this reason, it is important to match the motor’s
rated voltage to the voltage of the driver. Constant voltage drivers work best in low speed
and low current applications. They become inefficient at high speeds and high current
levels. In certain situations, resistors may be placed in series with the motor’s windings to
allow the motor to be operated using a driver voltage larger than the motor’s rated voltage
to increase performance at higher speeds.

2.4.1: Driver & Winding Configurations

Step motor drivers can be divided into two types, unipolar and bipolar.
Unipolar drivers can send current through a motor’s windings in only one direction.
Unipolar drivers tend to achieve better high-speed performance. Bipolar drivers can send
current through a motor’s windings in both directions. Step motors can be connected to
these drives in several different ways to get different motor performance, making a
bipolar drive much more flexible than a unipolar drive.

19
In a unipolar winding configuration, only half the coils of each winding are used at a time
as shown in figure 2.5a. Energizing half of the coils is beneficial because it reduces the
winding’s inductance. Inductance is an electrical property that fights changes in current
flow, particularly at higher speeds. The unipolar winding configuration tends to give
better high-speed performance. The disadvantage of this type of configuration is that at
lower speeds it tends to give less torque than configurations that use the entire winding.

In a bipolar series winding configuration, both halves of the phase are connected in series
as shown in figure 2.5b. Since the full coil is used, the same motor will produce 40%
more torque in the low to mid speed range. Unfortunately, this configuration has four
times the inductance of the same motor operated in the unipolar configuration. Although
the motor has good low speed torque, the torque will drop off rapidly at high speeds.

A bipolar half coil winding configuration can be used to achieve unipolar performance
with a bipolar drive. In this configuration, the motor’s inductance and low speed torque
are less than those in the bipolar series configuration. As in the unipolar configuration, the
half coil configuration tends to give better performance at higher speeds. Both 6 and 8
lead wire motors can be connected in the bipolar half coil configuration. This is shown in
figure 2.5c.

A bipolar parallel winding configuration can only be achieved using an 8 lead wire motor
or by internal wiring. In a parallel configuration, one half of the winding phase is placed
in parallel with the other half as shown in figure 2.5d. This allows the full winding to be
used while keeping the inductance low. This combination allows the bipolar parallel
configuration to produce 40% more torque than the unipolar winding configuration while
still performing well across a wide range of speeds. However, due to the parallel
configuration, the winding resistance is halved and the motor will require 40% more
current than the same motor run in a unipolar configuration to produce this increased
torque.

20
Figure 2.5: Winding configurations

2.5: STEPPING MODES


There are two modes of operation when using a stepper motor. The mode of operation is
determined by the step sequence applied. The two step sequences are full step and half
step.

2.5.1: Full step drive


In full step operation, the motor moves through its basic step angle, for example, a 7.5°
step motor takes 48 steps per motor revolution. There are two types of full step excitation
modes. In single phase mode, also known as ―one-phase on, full step‖ excitation, the
motor is operated with only one phase energized at a time. This mode requires the least
amount of power from the driver of any of the excitation modes. Figure 2.6 shows how
the rotor moves in single phase mode with the sequence of energizing the coils given in
table 1.

In dual phase mode, also known as ―two-phase on, full step‖ excitation, the motor is
operated with both phases energized at the same time. This mode provides improved
torque and speed performance. Dual phase excitation provides about 30% to 40% more
torque than single phase excitation, but does require twice as much power from the driver.
Figure 2.7 shows the rotor movement in dual phase mode with the sequence of energizing
the coils given in table 2.

21
Full step sequence

Step COIL A COIL B COIL C COIL D


0 1 0 0 0

1 0 1 0 0

2 0 0 1 0

3 0 0 0 1

Table 1: One phase ON, full step sequence

Figure 2.6: One phase ON, full step

22
Step COIL A COIL B COIL C COIL D
0 1 1 0 0

1 0 1 1 0

2 0 0 1 1

3 1 0 0 1

Table 2: Two phases ON, full step

Figure 2.7: Two phases ON, full step

2.5.2: Half step drive


Half step excitation is alternating single and dual phase operation resulting in steps that
are half the basic step angle. Due to the smaller step angle, this mode provides twice the
resolution and smoother operation. Half stepping produces roughly 15% less torque than
dual phase full stepping. Modified half stepping eliminates this torque decrease by
increasing the current applied to the motor when a single phase is energized. Figure 2.8
shows how the rotor moves in half step mode with the sequence of energizing the coils
given in table 3.

23
Half Step Sequence

Step COIL A COIL B COIL C COIL D

0 1 1 0 0

1 0 1 0 0

2 0 1 1 0

3 0 0 1 0

4 0 0 1 1

5 0 0 0 1

6 1 0 0 1

7 1 0 0 0

Table 3: Half Step Sequence

Figure 2.8: Half step sequence

24
2.6: STEP ANGLE
The movement associated with a single step depends on the internal construction of the
motor, in particular the number of teeth on the stator and the rotor. Step angle of the
stepper motor is defined as the angle traversed by the motor in one step. It is the
minimum degree of rotation associated with a single step. Various motors have different
step angles.
To calculate step angle, simply divide 360 by number of steps a motor takes to complete
one revolution. As we have seen that in half mode, the number of steps taken by the
motor to complete one revolution gets doubled, so step angle reduces to half.
The stepper motor rotating in full mode takes 4 steps to complete a revolution, so step
angle can be calculated as:

Step Angle ø = 360° / 4 = 90°

and in case of half mode step angle gets half so 45°.

So this way we can calculate step angle for any stepper motor. Usually step angle is given
in the data sheet of the stepper motor you are using. Knowing stepper motor's step angle
helps you calibrate the rotation of motor also to helps you move the motor to correct
angular position.

25
CHAPTER 3
IMPLEMENTATION

3.1: INTRODUCTION
The previous chapter discussed the technical and theoretical background for a stepper
motor, and how it can be controlled. The techniques of how to control the stepper motor
is were implemented and discussed in this chapter.
The stepper motor controller will be divided into two sections, the physical circuit, using
the 8051 microcontroller to control the movement of the stepper motor and the second
part deals with appropriate software necessary to generate the control bits required for the
motor.

3.2: PROJECT BLOCK DIAGRAM

Figure 3.1: Project Block Diagram

The diagram above shows a typical step motor based system. All of these parts must be
present in one form or another. Each component’s performance will have an effect on the
others.

First is the pulse generator, also known as a controller or indexer. The pulse generator
will output command pulses that the motor will follow. By altering the frequency of the
pulse train, the pulse generator can instruct the motor to accelerate, run at a speed,
decelerate or stop. A pulse generator must be present otherwise the motor will not move.

26
Next is the motor driver. The driver’s function is to control the magnitude and direction
of current flow into the motor windings. The driver takes the pulses from the pulse
generator and determines how and when the windings should be energized. The windings
must be energized in a specific sequence to generate motion.

Finally there is the step motor itself.

3.2.1: The Controller


The controller used in driving a stepper motor in this particular piece of work was the
Atmel AT89S52 microcontroller which is from the 8051 microcontroller family.
The microcontroller offers a great flexibility in it can operate in either stand-alone mode
or interfaced to a computer.
In stand-alone mode the microcontroller can operate independent of the host computer.
Once the programs are downloaded to the non-volatile memory, they can be initiated
from various types of operator interfaces, such as switches, or through the auxiliary I/O
ports.

The 8051 circuit


The 8051 has an on-chip oscillator but requires an external clock to run it. The Quartz
crystal oscillator is connected to input pin 18 and pin 19. the Quartz crystal oscillator uses
two capacitors of 33pF to stabilize the oscillations. Each capacitor is connected to ground.
An 11.0592MHz crystal oscillator is used in the circuit depending on the 8051 speeds.
Note that there are various speeds of the 8051 family. Speed refers to the maximum
oscillator frequency connected to the 8051 microcontroller.

27
Figure 3.2: Connections of the Quartz crystal and the Reset circuit

3.2.2: The Driver

The 8051 microcontroller does not have sufficient drive capability on its output to drive
each coil, so there are a number of ways to drive a stepper,

 Using a transistor to drive each coil


 Using a driver array packaged in an IC
 Using a specialized stepper motor driver chip

However it can be noted that if transistors are used as drivers, then diodes must also be
used to take care of the inductive current generated when the coil is turned OFF. One
reason that the ULN 2003 is preferable to the use of transistors as drivers is that the ULN
2003 has an internal diode to take care of back EMF.

The ULN 2003 is a TTL-input NPN Darlington driver. It is a high voltage, high current
Darlington array containing seven open collector Darlington pairs with common emitters.
Each channel rated at 500mA and can withstand peak currents of 600mA. Suppression
diodes are included for inductive load driving and the inputs are pinned opposite the
outputs to simplify board layout.

28
Figure 3.3: The ULN 2003 Driver IC

3.2.3: The stepper motor


The stepper motor used in this project was a permanent magnet Unipolar stepper motor
with 5 wires, one for the motor supply which is red in colour and the other four are
connected to the motor coils. It is composed of two windings, each with a centre tap. The
centre taps are connected to each other internally and brought outside the motor as one
wire. The stepper motor had a step angle of 7.5 degrees step angle and a resistance of 180
Ohms.

Stepper motors do not usually have the wires labeled. Therefore to check which wire was
what was done by measuring the resistance of the leads using an ohmmeter. This
identified which was the centre-tap and which leads were connected to the coils.

29
3.3: CIRCUIT DIAGRAM

Figure 3.4: Circuit Diagram for Stepper motor controller

The circuit diagram in figure 3.2 shows the interfacing of a stepper motor to the
microcontroller through a driver.

30
Analyzing the circuit
The microcontroller is interfaced to the stepper motor through ports 0.0, 0.1, 0.2, and 0.3.
This is done through the ULN 2003 Driver. The input pins 1, 2, 3 and 4 of the ULN 2003
are connected to the microcontroller and the output pins 13, 14, 15 and 16 to the four
leads of the stepper motor.

The five leads of the stepper motor were distinguished as explained earlier by measuring
the resistance of the leads. Thus, the wire which was the centre tap of the motor coils was
connected to +5v supply. The stepper motor had a resistance of 120 ohms across the coils
and was connected across +5V supply. The current passing through each coil is therefore
27mA.

Three switches were connected across ports 3.0, 3.1 and 3.2 of the microcontroller.
Theses switches are known as mode switches which were programmed to control the
stepping mode of the stepper motor. Eight other switches were connected across port 2 of
the microcontroller, which are known as speed control switches and were programmed to
control the speed of the stepper motor.

3.4: SOFTWARE DESIGN:


The program for the stepper motor control was written in assembly language. The
assembly code is given in the appendix.

3.4.1: Programming the 8051 microcontroller


The Assembly code was compiled using Keil Software, the HEX file that was generated
was ―burned‖ into the ROM of the 8051 Microcontroller. This was done by the 8051
Programmer Kit.

31
The procedure for ―burning‖ the 8051 microcontroller was done as follows:
 The microcontroller was inserted into the programmer kit
 The programmer kit was connected to the parallel port of the computer
 The programmer kit was then powered up to +5V d.c supply (adapter)
 The assembly code was written and changed into the HEX code by the Keil
compiler
 The HEX code was then loaded into the microcontroller
 The 8051 microcontroller was then ready to drive and control the stepper motor

Figure 3.5: Compiling the Assembly Code using the Keil Software

32
3.4.2: Program Flow Chart

Figure 3.6: Program Flow Chart

33
CHAPTER 4
RESULTS AND OBSERVATIONS

4.1: PROCEDURE FOR TESTING

 All the mode switches were switched to zero

 All the speed control switches were switched to zero

 The circuit was powered up by 5V supply (adapter)

 The mode switches were toggled and the rotation of the stepper motor was
observed

 The speed control switches were toggled to vary the speed of the stepper motor

34
4.2: RESULTS

4.2.1: Direction and Mode of the Stepper Motor


The mode switches of the circuit were toggled according to the sequence in table 4 and
the observed status of the stepper motor was recorded on the same table.

SWITCHES
MOTOR STATUS
P2.2, P2.1, P2.0
0 0 0 Stop
0 0 1 Forward full step (dual-phase on)
0 1 0 Reverse full step (dual-phase on)
0 1 1 Forward full step (single-phase on)
1 0 0 Reverse full step (single-phase on)
1 0 1 Forward half step
1 1 0 Reverse half step

Table 4: status of the stepper motor on different switch modes

4.2.2: Speed Control


The speed of the stepper motor was observed by vision and a stop watch. Time taken for
one revolution was noted and the speed in revolutions per second was calculated by
taking the inverse.

Table 5 gives the binary number of the 8 switches, its decimal equivalent, time taken for
one revolution and the speed in revolutions per second. This was done for the different
modes.

35
1. Full Step Mode (Dual-phase on)

STATUS OF THE SWITCHES TIME TAKEN


FOR ONE SPEED IN
BINARY DECIMAL
REVOLUTION RPS
(SEC)
00000001 1 13.64 0.07

00100000 32 11.95 0.08

10000000 128 6.834 0.15

2. Full Step Mode (Single-phase on)

STATUS OF THE SWITCHES TIME TAKEN


FOR ONE SPEED IN
BINARY DECIMAL
REVOLUTION RPS
(SEC)
00000001 1 13.84 0.07

00100000 32 12.00 0.08

10000000 128 6.9 0.14

3. Half Step Mode

STATUS OF THE SWITCHES TIME TAKEN


FOR ONE SPEED IN
BINARY DECIMAL
REVOLUTION RPS
(SEC)
00000001 1 13.71 0.07

00100000 32 11.5 0.09

10000000 128 6.5 0.16

36
4.3: OBSERVATIONS:

It was observed that when the stepper motor was running in the full step mode, its
rotation was rough and slower than the half step mode. Therefore half step mode has a
smoother and faster movement than the half step mode. A smoother movement is
achieved if the stepper motor has a small step angle and therefore more steps per
revolution.

37
CHAPTER 5
CONCLUSION AND FUTURE WORK

5.1: CONCLUSION
The early part of the text attempted to provide a concise introduction to the technical and
mathematical principles of step motors while the latter part of the text focused on the
application of those principles and techniques in designing the stepper motor controller
along with its control program and connected circuitry.

It was an educational experience conducting this project and the stepper motor can be
used as an educational tool for introducing the basic principles of DC motors.

The project was completed successfully as both the electronic unit and the bit generating
units were successfully implemented to realize the objectives of the project. The analysis
of the results got practically matched the theoretical analysis of stepper motors. The
difference in speed and smoothness of rotation in the different modes was observed and
related correctly to the theory of stepper motors.

5.2: FUTURE WORK


There are many improvements and additions that can be made to the design of the stepper
motor controller to make them more versatile.
Future work for this kind of project includes the following:

 Improvements on the circuit can be done so that the whole kit can handle bigger
motors with greater torque and a higher current handling capacity.
 Improvements can also be made such as to be able to control more motors using
one controller
 LCD screen that displays the speed can be implemented

38
APPENDIX A: PROGRAM SOURCE CODE

ORG 0H

STEPPER EQU P ;STEPPER MOTOR CONNECTED TO P0


MODE_SWITCH EQU P3 ;TOGGLE SWITCHES FOR MOTOR CONTROL IN
;VARIOUS MODES

MAIN:

MOV P3,#0FFH ; MAKE P3 AN INPUT PORT


MOV P2,#0FFH ; MAKE P3 AN INPUT PORT
MOV B,P2 ;LOAD P2 INTO ACC B , THIS IS THE DELAY VALUE
MOV 32H,B ;LOAD VALUE OF ACC B INTO RAM LOCARION 32H
;WHICH IS USED IN THE DELAY SUBROUTINE

MOV P1, #0FFH

NEXT_0: MOV R1,MODE_SWITCH ;LOAD INTO R1 THE MODE SWTCH


VALUE
CJNE R1,#11111000B,NEXT_1 ;COMPARE VALUE 111111000 WITH
VALUE IN R1, AND JUMP TO NEXT_1
IF NOT EQUAL
LCALL MOTOR_OFF ;IF VALUE IN R1 IS EQAL TO
1111111000, THEN CALL MOTOR OFF
SUBROUTINE

NEXT_1: MOV R2,MODE_SWITCH ;LOAD INTO R2 THE MODE SWTCH


VALUE

39
CJNE R2,#11111001B,NEXT_2 ;COMPARE VALUE 111111001 WITH
VALUE IN R2, AND JUMP TO NEXT_2
IF NOT EQUAL
LCALL DUALPHASE_FORWARD ;IF VALUE IN R2 IS EQUAL TO
1111111001, THEN CALL
DUALPHASE_FORWARD SUBROUTINE

NEXT_2: MOV R3,MODE_SWITCH ;LOAD INTO R3 THE MODE SWTCH


VALUE
CJNE R3,#11111010B,NEXT_3 ;COMPARE VALUE 11111010 WITH
VALUE IN R3, AND JUMP TO NEXT_3
IF NOT EQUAL
LCALL DUALPHASE_REVERSE ;IF VALUE IN R3 IS EQUAL TO
11111010, THEN CALL
DUALPHASE_REVERSE SUBROUTINE

NEXT_3: MOV R4,MODE_SWITCH ;LOAD INTO R4 THE MODE SWTCH


VALUE
CJNE R4,#11111011B,NEXT_4 ;COMPARE VALUE 11111011B WITH
VALUE IN R4, AND JUMP TO NEXT_4
IF NOT EQUAL
LCALL FORWARD_FULLSTEP ;IF VALUE IN R4 IS EQUAL TO
11111011, THEN CALL
FORWARD_FULLSTEP SUBROUTINE

NEXT_4: MOV R5,MODE_SWITCH ;LOAD INTO R5 THE MODE SWTCH


VALUE
CJNE R5,#11111100B,NEXT_5 ;COMPARE VALUE 11111100 WITH
VALUE IN R5, AND JUMP TO NEXT_5
IF NOT EQUAL
LCALL REVERSE_FULLSTEP ;IF VALUE IN R5 IS EQUAL TO
11111100, THEN CALL
REVERSE_FULLSTEP SUBROUTINE

40
NEXT_5: MOV R6,MODE_SWITCH ;LOAD INTO R6 THE MODE SWTCH
VALUE
CJNE R6,#11111101B,NEXT_6 ;COMPARE VALUE 11111101 WITH
VALUE IN R6, AND JUMP TO NEXT_6
IF NOT EQUAL
LCALL FORWARD_HALFSTEP ;IF VALUE IN R5 IS EQUAL TO
11111101, THEN CALL
FORWARD_HALFSTEP SUBROUTINE

NEXT_6: MOV R7,MODE_SWITCH ;LOAD INTO R7 THE MODE SWTCH


VALUE
CJNE R7,#11111110B, EXIT ;COMPARE VALUE 11111110 WITH
VALUE IN R7, AND JUMP TO NEXT_7
IF NOT EQUAL
LCALL REVERSE_HALFSTEP ;IF VALUE IN R5 IS EQUAL TO
11111110, THEN CALL
REVERSE_HALFSTEP SUBROUTINE

EXIT:LJMP MAIN

;***********************************************************************

DUALPHASE_FORWARD:

MOV A, #00000011B ;step 0 FULL STEP INITIAL SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

41
MOV A, #00000110B ;step 1 FULL STEP SECOND SEQUENCE
NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A, #00001100B ;step 2 FULL STEP THIRD SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00001001B ;step 3 FULL STEP FOURTH SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

RET

LJMP MAIN

;***********************************************************************

DUALPHASE_REVERSE:

MOV A, #00001001B ;step 0 FULL STEP INITIAL SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

42
MOV A, #00001100B ; step 1 FULL STEP SECOND SEQUENCE
NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A, #00000110B ;step 2 FULL STEP THIRD SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000011B ;step 3 FULL STEP FOURTH SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

RET

LJMP MAIN

;***********************************************************************

43
FORWARD_FULLSTEP:

MOV A, #00000001B ;step 0 FULL STEP INITIAL SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A, #00000010B ;step 1 FULL STEP SECOND SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A, #00000100B ;step 2 FULL STEP THIRD SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00001000B ;step 3 FULL STEP FOURTH SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

RET

LJMP MAIN

44
;***********************************************************************

REVERSE_FULLSTEP:

MOV A, #00001000B ;step 0 FULL STEP INITIAL SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A, #00000100B ;step 1 FULL STEP SECOND SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A, #00000010B ;step 2 FULL STEP THIRD SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000001B ;step 3 FULL STEP 4TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

45
RET

LJMP MAIN

;***********************************************************************

FORWARD_HALFSTEP:

MOV A,#00000001B ;step 1 FULL STEP 1ST SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000011B ;step 2 FULL STEP 2ND SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000010B ;step 3 FULL STEP THIRD SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

46
MOV A,#00000110B ;step 4 FULL STEP 4TH SEQUENCE NUMBER
LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000100B ;step 5 FULL STEP 5TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00001100B ;step 6 FULL STEP 6TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00001000B ;step 7 FULL STEP 7TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00001001B ;step 8 FULL STEP 8TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

47
RET

LJMP MAIN

;***********************************************************************

REVERSE_HALFSTEP:

MOV A,#00001001B ;step 1 FULL STEP 1ST SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00001000B ;step 2 FULL STEP 2ND SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00001100B ;step 3 FULL STEP THIRD SEQUENCE


NUMBER LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

48
MOV A,#00000100B ;step 4 FULL STEP 4TH SEQUENCE NUMBER
LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000110B ;step 5 FULL STEP 5TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000010B ;step 6 FULL STEP 6TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000011B ;step 7 FULL STEP 7TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

MOV A,#00000001B ;step 8 FULL STEP 8TH SEQUENCE NUMBER


LOADED INTO ACC
MOV STEPPER,A ;NUMBER OUTPUTTED TO PORT OF STEPPER
MOTOR
LCALL DELAY ;DELAY TIME SUBROUTINE CALLED

49
RET

LJMP MAIN

;***********************************************************************
*

MOTOR_OFF:

NOP
LCALL DELAY ;

RET

LJMP MAIN

;***********************************************************************
*

50
DELAY: ;DELAY SUBROUTINE

MOV R7,#2

wait2:
MOV R6,32H ;32H ;DELAY NUMBER LOADED
INTO A DECREMENTNG REGISTER

wait1:
MOV R0,#150

wait:
DJNZ R5,wait
DJNZ R6,wait1
DJNZ R7,wait2 ;WAIT TILL ALL REGISTERS ARE EMPTY
RET ;GO BACK
END

;***********************************************************************
*******************

51
APPENDIX B: DATASHEET FOR 8051
MICROCONTROLLER

The datasheets given here are for the Atmel 8051 Microcontroller

52
APPENDIX C: DATASHEET FOR ULN 2003/2004

The datasheet given for the ULN 2003 Driver IC is from ST.

53
REFERENCES

Books:
1. The 8051 Microcontroller and Embedded Systems.
Pearson Education Asia, 2002.
Muhammad Ali Mazidi and Janice Gillispie Mazidi.
2. Stepping Motors: a guide to modern theory and practice.
P. P. Acarnley.
Peter Peregrinus on behalf of the IEE, 1984, c1982
3. Programming and Customizing the 8051 Microconroller.
Pearson Education Asia, 2000.
Mike Predko.
4. Lecture notes on digital electronics by Professor Mwangi.

Web sources:
1. www.ams2000.com/stepping101
2. www.motioncontrol.com
3. www.electojects.com
4. www.cs.uiowa.edu/jones : - Jones Stepper Motor Tutorial.
5. www.doc.ic.ac.uk/ih/doc/stepper : - Ian Harries on Stepping motors
6. www.atmel.com

Data sheets:

1. Data sheet on ULN2003/2004.


2. Data sheet on the 8051 Microcontroller.

54

You might also like