In: Electrical Engineering
design a stepper motor in 8051 microcontroller in which stepper motor moves clockwise for some time and stops , then anticlockwise for some times and motor stops. (Code in assembly language needed)
CLOCK WISE DIRECTION
CODE SEQUENCE |
HEX CODE |
STEP INPUT |
||||||
0 |
1 |
1 |
1 |
07 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
0B |
0 |
1 |
0 |
0 |
1 |
1 |
0 |
1 |
0D |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
0 |
0E |
0 |
0 |
0 |
1 |
MOV A,#80
MOV DPTR,#2023
MOVX @DPTR,A
MOV DPTR,#2022
REPEAT: MOV A,#07
MOVX @DPTR,A
LCALL DELAY
MOV A,#0B
MOVX @DPTR,A
LCALL DELAY
MOV A,#0D
MOVX @DPTR,A
LCALL DELAY
MOV A,#0E
MOVX @DPTR,A
LCALL DELAY
SJMP REPEAT
DELAY: MOV R0,#01
LOOP3: MOV R1,#0FF
LOOP2: MOV R2,#0FF
LOOP1: DJNZ R2,LOOP1
DJNZ R1,LOOP2
DJNZ R0,LOOP3
RET
ANTI CLOCK WISE
DIRECTION
CODE SEQUENCE |
HEX CODE |
STEP INPUT |
||||||
0 |
1 |
1 |
1 |
07 |
1 |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
0E |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
0D |
0 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
0B |
0 |
1 |
0 |
0 |
MOV A,#80
MOV DPTR,#2023
MOVX @DPTR,A
MOV DPTR,#2022
REPEAT: MOV A,#07
MOVX @DPTR,A
LCALL DELAY
MOV A,#0E
MOVX @DPTR,A
LCALL DELAY
MOV A,#0D
MOVX @DPTR,A
LCALL DELAY
MOV A,#0B
MOVX @DPTR,A
LCALL DELAY
SJMP REPEAT
DELAY: MOV R0,#01
LOOP3: MOV R1,#0FF
LOOP2: MOV R2,#0FF
LOOP1: DJNZ R2,LOOP1
DJNZ R1,LOOP2
DJNZ R0,LOOP3
RET