I am ready with my first Real Working Project.. Line Follower Robot.
Its simple..... It follows black line on a comparatively brighter surface.
I have used AT89c2051 controller, Infrared Sensors HO4R, Geared DC Motor to deliver 2KGcm at 100 RPM and L293D for driving motors.
Here is circuit diagram:
Here is PCB Design:
And PCB for Sensors:
A Little of Code:
ORG 0000H
MAIN:
REPEAT:
MOV A,#0FH
MOV P3,A
NOP
NOP
NOP
NOP
MOV A,P3
;CPL A
ANL A,#0FH
CJNE A,#00001111B,AA0 ;Back,Right,Front,Left ;left,front,right,back
LCALL STOP
JMP REPEAT
AA0:
CJNE A,#00001110B,AA1 ;left,front,right,back
;LCALL LEFT
LCALL FORWARD
JMP REPEAT
AA1:
CJNE A,#00001101B,AA2
;LCALL FORWARD
LCALL RIGHT
JMP REPEAT
AA2: ;left,front,right,back
CJNE A,#00001100B,AA3
;LCALL FORWARD
LCALL RIGHT
JMP REPEAT
AA3:
CJNE A,#00001011B,AA4
;LCALL RIGHT
LCALL FORWARD
JMP REPEAT
AA4:
CJNE A,#00001010B,AA5
;LCALL RIGHT
LCALL FORWARD
JMP REPEAT
AA5:
CJNE A,#00001001B,AA6
LCALL FORWARD
JMP REPEAT
AA6:
CJNE A,#00001000B,AA7 ;Back,Right,Front,Left
LCALL FORWARD
JMP REPEAT
AA7:
CJNE A,#00000111B,AA8
;LCALL FORWARD
LCALL LEFT
JMP REPEAT
AA8:
CJNE A,#00000110B,AA9
LCALL LEFT
JMP REPEAT
AA9:
CJNE A,#00000101B,AA10
;LCALL FORWARD
LCALL RIGHT
JMP REPEAT
AA10:
CJNE A,#00000100B,AA11
;LCALL LEFT
LCALL RIGHT
JMP REPEAT
AA11:
CJNE A,#00000011B,AA12
;LCALL RIGHT
LCALL FORWARD
JMP REPEAT
AA12:
CJNE A,#00000010B,AA13
;LCALL RIGHT
LCALL FORWARD
JMP REPEAT
AA13:
CJNE A,#00000001B,AA14 ;Back,Right,Front,Left ;left,front,right,back
;LCALL RIGHT
LCALL FORWARD
JMP REPEAT
AA14:
CJNE A,#00000000B,AA15
LCALL FORWARD
JMP REPEAT
AA15:
JMP REPEAT
FORWARD:
MOV A,#11011011B
MOV P1,A
LCALL DELAY
MOV A,#00H
MOV P1,A
RET
RIGHT:
MOV A,#11010111B
MOV P1,A
LCALL DELAY1
MOV A,#00H
MOV P1,A
RET
LEFT:
MOV A,#11101011B
MOV P1,A
LCALL DELAY1
MOV A,#00H
MOV P1,A
RET
BACKWARD:
MOV A,#11100111B
MOV P1,A
LCALL DELAY
MOV A,#00H
MOV P1,A
RET
STOP:
MOV A,#00000000B
MOV P1,A
LCALL DELAY
MOV A,#00H
MOV P1,A
RET
DELAY:
MOV R4,#1H
DDS32:MOV R3,#0FH
DDS31:MOV R2,#0FH
DDS3:DJNZ R2,DDS3
DJNZ R3,DDS31
DJNZ R4,DDS32
RET
DELAY1:
MOV R4,#10H
DDS132:MOV R3,#0FH
DDS131:MOV R2,#0FH
DDS13:DJNZ R2,DDS13
DJNZ R3,DDS131
DJNZ R4,DDS132
RET
END
;*************************************************************************
;
; N O T E S
;
; 1. RIGHT SENSOR P3.1
; 2. FRONT SENSOR P3.2
; 3. LEFT SENSOR P3.3
; 4. BACK SENSOR P3.0
; left,front,right,back
; 5. LED P1.7
; 6. SWITCH P1.6
; 7. IN4 P1.5
; 8. IN3 P1.4
; 9. IN2 P1.3
; 10. IN1 P1.2
; 11. EN34 P1.1
; 12. EN12 P1.0
;
; 13. Logic 1 ---> White Surface
; 14. Capture zeros.... i.e. zero means on line
;
;**************************************************************************
And it works.... :-)
No comments:
Post a Comment