Uploaded by dignity610

interfacing of stepper motor using 8051 (dr.ajao)

advertisement
MICROPROCESSOR IN CONTROL
Title : INTERFACING OF STEPPER MOTOR TO 8051 MICROCONTROLLER
BACKGROUND :
Stepper motor is brushless DC motor, which can be rotated in small angles, these angles are called steps.
Generally stepper motor use 200 steps to complete 360 degree rotation, means its rotate 1.8 degree per
step. Stepper motor used in many devices which needs precise rotational movement like robots,
antennas, hard drives etc. We can rotate stepper motor to any particular angle by giving it proper
instructions.
What is a stepper motor?
A motor, in general, is a device that converts electrical energy into mechanical energy.
As the name suggests, a stepper motor is a device that does the same task as above but, in steps.
It is a brushless, synchronous electric motor that can divide a complete rotation into a number of steps.
Stepper motors generally have a permanent magnet shaft (rotor), and it is surrounded by a stator.
The best feature of this type of motor is that the motor’s angular position can be accurately controlled
without any feedback mechanism, as long as the motor is not oversized. (From a designer’s point of view
the sizing of the motor is essential, if the stepper motor is undersized then it will not be able to
withstand load and if it is oversized then it becomes too expensive for its purpose.).
Therefore, it works in a simple accurate open-loop system, where the output is directly dependent on
the input.
A stepper motor rotates at small angles to complete 360 degrees rotation, these small angles are called
steps, hence the name Stepper Motor. Typically, a stepper motor consists of 200 steps.
200 Steps = 360 degrees
1 Step = ‘x’ degrees
x = 360 / 200 = 1.8 degree
Therefore, every step is 1.8 degrees.
The high and low pulses are provided to the stator coil of the stepper motor.
1
Here we’re using a 4-coil stator. The angle of each step is decided by the steps in the rotor and its
alignment with the stator.
In the case of a 200-steps motor, the step angle is 360 / 200 = 1.8 degrees, and in the case of an 8-steps
rotor, the step angle is 360 / 8 = 45 degrees. Here’s a simulation.
200 Steps Rotor: Step angle = 1.8 degrees
8 Steps Rotor: Step
Important terminology
motor
angle = 45 degrees
related to a stepper
2
1. Revolutions Per Minute (RPM): This term is often used when the number of rotations is to be
found per minute. It determines the frequency with which the motor is rotating.
2. Step Angle: Since a stepper motor rotates one step at a time, the angle it sweeps in one step is
called the Step Angle. For a rotor having 200 steps/teeth, it is equal to 1.8 degrees and for a
motor having 4 steps, it is equal to 90 degrees.
3. Steps per revolution: This parameter decides the number of steps required to complete one
revolution and is determined by 360 / (Step Angle).
4. Steps per second: As suggested by the name it determines the steps covered in one second and
is given by
Steps per second = RPM x steps per revolution / 60.
Type of Stepper Motor
Stepper motors are broadly divided into two types :
1. Unipolar stepper motor
2. Bipolar stepper motor
Unipolar stepper motor
The unipolar stepper motor has five or six wires out of which four wires are joined to one of the ends of
each of the four stator coils. The connections at the center of the coils are joined together and are
connected to the 12V supply. They are called unipolar steppers because power always comes in on this
one pole.
Bipolar
stepper motor
The
motor
wires
bipolar stepper
usually has four
coming out of it.
3
Unlike unipolar steppers, bipolar steppers have no common center connection. They have two
independent sets of coils instead.
We’re
going to use the
unipolar
stepper motor in
our further discussions since it is easier to operate, widely available, and usually the cheapest means to
get precise angular moments.
What are the components of a stepper motor
Components of Stepper
1. Stator: The stator is made up of four coils, that are energized by the pulses from a
microcontroller or a stepper controller.
4
2. Rotor: The number of steps of the rotor and its alignment with the stator determines the step
angle and steps per revolution.
3. Permanent magnets: The rotor is mounted on a permanent magnet that attracts or repels the
stator coils and hence the propulsion occurs.
Working of a stepper motor
A stepper motor works on the principle of magnetic attraction and repulsion. The coils of stators are
placed on electromagnets which are energized and de-energized by the pulses of the microcontroller
which creates magnetic north and south on the stator poles. The rotor is mounted on a permanent
magnet having a permanent N and S marked.
The sequence in which the coils are excited to form the poles causes the rotor to attract one pair of
stator pole and repel the other causing motion in the shaft and the load connected to it.
Components required for interfacing a Stepper motor with 8051 Microcontroller
S/n
Components
required
Description
No's
1.
8051 Microcontroller
AT89S51/
AT89C51/Any other
compatible variants
1
2
Stepper Motor
12v
1
3
Current Driver IC
ULN2003A
1
4
DC Power Supply
12V
1
5
Oscillator Crystal
12Mhz
1
5
6
Capacitor (1)
22pF
2
7
Capacitor (2)
10uF
1
8
Resistor/ Pot
10kohm
1
9
Connecting wires
As per the
requirements
As per the
requirements
Circuit diagram to interface stepper motor to 8051
Schematic circuit diagram to interface stepper motor to 8051.
Interfacing stepper motor to 8051 Microcontroller
We are using Port 2 of 8051 microcontroller to generate high and low pulses and using a current
amplifier IC i.e. ULN2003a to amplify the current to drive the stepper motor using the pulse of the
microcontroller. On the basis of the way the coils are energized, a Unipolar Stepper motor can be
classified into three categories:



