Line Follower Mobile Robot

Cruddy Line Follower Mobile Robot and my Serial PIC Programmer

     This is my first Microcontroller Hobby Project. He is “Cruddy” my line follower mobile robot. I named him Cruddy because he’s quite a mess on his structure. It is my first time on building a robot so expect that my soldering skills are not yet that good. The chassis was from a remote controlled toy car. I removed its PCB and made a better PCB. Cruddy follows lines although quite slow to avoid exceeding the line. He moves backward when he exceeds the line. He is  a revision from our first project “MVGAT”, an obstacle and cliff avoider mobile robot. Although MVGAT didn’t functioned well because of sensor defects and power inaccurate design,  his sensor board was changed and few design revised thus Cruddy was made in to success. The PIC Programming Language used here was PIC Assembly.

Cruddy is a self operating robot that detects and follows a line that is drawn on the floor.

Main Components:

1. PIC16F877A – Brain

2. RC Car – Body

3. Sensors – Senses

4. Circuit is powered by – 9v Battery (1 piece)

Motor is powered by – AA Batteries (4 pieces)

5. Motors – 2 DC motors

Schematic for the Mobile Robot (Sensors not included):

Sensors were not included because I used Universal PCB and there’s no need for PCB Layout Designing. Sensors were based from this schematic:

How does it function? When a line is detected the Op-Amp Comparator IC LM358 produces 0v (logic 0) otherwise 5v (logic 1). I then used them in an if-else statement form in Assembly Language. The program code is provided below.

I used three pairs of LEDs and LDRs thus leaving one pin input on the Body’s PCB hanging. You can utilize all the four pins by using 4 pairs of LEDs and LDRs.

Code:


list        p=16f877A    ; list directive to define processor
#include    <p16f877A.inc>    ; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF

CBLOCK 0x0c
FIRST
SECOND
THIRD
ENDC

ORG     0x000
goto    main              ; go to beginning of program

ORG     0x004
; isr code can go here

main

BANKSEL TRISA
MOVLW 0X06
MOVWF ADCON1
MOVLW 0X07
MOVWF CMCON
MOVLW 0XFF
MOVWF TRISA
MOVLW 0X00
MOVWF TRISB
BANKSEL PORTB
MOVLW 0X00
MOVWF ADCON0
BANKSEL PORTB

CHECK:
btfss PORTA, 0
GOTO CHECK2_0
GOTO CHECK2_1

CHECK2_0:
BTFSS PORTA, 1
GOTO CHECK3_0_0                                 ;00x
GOTO CHECK3_0_1                                    ;01x

CHECK3_0_0:
BTFSS PORTA, 2
GOTO FORWARD                                    ;000
GOTO LEFT                                        ;001

CHECK3_0_1:
BTFSS PORTA, 2
GOTO FORWARD                                    ;010
GOTO LEFT                                        ;011

CHECK2_1
BTFSS PORTA, 1
GOTO CHECK3_1_0                                    ;10x
GOTO CHECK3_1_1                                    ;11x

CHECK3_1_0
BTFSS PORTA, 2
GOTO RIGHT                                        ;100
GOTO FORWARD                                    ;101

CHECK3_1_1
BTFSS PORTA, 2
GOTO RIGHT                                        ;110
GOTO BACKWARD                                    ;111

FORWARD:
MOVLW B'00000001'
MOVWF PORTB
CALL DELAY
movlw b'00000000'
movwf PORTB
CALL DELAY
GOTO CHECK

LEFT:
MOVLW B'00000100'
MOVWF PORTB
CALL DELAY
MOVLW B'00000101'
MOVWF PORTB
CALL DELAY
GOTO CHECK

RIGHT:
MOVLW B'00001000'
MOVWF PORTB
CALL DELAY
MOVLW B'00001001'
MOVWF PORTB
CALL DELAY
GOTO CHECK

BACKWARD:
MOVLW B'00001010'
MOVWF PORTB
CALL DELAY
call DELAY
GOTO CHECK

DELAY

MOVLW .40
MOVWF THIRD
MOVLW .250
MOVWF SECOND
MOVWF FIRST
LOOP_.5_MS:
NOP
DECFSZ    FIRST,F
GOTO    LOOP_.5_MS

DECFSZ     SECOND,F
GOTO    LOOP_.5_MS

DECFSZ     THIRD,F
GOTO    LOOP_.5_MS
return

END

Here is a demo of Cruddy:

Watch it on FACEBOOK

For questions, you can leave a comment below.

About these ads

7 responses to “Line Follower Mobile Robot

  1. Hi sir. Could you please send me a copy of the components you used for this project? I can’t view the parts list from your schematic. Also the sensor schematic cannot be seen.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s