AGV
AGV
AGV
INIT:
MOV R4,#99H
MOV R5,#99H
BEGIN:
FRONTSENSOR_POSITION:
MOV C,P1.0
JNC LOOP3
SJMP LEFTSENSOR_POSITION
LOOP3:
ACALL TURN_RIGHT
SETB P1.0
LEFTSENSOR_POSITION:
MOV C,P1.1
JNC LOOP2
SJMP RIGHTSENSOR_POSITION
LOOP2:
ACALL TURN_LEFT
SETB P1.1
RIGHTSENSOR_POSITION:
MOV C,P1.2
JNC LOOP1
SJMP BEGIIN
LOOP1:
ACALL TURN_RIGHT
SETB P1.2
BEGIIN:
ACALL NEXT_SENSING_POINT
SJMP FRONTSENSOR_POSITION
DELAY:
MOV B,#02FH
DELAYLOOP:
ACALL DELAY1
DJNZ B,DELAYLOOP
RET
BIGDELAY:
MOV B,#0FFH
BDELAYLOOP:
ACALL DELAY1
DJNZ B,BDELAYLOOP
RET
DELAY1:
MOV ACC,#0FFH
DELAYLOOP1:
DJNZ ACC,DELAYLOOP1
RET
RET
; END OF ROBOT_FORWARD
ROBOT_BACKWORD ; MOVES ROBOT FORWARD ONE STEP BOTH MOTORS FORWARD
; HERE MOVE LEFT MOTOR CLOCKWISE AND RIGHT MOTOR ANTICLOCKWISE
MOV A,R4
RR A
MOV R4,A
MOV B,A
MOV A,R5
RL A
MOV R5,A
ANL B,#0FH
ANL A,#0F0H
ORL B,A
MOV P0,B
ACALL DELAY
ACALL DELAY
RET
; END OF ROBOT_BACKWORD
ROBOT_RIGHT ; MOVES ROBOT FORWARD ONE STEP BOTH MOTORS FORWARD
; HERE MOVE LEFT MOTOR ANTICLOCKWISE AND RIGHT MOTOR ANTICLOCKWISE
MOV A,R4
RR A
MOV R4,A
MOV B,A
MOV A,R5
RR A
MOV R5,A
ANL B,#0FH
ANL A,#0F0H
ORL B,A
MOV P0,B
ACALL DELAY
ACALL DELAY
RET
; END OF ROBOT_RIGHT
ROBOT_LEFT ; MOVES ROBOT FORWARD ONE STEP BOTH MOTORS FORWARD
; HERE MOVE LEFT MOTOR CLOCKWISE AND RIGHT MOTOR CLOCKWISE
MOV A,R4
RL A
MOV R4,A
MOV B,A
MOV A,R5
RL A
MOV R5,A
ANL B,#0FH
ANL A,#0F0H
ORL B,A
MOV P0,B
ACALL DELAY
ACALL DELAY
RET
; END OF ROBOT_LEFT