Interfacing of A Stepper Motor With An 8051 Microcontroller
Interfacing of A Stepper Motor With An 8051 Microcontroller
Interfacing of A Stepper Motor With An 8051 Microcontroller
ON
SUBMITTED BY:
YOGENDER KUMAR ARYA – 0931562808 (ECE-S3)
CERTIFICATE
This is to certify that Project Report titled “INTERFACING OF A
STEPPER MOTOR WITH AN 8051 MICROCONTROLLER”,
which is submitted by following students of Bachelors in Technology
in Electronics and Communication Engg. Of NORTHERN INDIA
ENGINEERING COLLEGE, NEW DELHI, under my supervision.
Projectee:
ACKNOWLEDGEMENT
We feel highly privileged to express our deep sense of gratitude to
all those who helped us during our project work. We would like to
express our grateful thanks for the help and advice given to us by
………… , HOD ECE Dept., for their valuable guidance in our
project.
Date:
APPROVED BY:
HOD……
OVERVIEW
In our project we have explained how to control and run a stepper motor
through microcontroller interfacing. The circuit incorporates a small high
quality stepper motor combined with a series of driver IC to enable
P89V51RD2FN microcontroller in controlling of the stepper motor.
PART 1
INTRODUCTION
Stepper motors are used in a variety of applications, including high and low
propulsion technology, computer peripherals, machine tools, robotics, etc.
The interest in this system has been steadily increasing requirements for
accuracy and repeatability while at the same time placing ever tighter
demands on the maximum and constancy of speed as well as position
resolution. However it has a non-linear and coupled dynamic structure so we
could use different control schemes to make the stepper more competitive to
use in different levels of application.
STEP PULSES
MOTOR CURRENT
The Driver (or Amplifier) converts the indexer command signals into the
power necessary to energize the motor windings. There are numerous types
of drivers, with different current/amperage ratings and construction
technology. Not all drivers are suitable to run all motors, so when designing
a Motion Control System the driver selection process is critical.
Advantages of step motors are low cost, high reliability, high torque at low
speeds and a simple, rugged construction that operates in almost any
environment. The main disadvantages in using a step motor is the resonance
effect often exhibited at low speeds and decreasing torque with increasing
speed.
IMPORTANCE
REQUIREMENTS
Unipolar stepper motor
P89V51RD2FN Microcontroller
L293D Driver IC
Computer Interfacing
PART 2
STEPPER MOTOR
2.1 INTRODUCTION:
A stepper motor is a brushless, synchronous electric motor
that can divide a full rotation into a large number of steps. The motor's
position can be controlled precisely, without any feedback mechanism (open
loop control).
Most electric motors are controlled by a simple on/off, and the reverse
circuitry. On some there is an attempt to roughly control rotational
speed. But a handful of motors use sophisticated control electronics to
enable precise control of rotation, not just of speed but of actual rotational
position. First is the computer controlled stepper motor, and the second is
the computer controlled servo motor.
These two systems are capable of accurate rotational positioning to
within a few degrees; both are used with small motors that can act low
power actuators. The difference between the two is a question of whether the
control loop that determines the positioning is open or closed. The stepper
motor uses an open loop with no feedback, position being determined by a
software counter in the controlling computer.
Stepper motors translate digital switching signals into motion. They
are in consequences widely used in motion, automated machine tools, disk
drives, and a variety of other applications requiring precise motion under
computer control.
Voltage:
Stepper motors usually have a voltage rating. This is either printed
directly on the unit, or is specified in the motor's datasheet. Exceeding the
rated voltage is sometimes necessary to obtain the desired torque from a
given motor, but doing so may produce excessive heat and/or shorten the life
of the motor.
Resistance:
Resistance-per-winding is another characteristic of a stepper motor.
This resistance will determine current draw of the motor, as well as affect
the motor's torque curve and maximum operating speed.
VARIABLE RELUCTANCE:
The variable reluctance motor does not use a permanent
magnet. This type of construction is good in non industrial applications that
do not require a high degree of motor torque.
The variable reluctance motor in the above illustration has four "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.
PERMANENT MAGNET:
The permanent magnet motor, also referred to as a "canstack" motor, has, as
the name implies, a permanent magnet rotor. It is a relatively low speed, low
torque device with large step angles of either 45 or 90 degrees. It's simple
construction and low cost make it an ideal choice for non industrial
applications.
Unlike the other stepping motors, the PM 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 PM 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. It has a 90degree /pulse
step angle.
HYBRID:
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.
The type of motor determines the type of drivers, and the type of translator
used. Of the permanent magnet stepper motors, there are several "sub
flavors" available.
In this project we use unipolar stepper motor which has five or six
wires and four coils (actually two coils divided by center connections on
each coil). The center connections of the coils are tied together and used as
the power connection. They are called unipolar steppers because power
always comes in on this one pole.
Bipolar Stepper Motors:
Unlike unipolar stepper motors, bipolar units require more complex
driver circuitry. Bipolar motors are known for their excellent size/torque
ratio, and provide more torque for their size than unipolar motors.
Bipolar motors are designed with separate coils that need to be driven in
either direction (the polarity needs to be reversed during operation) for
proper stepping to occur. This presents a driver challenge. Bipolar stepper
motors use the same binary drive pattern as a unipolar motor, only the '0' and
'1' signals correspond to the polarity of the voltage applied to the coils, not
simply 'on-off' signals. Figure 5.1 shows a basic 4-phase bipolar motor's coil
setup and drive sequence.
Variable Reluctance Stepper Motors:
Sometimes referred to as Hybrid motors, variable reluctance
stepper motors are the simplest to control over other types of stepper motors.
Their drive sequence is simply to energize each of the windings in order, one
after the other (see drive pattern table below) This type of stepper motor will
often have only one lead, which is the common lead for all the other leads.
This type of motor feels like a
DC motor when the shaft is spun by hand; it turns freely and you cannot feel
the steps. This type of stepper motor is not permanently magnetized like it’s
unipolar and bipolar counterparts.
2.4 How Stepper Motors Work:
Operation principle of a stepper motor is when we energize a coil
of stepper motor, the shaft of stepper motor (which is actually a permanent
magnet) align itself according to poles of energized coil. So when motor
coils are energized in a particular sequence, motor shaft tend to align itself
according to pole of coils and hence rotates.
Stepper motors, however, behave differently than standard DC motors. First
of all, they cannot run freely by themselves. Stepper motors do as their name
suggests -- they "step" a little bit at a time. Stepper motors also differ from
DC motors in their torque-speed relationship. DC motors generally are not
very good at producing high torque at low speeds, without the aid of a
gearing mechanism. Stepper motors, on the other hand, work in the opposite
manner. They produce the highest torque at low speeds. Stepper motors also
have another characteristic, holding torque, which is not present in DC
motors.
Holding torque allows a stepper motor to hold its position firmly when not
turning. This can be useful for applications where the motor may be starting
and stopping, while the force acting against the motor remains present. This
eliminates the need for a mechanical brake mechanism. Steppers don't
simply respond to a clock signal, they have several windings which need to
be energized in the correct sequence before the motor's shaft will rotate.
Reversing the order of the sequence will cause the motor to rotate the other
way. If the control signals are not sent in the correct order, the motor will not
turn properly. It may simply buzz and not move, or it may actually turn, but
in a rough or jerky manner. A circuit which is responsible for converting
step and direction signals into winding energization patterns is called a
translator. Most stepper motor control systems include a driver in addition
to the translator, to handle the current drawn by the motor's windings.
Stepper motor "step modes" include Full, Half and Micro step. The
type of step mode output of any motor is dependent on the design of the
driver.
FULL STEP:
Standard (hybrid) stepping motors have 200 rotor teeth, or 200 full
steps per revolution of the motor shaft. Dividing the 200 steps into the 360º's
rotation equals a 1.8º full step angle. Normally, full step mode is achieved
by energizing both windings while reversing the current alternately.
Essentially one digital input from the driver is equivalent to one step.
HALF STEP:
Half step simply means that the motor is rotating at 400 steps per
revolution. In this mode, one winding is energized and then two windings
are energized alternately, causing the rotor to rotate at half the distance, or
0.9º's. (The same effect can be achieved by operating in full step mode with
a 400 step per revolution motor). Half stepping is a more practical solution
however, in industrial applications. Although it provides slightly less torque,
half step mode reduces the amount "jumpiness" inherent in running in a full
step mode.
MICROSTEP:
Micro stepping is a relatively new stepper motor technology that
controls the current in the motor winding to a degree that further subdivides
the number of positions between poles. AMS micro steppers are capable of
rotating at 1/256 of a step (per step), or over 50,000 steps per revolution.
2.6 ADVANTAGES:
Stepper motors have several advantages:
2.7 DISADVANTAGES:
Disadvantages are:
a) Fixed increments of motion
b) Low efficiency, driver choice important
c) High oscillation and overshoot to a step input
d) Limited power output
e) Limited ability to handle large inertial loads
f) Friction errors can increase position error
g) Step motor is the resonance effect often exhibited at low speeds and
decreasing torque with increasing speed.
PART 3
MICROCONTROLLER
3.1 INTRODUCTION:
Microcontrollers are "special purpose computers." Microcontrollers do one
thing well. There are a number of other common characteristics that define
microcontrollers. If a computer matches a majority of these characteristics,
then you can call it a "microcontroller":
Microcontrollers are "embedded" inside some other device (often
a consumer product) so that they can control the features or actions of the
product. Another name for a microcontroller, therefore, is "embedded
controller."
Microcontrollers are dedicated to one task and run one specific
program. The program is stored in (read-only memory) and generally
does not change.
Microcontrollers are often low-power devices. A desktop computer
is almost always plugged into a wall socket and might consume 50 watts of
electricity. A battery-operated microcontroller might consume 50 milliwatts.
A microcontroller has a dedicated input device and often (but not
always) has a small LED or LCD display for output. A microcontroller
also takes input from the device it is controlling and controls the device by
sending signals to different components in the device.
In our project we are using P89C51RD2 MICROCONTROLLER.
3.2 P89V51RD2FN
MICROCONTROLLER
The P89C51RD2 is a low-power, high-performance CMOS 8-bit
microcontroller with 8K bytes of Flash programmable and erasable read
only memory (PEROM). The device is manufactured using Philips’ high-
density nonvolatile memory technology and is compatible with the industry-
standard MCS-51 instruction set and pinout. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional
nonvolatile memory programmer. By combining a versatile 8-bit CPU with
Flash on a monolithic chip, the Philips P89V51RD2FN is a powerful
microcomputer which provides a highly-flexible and cost-effective solution
to many embedded control applications.
Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each
pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins
can be used as high impedance inputs.
Port 0 may also be configured to be the multiplexed low order address/data
bus during accesses to external program and data memory. In this mode P0
has internal pull ups.
Port 0 also receives the code bytes during Flash programming, and outputs
the code bytes during program verification. External pull ups are required
during program verification.
Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1
pins are pulled high by the internal pull-ups when ‘1’s are written to them
and can be used as inputs in this state. As inputs, Port 1 pins that are
externally pulled LOW will source current (IIL) because of the internal pull-
ups. P1.5, P1.6, P1.7 have high current drive of 16 mA. Port 1 also receives
the low-order address bytes during the external host mode programming and
verification.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port
2 pins they are pulled high by the internal pull ups and can be used as inputs.
As inputs, Port 2 pins that are externally being pulled low will source current
(IIL) because of the internal pull ups. Port 2 emits the high-order address
byte during fetches from external program memory and during accesses to
external data memory that use 16-bit addresses. In this application, it uses
strong internal pull ups when emitting 1s. During accesses to external data
memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of
the P2 Special Function Register. Port 2 also receives the high-order address
bits and some control signals during Flash programming and verification.
Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port
3 pins they are pulled high by the internal pull ups and can be used as inputs.
As inputs, Port 3 pins that are externally being pulled low will source current
(IIL) because of the pull ups. Port 3 also serves the functions of various
special features of the AT89C51 as listed below:
Port 3 also receives some control signals for Flash programming and
verification.
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input
(PROG) during Flash programming. In normal operation ALE is emitted at a
constant rate of 1/6 the oscillator frequency, and may be used for external
timing or clocking purposes. Note, however, that one ALE pulse is skipped
during each access to external Data Memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location
8EH. With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-
disable bit has no effect if the microcontroller is in external execution mode.
PSEN:
Program Store Enable is the read strobe to external program memory. When
the microcontroller is executing code from external program memory, PSEN
is activated twice each machine cycle, except that two PSEN activations are
skipped during each access to external data memory.
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at
0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA
will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin
also receives the 12-volt programming enable voltage(VPP) during Flash
programming, for parts that require12-volt VPP.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2:
Output from the inverting oscillator amplifier.
PART 4
L293D DRIVER IC
4.1 INTRODUCTION:
The Device is a monolithic integrated high voltage, high current four
channel driver designed to accept standard DTL or TTL logic levels and
drive inductive loads (such as relays solenoides, DC and stepping motors)
and switching power transistors. To simplify use as two bridges each pair of
channels is equipped with an enable input. A separate supply input is
provided for the logic, allowing operation at a lower voltage and internal
clamp diodes are included. This device is suitable for use in switching
applications at frequencies up to 5 kHz..
PART 5
OVER ALL SYSTEM
5.1 BLOCK DIAGRAM
5.2 HARDWARE
Interfacing
Interfacing is an important task to be accomplished in almost all
automation applications. The digital signals are to be generated to make the
hardware run as per the instructions of program.
In the present application, the programming is done in .C. programming
language. .C. is chosen for its simplicity and ruggedness. It offers simple
methods to interact with the serial port through which the interfacing is
done.
The driver circuit used for the purpose of interfacing consists of Quadruple
half - H-bridge L293D driver IC.
The signals from the µ-controller are amplified by the L293D which can
drive loads up to 600mA. It's input is TTL as well as DTL compatible and
the output is up to 36VDC. The stepper motor is driven in full step mode, for
every step single windings is energised.
PROGRAMMING
#include <REG2051.H>.
#define s0 P1^1
#define s1 P1^2
#define s2 P1^3
#define s3 P1^4
#define en12 P1^0
#define en34 P1^6
void delay();
void main()
{
en12=en34=1;
while(1)
{
s3=s2=1;
s1=s0=0;
delay();
s3=s0=0;
s2=s1=1;
delay();
s3=s2=0;
s1=s0=1;
delay();
s3=s0=1;
s2=s1=0;
delay();
}
}
void delay()
{
unsigned int i;
for(i=0;i<3000;i++);
}
CONCLUSION
The project was successfully completed after a lot of efforts and work hours.
This project underwent controlling of stepper motor, compiling, debugging,
removing errors, make it bug free, adding more facilities & interactivity,
make it more reliable and user friendly.
Guidance was taken from faculty; help from the friend were accepted at the
various project development phases. Many books related to controlling of
microcontroller were referred to get the desired results.
REFERENCES
SITES:
http://www.google.com
http://www.wikipedia.com
BOOKS: