You are on page 1of 20

Madanapalle Institute of Technology and Science

(UGC-Autonomous)
Department of Electronics and Communication Engineering

Microprocessor and Microcontroller Lab


Expt. 12: STEPPER MOTOR CONTROL USING 8051

Aim:
To develop an 8051 assembly language program
to control the stepper motor in
clockwise/anticlockwise direction and verify it
in the laboratory using Microcontroller Kit.
Assume that the content of internal RAM 20h
control the direction of stepper motor. For
example, for 01h then the motor rotates in
clockwise direction, and for 02h the motor runs
in anticlockwise direction.
Apparatus required:
 8051 Microcontroller Kit (ESA 51)
 Regulated power supply –SMPS
 PS2 Keyboard
 Stepper Motor
 Stepper motor Interface study card
 26 pin ribbon cable connector
8051 Microcontroller Kit
Procedure
1. Use A (Assemble) command to enter the program:
<RESET>A 8000 <ENTER> , and type the program line-by-line using
<ENTER>

2. Use Z (Disassemble) command to verify the program:


<RESET> Z 8000, 8030 <ENTER> (*copy the address and opcode field
from the display to complete the program table)

3. Use M (Memory) command to enter the data at Internal RAM:


<RESET> MI 20 <ENTER> Data1 <ENTER> Data2 <ENTER> …….
Data N <ENTER>

4. Use G (Go and Execute) command to execute the program:


<RESET> G 8000 < ENTER>

5. Use M (Memory) command to verify the result at Internal RAM:


<RESET> MI 30, 31 <ENTER>
THEORY:
Wave Drive Mode:

Steps Coil 1 Coil 2 Coil 3 Coil 4


1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1

Full Drive Mode:

Steps Coil 1 Coil 2 Coil 3 Coil 4


1 1 1 0 0
2 0 1 1 0
3 0 0 1 1
4 1 0 0 1
Half Drive Mode:

Steps Coil 1 Coil 2 Coil 3 Coil 4


1 1 0 0 0
2 1 1 0 0
3 0 1 0 0
4 0 1 1 0
5 0 0 1 0
6 0 0 1 1
7 0 0 0 1
8 1 0 0 1
Address Opcode Label Mnemonics Comments
8000h Org 8000H
MAIN: MOV A, 20H
MOV C,ACC.0
JC FORWARD
MOV C,ACC.1
JC REVERSE
SJMP MAIN

FORWARD: MOV A,#0CH


MOV P2,A
ACALL DELAY
MOV A,#06H
MOV P2,A
ACALL DELAY
MOV A,#03H
MOV P2,A
ACALL DELAY
MOV A,#09H
MOV P2,A
ACALL DELAY
SJMP MAIN
Address Opcode Label Mnemonics Comments
8000h REVERSE: MOV A,#09H
MOV P2,A
ACALL DELAY
MOV A,#03H
MOV P2,A
ACALL DELAY
MOV A,#06H
MOV P2,A
ACALL DELAY
MOV A,#0CH
MOV P2,A
ACALL DELAY
SJMP MAIN

DELAY: MOV R2,#02H


LOOP3: MOV R1,#02H
LOOP2: MOV R0,#0FFH
LOOP1: DJNZ R0, LOOP1
DJNZ R1,LOOP2
DJNZ R2,LOOP3
RET
Algorithm 12:
Conclusion 12:
In this lab activity, 8051 assembly language
program to control the stepper motor in
clockwise/anticlockwise direction has been
developed and the same was verified using
given Microcontroller Kit.

You might also like