EXP NO 5 MA PROGRAMS

ORG 0000H ;start
SJMP MAIN
ORG 0045H
MAIN:MOV R7,#08H ;8 count for half-stepping
MOV DPTR,#0300H ;access external memory location 300H
BACK:CLR A
MOVC A,@A+DPTR ;add contents of memory location pointed by DPTR with
Contents of Accumulator
MOV P1,A ;copy data to port to which motor is connected
ACALL DELAY
INC DPTR ;increment DPTR
DJNZ R7 ,BACK ;decrement R7 till count becomes 0 for one roation of motor
SJMP MAIN

DELAY:MOV R2,#10H ;delay
HERE1:MOV R3,#30H
HERE:DJNZ R3,HERE
DJNZ R2,HERE1
RET

ORG 0300H ;from memory location 300H of external memory
DB 08H,0CH,04H,06H,02H,03H,01H,09H ; clockwise Half-stepping-save data from look up table
END

HALF step-anticlockwise
ORG 0000H ;start
SJMP MAIN
ORG 0045H
MAIN:MOV R7,#08H ;8 count for half-stepping
MOV DPTR,#0300H ;access external memory location 300H
BACK:CLR A
MOVC A,@A+DPTR ;add contents of memory location pointed by DPTR with
Contents of Accumulator
MOV P1,A ;copy data to port to which motor is connected
ACALL DELAY
INC DPTR ;increment DPTR
DJNZ R7 ,BACK ;decrement R7 till count becomes 0 for one roation of motor
SJMP MAIN

DELAY:MOV R2,#10H ;delay
HERE1:MOV R3,#30H
HERE:DJNZ R3,HERE
DJNZ R2,HERE1
RET

ORG 0300H
DB 09H, 01H,03H,02H,06H,04H,0CH,08H ; anti-clockwise Half-stepping
END

FULL step-clockwise:
ORG 0000H
SJMP MAIN
ORG0045H
MAIN:MOV R7,#04H
MOV A,#88H
BACK:MOV P1,A
RL A
ACALL DELAY
DJNZ R7,BACK
SJMP MAIN
DELAY:MOV R4,#0FFH
UP:MOV R3,#30H
GO:DJNZ R3,GO
DJNZ R4,UP
FULL step-anticlockwise:
ORG 0000H
SJMP MAIN
ORG0045H
MAIN:MOV R7,#04H
MOV A,#88H
BACK:MOV P1,A
RR A
ACALL DELAY
DJNZ R7,BACK
SJMP MAIN
DELAY:MOV R4,#0FFH
UP:MOV R3,#30H
GO:DJNZ R3,GO
DJNZ R4,UP

RET
Previous Post Next Post