Escolar Documentos
Profissional Documentos
Cultura Documentos
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.
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.
Clock 6 MHz
HEX Inverter
Right Motor
Analog Comparators
Threshold Voltage
Sensor Array
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
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
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
=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
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
L4 L3 L2 L1 R1 R 2 left 1 1 0 0 1 1
R 3 1
R 4 1 Right
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
L4 L3 L2 L1 R1 R 2 left 1 0 0 1 1 1
R 3 1
R 4 1 Right
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
L4 L3 L2 L1 R1 R 2 left 1 1 1 1 0 0
R 3 0
R 4 1 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
L4 L3 L2 L1 R1 R 2 left 1 1 1 0 0 0
R 3 0
R 4 1 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 0 0 0 0 1
R 3 1
R 4 1 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 0 0 0 0 0
R 3 0
R 4 1 Right
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
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
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
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.
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
L4 L3 L2 L1 R1 R 2 1 1 1 0 1 1
R 3 1
R 4 1
CODE
//PORTB=0x39; stop //PORTB=0x18; straight //PORTB=0x10;Left //PORTB=0x08; Right //
PORTB=0x21; Reverse
#define FWD 0x18 #define REV 0x21 #define R 0x08 #define L 0x10 #define STOP 0x39
#define MAX 3 #define HMAX 1 void move (unsigned char dir,unsigned char delay,unsigned char
power);
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); }