Wave Drive Mode
Full Drive Mode
Half Drive Mode
Wave drive mode
6
In this mode only one coil is energized at a time, all the four coils are energized one after the other in a
sequence. In terms of power consumption, this mode is a power saver, but the torque produced is less
compared to the full drive mode. In the following table, A-B-C-D refers to the stator coils, that are to be
energized sequentially in the manner and ‘1’s and ‘0’s refers to ‘HIGH‘ and ‘LOW’ states.
Steps
A
B
C
D
Hex
1
1
0
0
0
0*08
2
0
1
0
0
0*04
3
0
0
1
0
0*02
4
0
0
0
1
0*01
Full Drive mode
In this mode two coils are energized at a time, i.e. Logic 1 is given to 2 coils at the same time, this results
in higher torque, but the power consumption also increases and precision of the stepper motor
increases two folds.
Steps
A
B
C
D
Hex
1
1
1
0
0
0*0C
2
0
1
1
0
0*06
3
0
0
1
1
0*03
4
1
0
0
1
0*09
Half Drive Mode
This mode works on the alternate energizing principle, i.e. at one moment only 1 coil is energized, but in
the very next moment 2 coils are energized, then again back to 1. This sequence is repeated so as to
make the motor more power-efficient while maintaining the high torque and increase the angular
rotation of the motor.
Steps
A
B
C
D
Hex
7
1
1
0
0
0
0*08
2
1
1
0
0
0*0C
3
0
1
0
0
0*04
4
0
1
1
0
0*06
5
0
0
1
0
0*02
6
0
0
1
1
0*03
7
0
0
0
1
0*01
0
0
1
0*09
8
1
Why are we using ULN2003A driver?
A Stepper motor consumes a current of 0.1 – 1 A during step rotation with the load. An AT89c51
produces a maximum current of 0.045A through the ports. Therefore, the pulses sent from Port 2 are
not sufficient to run a stepper motor. Hence, we cannot directly interface stepper motors with
microcontrollers like AT89C51 microcontroller.
There are two solutions to this problem:
To use a motor driver like L239D
Or, to use a current amplification IC like ULN2003A, here we choose the latter.
To overcome the stepper motor’s power constraint, we need an external power source that can drive
heavy loads and supply enough power for the operation of the stepper motor. ULN2003 is an IC
containing pairs of Darlington configuration of transistors. ULN2003 takes low power input and outputs
a signal with greater power.
The Darlington transistor is made up of two PNP or NPN BJTs by connecting together where the emitter
of the PNP transistor is connected to the base of the other PNP transistor to create a sensitive transistor
with high current gain used in many applications where switching or amplification is crucial.
Step by step connections
8
 Step 1: If you’re using Proteus or and other simulation software or even hardware, select the
AT89C51 or AT89S51 microcontroller or any other compatible variant. (The AT89C51 is an 8-bit
microcontroller from the Atmel family which works with the 8051 architecture.)
 Step 2: Connect a 12 MHz oscillator between pin 18 and 19.
 Step 3: Connect two capacitors of 22pF, with one terminal on either side of the oscillator and
