AIM: To interface stepper motor with 8051 parallel port and to vary speed of motor, direction of motor.
APPARATUS REQUIRED:
- 8051 Trainer Kit
- Stepper Motor Interface Board
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotor motion occurs in a stepwise manner from one equilibrium position to next.
The motor under our consideration uses 2 – phase scheme of operation. In this scheme, any two adjacent stator windings are energized. The switching condition for the above said scheme is shown in Table.
Clockwise
A1 | B1 | A2 | B2 |
1 | 0 | 0 | 1 |
0 | 1 | 0 | 0 |
0 | 1 | 0 | 1 |
1 | 0 | 1 | 0 |
Anti – Clockwise
A1 | B1 | A2 | B2 |
1 | 0 | 1 | 0 |
0 | 1 | 0 | 1 |
0 | 1 | 0 | 0 |
1 | 0 | 0 | 1 |
In order to vary the speed of the motor, the values stored in the registers R1, R2, R3 can be changed appropriately.
ALGORITHM:
- Store the look up table address in DPTR
- Move the count value (04) to one of the register (R0)
- Load the control word for motor rotation in accumulator
- Push the address in DPTR into stack
- Load FFC0 in to DPTR.
- Call the delay program
- Send the control word for motor rotation to the external device.
- Pop up the values in stack and increment it.
- Decrement the count in R0. If zero go to next step else proceed to step 3.
- Perform steps 1 to 9 repeatedly.
PROGRAM:
START: ORG 4100
MOV DPTR,#4500H
MOV R0,#04
AGAIN: MOVX A,@DPTR
PUSH DPH
PUSH PDL
MOV DPTR,#FFC0H
MOV R2, 04H
MOV R1,#FFH
DLY1: MOV R3, #FFH
DLY: DJNZ R3,DLY
DJNZ R1,DLY1
DJNZ R2,DLY1
MOVX @DPTR,A
POP DPL
POP DPH
INC DPTR
DJNZ R0,AGAIN
SJMP START
DATA:
4500: 09, 05, 06, 0A
RESULT:
Thus the speed and direction of the motor were controlled using 8051 trainer kit.