AGV

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

ORG 00H

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

; FUNCTIONS TO MOVE MOTORS


NEXT_SENSING_POINT: ; MOVES ROBOT FROM ONE SENSING POINT TO NEXT ONE
;TOTALY 28X4=112 STEPS ARE NEEDED TO MOVE 44CMS ON THE ARENA
MOV R0,#25
LOOP00: ACALL ROBOT_FARWORD
DJNZ R0,LOOP00
RET
BACKWARD: ;IT WILL MOVE THE ROBOT BACKWARD
MOV R0,#30
LOOOP: ACALL ROBOT_BACKWORD
DJNZ R0,LOOOP
RET

TURN_LEFT: ; MOVES ROBOT LEFT EXACTLY 90`


; IT NEEDS 11X2=33 STEPS TO EXACTLY ROTATE ROBOT 90`
MOV R0,#44
LOOP11: ACALL ROBOT_LEFT
DJNZ R0,LOOP11
RET
TURN_RIGHT: ; MOVES ROBOT LEFT EXACTLY 90`
; IT NEEDS 11X3=33 STEPS TO EXACTLY ROTATE ROBOT 90`
MOV R0,#44
LOOP22: ACALL ROBOT_RIGHT
DJNZ R0,LOOP22
RET
ROBOT_FARWORD ; MOVES ROBOT FORWARD ONE STEP BOTH MOTORS FORWARD
; HERE MOVE LEFT MOTOR ANTICLOCKWISE AND RIGHT MOTOR CLOCKWISE
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

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy