Você está na página 1de 60

Presented by Rodrigue Tchamna Kang dong-hoon Park jang sung June 2010

Line follower is a machine that can follow a path. The

path can be  visible like a black line on a white surface (or viceversa)  or it can be invisible like a magnetic field.
Sensing a line and maneuvering the robot to stay on

course, while constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system.

APPLICATIONS OF A LINE FOLLOWER


 Automated cars running on roads with embedded magnets;  guidance system for industrial robots moving on shop floor  deliver mail within an office building and deliver medications in a

hospital.

 Tour guides in museums and other similar applications.  following a line in a warehouse (to distribute goods)  the technology has been suggested for running buses and other mass

transit systems, and may end up as part of autonomous cars navigating the freeway. Tour guides in museums and other similar applications.

OBJECTIVES OF A LINE FOLLOWER


 Follow any complex black curves  It should be capable of taking various degrees of turns  The robot must also be capable of following a line even if it has breaks.  The robot must be insensitive to environmental factors such as lighting and noise.  Stop and reverse if the line disappears  Stop if an obstacle is present  So the robot will also need its own illumination source. The weapon here will is to use Infra Red (IR) light.

THE BLOCK DIAGRAM

Clock 6 MHz

Main Power Supply

Motor Power Supply Left Motor

PIC 16F873 Microcontroller

HEX Inverter

H - Bridge DC Motor Control

Right Motor

Analog Comparators

Threshold Voltage

Sensor Array

PIN CONFIGURATION OF THE MICROCONCONTROLLER


IN1 0 1 0 IN2 1 0 1 IN3 1 0 0 IN4 0 1 0 OPERATION BOTH MOTORS FORWARD (MOVE FORWARD) BOTH MOTORS BACKWARD (MOVE BACKWARD) RIGHT MOTOR BACKWARD LEFT MOTOR FORWARD (TURN RIGHT) RIGHT MOTOR FORWARD LEFT MOTOR BACKWARD (TURN LEFT) FULL STOP

CIRCUIT
Normally, all we need in order to track a black line on a white surface is Light Emitting Diode (Emitter) and Photo Diode (Receiver Sensor) However, it would be nice if the signal that we get could be TTL (on or off, 0V, 5V). So to do this one need a comparator

The resistance of the sensor decreases when IR light falls on it. A good sensor will have near zero resistance in presence of light and a very large resistance in absence of light. The potential at point 2 is proportional to Rsensor / (Rsensor + R1). Again, a good sensor circuit should give maximum change in potential at point 2 for nolight and bright-light conditions.

ALGORITHM
The algorithm tries to position the robot such that L1 and R1 both read 0 and the rest read 1. L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center Assumption: The width of the track is at least the distance between 2 sensors that track subsequent sensors the line LED Photo diode sensor 10 12 14 9 ,A, B, C, D, E, F 11 13 15

8 4 2 1 8 4 2 1 L4 L3 L2 L1 R1 R R R 2 3 4 left 1 1 0 0 1 1 1 Right

=0xE7

Center L=1 and R = 1 L=R so go straight forward

L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center sensors that track the line

ALGORITHM

LED Photo diode sensor 10 12 14 9 ,A, B, C, D, E, F 11 13 15

8 4 2 1 8 4 2 1 L4 L3 L2 L1 R1 R R R 2 3 4 left 1 1 0 0 1 1 1 1 Right

Center L=2 and R = 0 L>R so turn left

=0xCF =0x9F

ALGORITHM
The algorithm tries to position the robot such that L1 and R1 both read 0 and the rest read 1. L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center Assumption: The width of the track is at least the distance between 2 sensors that track subsequent sensors the line LED Photo diode sensor

L4 L3 L2 L1 R1 R 2 left 1 1 1 0 0 1

R 3 1

R 4 1 Right

Center L=1 and R = 1 L=R so go straight forward

L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center sensors that track the line

ALGORITHM

LED Photo diode sensor

L4 L3 L2 L1 R1 R 2 left 1 1 0 0 1 1

R 3 1

R 4 1 Right

Center L=2 and R = 0 L>R so turn left

L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center sensors that track the line

ALGORITHM

LED Photo diode sensor

L4 L3 L2 L1 R1 R 2 left 1 0 0 1 1 1

R 3 1

R 4 1 Right

Center L=3 and R = 0 L>R so turn left

L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center sensors that track the line

ALGORITHM

LED Photo diode sensor

L4 L3 L2 L1 R1 R 2 left 1 1 1 1 0 0

R 3 0

R 4 1 Right

Center L=0 and R = 3 R>L so turn Right

ALGORITHM
L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center sensors that track the line

LED Photo diode sensor

L4 L3 L2 L1 R1 R 2 left 1 1 1 0 0 0

R 3 0

R 4 1 Right

Center L=1 and R = 3 R>L so go straight forward

ALGORITHM
L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center sensors that track the line LED Photo diode sensor

L4 L3 L2 L1 R1 R 2 left 1 0 0 0 0 1

R 3 1

R 4 1 Right

Center L=3 and R = 1; L>R so Go LEFTeft

ALGORITHM
L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0; The two Center sensors that track the line LED Photo diode sensor

L4 L3 L2 L1 R1 R 2 left 1 0 0 0 0 0

R 3 0

R 4 1 Right

Center L=3 and R = 3 L=R so go straight forward

1. L= leftmost sensor which reads 0; R= rightmost sensor which reads 0. If no sensor on Left (or Right) is 0 then L (or R) equals 0;

2. If all sensors read 1 go to step 3, else, If L>R Move Left If L<R Move Right If L=R Move Forward Goto step 4

3. Move Clockwise if line was last seen on Right Move Counter Clockwise if line was last seen on Left Repeat step 3 till line is found.

4. Goto step 1.