the other terminal to ground, as shown below.
 Step 4: Set Pin 31, i.e., EA pin to HIGH by connecting it to the +5V DC source.
 Step 5: Now, to make the RESET circuit, connect Pin 9 (RST) to +5V through a capacitor of 10µF
and connect the same pin to +0V (GND) through a 10kΩ resistor or a potentiometer.
 Step 6: Connect the 4 pins of Port 2 to the input side of ULN2003a IC as follows,
P2.0 to 1B
P2.1 to 2B
P2.2 to 3B
P2.3 to 4B
 Step 7: Connect the outputs of the ULN2003a to the 4 wires of the stepper motor as shown in
the circuit diagram below. Note: Please note that while connecting the pins 1C, 2C, 3C, and 4C to
the wires of the stepper, try all the possible connections. If the motor starts oscillating instead of
rotating, then carefully look for the 4 coil wires and 2 common wires.
 Step 8: Connect the two common wires of the stepper motor and Pin 9 of the IC to a 12V DC
supply.
That’s it for the connections part, now you can move onto the code specific portion to interface it to
8051 Microcontrollers.
Assembly language program to interface stepper motor with 8051
// Wave Drive Mode
ORG 00H
MOV TMOD, #01H
MAIN:
MOV P2, #08H
ACALL DELAY
MOV P2, #04H
9
ACALL DELAY
MOV P2, #02H
ACALL DELAY
MOV P2, #01H
ACALL DELAY
SJMP MAIN
// To generate a delay of 200 *1 ms
DELAY:MOV R0,#200 //change this value to required delay in ms
BACK: MOV TH0,#0FCH
MOV TL0,#018H
SETB TR0
wait: JNB TF0,wait
CLR TR0
CLR TF0
DJNZ R0,BACK
RET
END
// Full Drive Mode
ORG 00H
MOV TMOD,#01H
MAIN:
MOV P2, #0CH
ACALL DELAY
10
MOV P2, #06H
ACALL DELAY
MOV P2, #03H
ACALL DELAY
MOV P2, #09H
ACALL DELAY
SJMP MAIN
// To generate a delay of 200 * 1 ms = 200ms
DELAY:MOV R0,#200 //change this value to required delay in ms
BACK: MOV TH0,#0FCH
MOV TL0,#018H
SETB TR0
wait: JNB TF0,wait
CLR TR0
CLR TF0
DJNZ R0,BACK
RET
END
// Half Drive Mode
ORG 00H
MOV TMOD,#01H
MAIN:
MOV P2, #08H
11
ACALL DELAY
MOV P2, #0CH
ACALL DELAY
MOV P2, #04H
ACALL DELAY
MOV P2, #06H
ACALL DELAY
MOV P2, #02H
ACALL DELAY
MOV P2, #03H
ACALL DELAY
MOV P2, #01H
ACALL DELAY
MOV P2, #09H
ACALL DELAY
SJMP MAIN
// To generate a delay of 200 *1ms
DELAY:MOV R0, #200 //change this value to required delay in ms
BACK: MOV TH0, #0FCH
MOV TL0, #018H
SETB TR0
wait: JNB TF0, wait
CLR TR0
CLR TF0
12
DJNZ R0, BACK
RET
END.
Observation
 I observed in wave drive mode only one coil is energized at a time, all the four coils are
energized one after the other in a sequence.
 I observed in full drive mode two coils are energized at a time. Thus, here two opposite coils are
excited at a time.
 Also in half step drive, coils are energized alternatively. Thus it rotates with half step angle
Conclusion
In conclusion, stepper motor is applicable to the following machines or devices :







Used in Dot Matrix Printer.
Used in tape drives, floppy disc drives, printers, and electric watches.
Metal cutting & Metal forming machines.
Used in textile industries.
Used in integrated circuits fabrications
This circuit can be used in the robotic applications.
This can also be used in mechantronics applications.
Reference
Copyright © 2022 Circuit Digest. All rights reserved.
TECHNOBYTE © 2016 - 2022 All rights reserved.
Copyright © 2022 Electronicshub.org.
13
Download