Table of Contents
ToggleStepper motor is a special type of DC motor. For every electrical pulse given stepper motor rotates certain no. of degrees. It is used in digital control systems such as robotics, dot matrix printers, disk drives etc.
In this article, I will show stepper motor control using 8051 microcontroller and ULN2003.
The stepper motor has a permanent magnet rotor shaft surrounded by a stator. The stator windings are energised by electrical pulses. The most common stepper motors have four stator windings. Series of pulses are applied to the input of stator windings.
The direction of rotation is formed by the stator poles. When the polarity of stator windings is changed the direction of the current also changed and causing the reverse rotation of rotor.
The sequence of pulses applied to each stator winding; the direction of rotating is determined. Degree of rotation is determined by the no. of stator poles and no. of rotor poles.
Circuit Diagram
Following image shows the circuit diagram of interfacing a Stepper Motor with 8051 Microcontroller and ULN2003.
Circuit Components
- AT89C51 Microcontroller
- ULN2003A
- Stepper Motor
- Crystal
- Resistor
- Capacitors
Interfacing Stepper Motor
The ULN2003A is a current driver IC. It is used to drive the current of the stepper motor as it requires more than 60mA of current. It is an array of Darlington pairs. It consists of seven pairs of Darlington arrays with common emitter.
The IC consists of 16 pins in which 7 are input pins, 7 are output pins and remaining are VCC and Ground. The first four input pins are connected to the microcontroller.
In the same way, four output pins are connected to the stepper motor.
Stepper motor has 6 pins. In these six pins, 2 pins are connected to the supply of 12V and the remaining are connected to the output of the stepper motor.
Stepper rotates at a given step angle. Each step in rotation is a fraction of full cycle. This depends on the mechanical parts and the driving method.
Similar to all the motors, stepper motors will have stator and rotor. Rotor has permanent magnet and stator has coil. The basic stepper motor has 4 coils with 90 degrees rotation step. These four coils are activated in the cyclic order.
There are different methods to drive a stepper motor. Some of these are explained below.
Full Step Drive: In this method two coils are energized at a time. Thus, here two opposite coils are excited at a time.
Half Step Drive: In this method coils are energized alternatively. Thus it rotates with half step angle. In this method, two coils can be energized at a time or single coil can be energized. Thus it increases the number of rotations per cycle.
Stepper Motor Control using 8051 Microcontroller
- Initially , switch on the circuit.
- Microcontroller starts driving the stepper motor.
- One can observe the rotation of the stepper motor
- The stepper motor has four wires. They are yellow, blue, red and white. These are energized alternatively as given below.
- In full step driving, use the following sequence.
- To drive the motor in half step angle, use the following sequence
Step-angle of stepper – motor = 1.80
Total numbers of step required = 180O/1.8O = (100)
We are sending 4 pulses and then checking counter. So counter is 100/4 = 25 ;
A B C D ;
1 0 0 1 = 09 D COIL;
1 1 0 0 = 0C C COIL;
0 1 1 0 = 06 B COIL;
0 0 1 1 = 03 A COIL;
Program
STEPPER MOTOR DRIVER USING LOOKUP TABLE
ORG 0000H ; START THE PROGRAM.
MOV R6, 25 ; TAKE COUNTER FOR 180O ROTATION.
UPX: MOV DPTR, #0400H ; LOAD THE STARTING ADDRESS OF LOOKUP. TABLE
MOV R7, #04H ; LOAD THE COUNTER.
H: CLR A ; CLEAR THE A.
MOVC A, @A+DPTR ; TAKE THE CODE FROM LOOKUP TABLE.
MOV P0, A ; SEND THE CODE TO P0.
INC DPTR ; INCREMENT DPTR FOR NEXT CODE.
LCALL DELAY ; DELAY.
DJNZ R7, H ; DECREMENT THE COUNTER.
DJNZ R6, UPX ; REPEAT UNTIL 180O ROTATION.
HERE: SJMP HERE; ; Stop PROGRAM AFTER 180O ROTATION.
ORG 0400H ; STARTING ADDRESS OF LOOKUP TABLE.
DB 0EH ; 0400H = 0EH.
DB 0DH ; 0401H = 0DH.
DB 0BH ; 0402H = 0BH.
DB 07H ; 0403H = 07H.
DELAY: ; DELAY LOOP WITHIN LOOP.
MOV R0, #01FH
UP2: MOV R1, #0FFH
UP1: DJNZ R1, UP1
DJNZ R0, UP2
RET
Alternate Program in Assembly
ORG 0000H ; START THE PROGRAM.
MOV R6, #100 ; SET COUNTER = 100 FOR 100 PULSES = 180.
MOV A, #0EEH ; LOAD THE CODE TO DRIVE THE MOTOR.
UP: MOV P0,A ; SEND CODE TO P0.
LCALL DELAY ; DELAY.
RR A ; ROTATE THE CODE.
DJNZ R6, UP ; REPEAT THE STEPS.
HERE: SJMP HERE ; STOP PROGRAM AFTER 180O ROTATION.
DELAY: ; DELAY LOOP WITHIN LOOP.
MOV R0, #01FH
UP2: MOV R1, #0FFH
UP1: DJNZ R1, UP1
DJNZ R0, UP2
RET
C Language Program Stepper motor Interfacing
#include<reg51.h>
void delay(int ms){
unsigned int i, j;
for(i = 0; i<ms; i++){ // Outer for loop for given milliseconds value
for(j = 0; j< 1275; j++){
//execute in each milliseconds;
}
}
}
void main(){
int rot_angle[] = {0x0C,0x06,0x03,0x09};
int i;
while(1){
//infinite loop
for(i = 0; i<4; i++){
P1 = rot_angle[i];
delay(100);
}
}
}
Recent posts
Related posts:
- Assembler Directives in 8051 Microcontroller
- Features of 8051 Microcontroller
- Memory Organization of 8051 Microcontroller
- Addressing Modes in 8051 Microcontroller
- Instruction Set in 8051 Microcontroller
- Architecture of 8051 Microcontroller
- PSW Register in 8051 Microcontroller | Program Status Word
- The Stack and Stack Pointer in 8051 Microcontroller
- Stack Pointer Data Pointer and Program Counter in 8051 Microcontroller
- Functions of Timing and Control Unit of 8051
- Functions of Ports in 8051 Microcontroller
- Port Structure of 8051 Microcontroller
- Reset Circuit of 8051 Microcontroller
- Power Saving Mode in 8051 | 8051 Power Down and Idle Mode
- 8051 Microcontroller Family
- Program Development Steps in ALP
- Addition of Two 8-Bit Numbers in 8051 Microcontroller
- Addition of Two 8 Bit Numbers with Carry in 8051 Microcontroller
- 8051 Program for Addition of Two 16 Bit Numbers
- 8051 Program for Subtraction of Two 16 bit Numbers
- 8051 Program to Multiply two 8 Bit numbers
- 8051 Program to Divide two 8 Bit numbers
- 8051 Program to Find the Largest Number in An Array
- 8051 Program to Find the Smallest Number in An Array Stored in Internal Memory
- Interrupts of 8051 Microcontroller
- 8051 Program to Find 2’s complement
- Program For 8051 Microcontroller to Unpack A Number
- Unveiling the Power of Assembly Language Programs for 8051 Microcontroller
- Software Development Cycle for Microcontrollers
- Software Development Tools in Embedded System