TRACE HEIGHT

FWD = Forward L = Left R= Right

Remember The motor moves only when the LEDs light (white color) hits the black track and light is reflected back to the photo diode sensor

LED Photo diode sensor

Starting point

0110 0111

Go FWD

0000 1111

Go LEFTeft

0110 0111

Go FWD

1110 0000

Go RIGHT

1110 0100

Go FWD

1111 0001

Go RIGHT

1110 0100

Go FWD

1111 0000

Go RIGHT

1110 0101

Go FWD

1111 0110

Go RIGHT

1110 0100

Go FWD

1111 0110

Go RIGHT

1110 0100

Go FWD

1110 0100

Go LEFT

1111 0100

Go FWD

0110 0000

Go LEFT

1011 0111

Go FWD

0000 1111

Go LEFT

0011 0111

Go FWD

0100 1111

Go LEFT

1010 0111

Go FWD

0110 1111

Go LEFT

0110 0111

Go FWD

0110 1111

Go LEFT

0110 0111

Go FWD

0110 0011

Go LEFT

End point

So Finally
0110 1110 1110 1111 1110 1111 1110 1111 1110 1111 1110 0111 FwD 0000 Right 0100 FwD 0001 Right 0100 FwD 0000 Right 0101 FwD 0110 Right 0100 FwD 0110 Right 0100 FwD 0110 0000 1111 1100 0110 1011 0000 0011 0100 1010 0110 0110 0110 0110 0110 0111 FwD 1111 Left 0100 Left 0100 FwD 0000 Left 0111 FwD 1111 Left 0111 FwD 1111 Left 0111 FwD 1111 Left 0111 FwD 1111 Left 0111 FwD 0011 Left

After reduction,
Left 0000 1111 0110 0100 0110 0110 1111 0100 0000 1111 1111 0011 FWD 0110 1110 1110 1100 1011 0011 1010 0111 0100 0101 0100 0111 0111 0111 Right 1110 0000 1111 0001 1111 0000 1111 0110

Left = 0x (0F, F4, 60, 4F, 6F, 63)

FWD= 0x (67, E4, E5, C4, B7, 37, A7)

Right= 0x (E0, F1, F0, F6)

LIMITATIONS
The width of line to track depends on the disposition and distance between the sensors array and cannot be changed by software. Thin curves are not tracked efficiently, and must be avoided.

RESULT AND CONCLUSION


The Robot could Follow any complex black curves, with various degrees of turns The robot was insensitive to environmental factors such as lighting and noise. It could Stop and reverse when line disappears

y THANK YOU FOR LISTENING

yEXTRACT OF CODE

while (1){ if(PIND!=0xff) { rotpow=255; ldev=rdev=0; if(PD3==0) rdev=1; if(PD2==0) rdev=2; if(PD1==0) rdev=3; if(PD0==0) rdev=4; if(PD4==0) ldev=1; if(PD5==0) ldev=2; if(PD6==0) ldev=3; if(PD7==0) ldev=4;

PD7 PD6

PD5 PD4 PD3 PD2 PD1 PD0

L4 L3 L2 L1 R1 R 2 1 1 1 0 1 1

R 3 1

R 4 1

if(rdev>ldev) move(R,0,Speed1); if(rdev<ldev) move(L,0,Speed2); if(rdev==ldev) move(FWD,0,speed_FWD); }

}; //End While } //End Main

CODE
//PORTB=0x39; stop //PORTB=0x18; straight //PORTB=0x10;Left //PORTB=0x08; Right //

PORTB=0x21; Reverse

#include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h>

#define FWD 0x18 #define REV 0x21 #define R 0x08 #define L 0x10 #define STOP 0x39

#define CW 0x99 #define CCW 0x66

#define SPEED0 255 #define SPEED1 0 #define SPEED2 0 #define SPEED3 0

#define MAX 3 #define HMAX 1 void move (unsigned char dir,unsigned char delay,unsigned char

power);

unsigned int Speed1=1000, Speed2=1000 ,speed_FWD=2000; unsigned char

i,rdev,ldev,ip,delay,dir,power,dirl,history[MAX],hcount=0,rotpow;

int main(void) {

y DDRB=0xff;//motor(PB4->ena_a / PB1->in1 / PB0->in2 y PORTD=0xff; y DDRD=0x00; // DDR = Data Direction Register y TCCR1A=0xA3; y TCCR1B=0x02;//8 Busy

y while (1) y { y if(PIND!=0xff) y { y rotpow=255; y ldev=rdev=0; y if(PD3==0) y rdev=1; y if(PD2==0) y rdev=2; y if(PD1==0) y rdev=3; y if(PD0==0) y rdev=4; y

y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y

if(PD4==0) ldev=1; if(PD5==0) ldev=2; if(PD6==0) ldev=3; if(PD7==0) ldev=4; if(rdev>ldev) move(R,0,Speed1); if(rdev<ldev) move(L,0,Speed2); if(rdev==ldev) move(FWD,0,speed_FWD); //_delay_ms(100); //sleep(10); } else { for(i=0,dirl=0;i<MAX;i++) { if(history[i]==L) {dirl++;} } if(rotpow<160) {rotpow=160;} if(rotpow<255) {rotpow++;} if(dirl>HMAX){move(CW,0,rotpow);} else{move(CCW,0,rotpow);} } OCR1A = Speed1; OCR1B = Speed2; }; //End While } //End Main

void move (unsigned char dir,unsigned char delay,unsigned char power) { PORTB=dir; //Speed1=power; //Speed2=power; if(dir==L || dir==R) { hcount=(hcount+1)%MAX; history[hcount]=dir; } //LSPEED=RSPEED=2000;//power Speed1=Speed2=2000; speed_FWD=2000; //delay_ms(delay); }

Você também pode gostar