Faculty of Information Engineering & Technology Electrical & Electronics Department

Line Tracking Robot Using Infrared cells For Lane keeping assistant purposes

Bachelor Thesis

By: Mina Fawzy Adly Habib Supervisor: Dr. Tallal El- Shabrawy Submission Date: February 1 , 2010
st

This is to certify that: (i) (ii) The thesis comprises only my original work towards the Bachelor Degree. Due to acknowledgment has been made in the text to all other material used.

Mina Fawzy Adly

______________

Abstract:

In road-transport terminology, a lane departure warning system is a mechanism designed to warn a driver when the vehicle begins to move out of its lane on freeways and arterial roads. These systems are designed to minimize accidents by addressing the main causes of collisions: driving error, distraction and drowsiness. In 2009 the National Highway Traffic Safety Administration (NHTSA) began studying whether to mandate lane departure warning systems and frontal collision warning systems on automobiles. So the aim of this project is to combine the two features together in one intelligent vehicle in hope to design a safer mean of transportation to save lives wasted on roads yearly especially with the increase of the number of cars introduced to the road each year. So the need of such security systems in today's intelligent cars is essential. The project consists of two main phases; First is to design and build a line tracking circuit that keeps the car moving over its given course and automatically corrects the car's course when it is accidently deflected away from the track and if it exits the lane it can remember the last position the line was detected and restore its course, This circuit is controlled by a microcontroller that gets the track's information by four infrared cells mounted in the front of the car, and also controls the motors of the car; in order to gain control to the car's steering and speed. The circuit is built as a PCB (Printed circuit board) in order to ensure the circuit's reliability and make a suitable sized circuit, and also to make it possible to direct the infrared cell to face the track beneath the car. The second phase is to build a frontal obstacle avoider circuit that automatically stops the car and trigger the car's front light and horn once an obstacle is detected among the car's path. Circuit is also built with a PCB technique in order to make it have a reasonable size to be able to mount it in front of the car, and also to ensure circuits reliability.

III

Contents

List of figures ……………………………………………………………………………………….VI Chapter 1 Introduction ……………………………………………………………………..… 1 1.1 1.2 1.3 Project purpose ………………………………………………………………. 2 Required knowledge …………………………………………………….…. 2 Outline …………………………………………………………………………….. 3

Chapter 2 Project basics …………………………………………………………………..…. 4 2.1 Line following robot …………………………………………………………….. 4 2.2 Structure of the robot ………………………………………………………….. 4 2.3 Required components …………………………………………………………. 5 Chapter 3 Line tracking algorithm ………………………………………………………. 6 3.1 Number of cells in the sensors line ………………………………………. 6 3.1.1 Sensors precision ……………………………………………………. 7 3.2 Distance between cells ……………………………………………………….. 8 3.2.1 When robot is centered …………………………………………. 8 3.2.2 Largely spaced cells with devia on ……………………….… 8 3.2.3 Closely spaced cells with devia on …………………………. 9 3.3 Results ……………………………………………………………………………… 10 3.4 Building the cells ………………………………………………………………. 11 3.4.1 Cell implementa on …………………………………………….. 12 3.4.2 Circuit implementa ons of the sensors ………………… 13 Chapter 4 Implementa on of the robot with the microcontroller ……. 14 4.1 Introduc on ……………………………………………………………………… 14

19 4.5 The full schema c of the circuit …………………………….4.1 Architecture of the In System Programmer ………….6 PCB design of the circuit ………………………………………. 36 7. 14 4.4..2 The 8051 Microcontroller ………………………………………………….1.1 Circuit implementa on ……………………………………………………… 32 6.4..1 Possible improvements ……………………………………………………… 36 References ………………………………………………………………………………………… 38 .1 Design and implementa ons ………………………………… 19 4.3..4 Controlling motors using a motor driver ……………….1. 23 4.4.3.3 Program the microcontroller with the ISP ………………………….4. 30 Chapter 6 Obstacle detec on using infrared LEDs …………………………….. 22 4.1 The C code …………………………………………………………………….5 Func oning of the microcontroller …………………………………… 24 Chapter 5 C code for the microcontroller ………………………………………… 25 5.2 PCB design for the obstacle avoider …………………………………… 35 Chapter 7 Conclusion ………………………………………………………………………. 16 4.2 Genera ng PWM to control motors speed ………………………..3 Overview ……………………………………………………………… 20 4.2 Programming the microcontroller ………………………… 18 4..4. 15 4. 33 6. 31 6.2 Opera on of the robot ………………………………………….4 Line following robot circuit ………………………………………………… 19 4.1 Noise effects ………………………………………………………… 32 6. 25 5..2 Stopping the robot when obstacle in range …………. 21 4..4..

. 12 Figure 8: Sensor line readings when robot is on the left ……………………. 17 Figure 12B: The constructed ISP ………………………………………………………… 17 Figure 13: Using of the ISP programmer ……………………………………………. 20 Figure 15: Connec ng motors to the microcontroller using a motor driver ………………………………………………………………………………………………… 21 Figure 16: Full schema c of the robot ……………………………………………. 16 Figure 12A: Connecting the microcontroller with the computer's parallel port ………………………………………………………………………………………………. 11 Figure 6: Sensor line readings when robot is centered ……………………… 12 Figure 7: Sensor line readings when robot is on the right ………………….List of figures Figure 1: Implemented sensors line …………………………………………………… 7 Figure 2: Robot is centered over the line …………………………………………… 8 Figure 3: Largely spaced cells with devia on ……………………………………...…. 9 Figure 5: Sensor cell structure …………………………………………………………. 18 Figure 14: Overview ………………………………………………………………………….. 22 Figure 17A-17B: PCB design of the line following robot ……………………. 23 Figure 18: Motor driver (L293D) ……………………………………………………….. 9 Figure 4: Closely spaced cells with deviation …………………………………….… 13 Figure 10: Atmel AT89S52 Microcontroller ………………………………………… 15 Figure 11: Structure if the In System Programmer ……………………………. 24 .. 12 Figure 9: Circuit of the sensors line …………………………………………………..…..

Figure 19: Rela on between the robot's posi on and the motors speed ………………………………………………………………………………………………. 30 Figure 20: Obstacle detec on technique …………………………………………… 31 Figure 21: Sensor circuit ……………………………………………………………………. 34 Figure 24A-24B: Obstacle avoider PCB design ……………………….…. 33 Figure 23: Connec ng the sensor circuit to the microcontroller using a relay ………………………………………………………………………………………………... 37 .…………… 35 Figure 25: Overall design of the robot ……………………………………………….…. 32 Figure 22: Used NOT gates (74LS04) ………………………………………………..

The control system senses the line beneath the robot and maneuvers it to stay on course using feedback system which is simple but yet effective closed loop system. 1 . If every vehicle on the road follows these security systems even in a multi-lane freeway then the collision possibility will be almost zero percent. Practical applications of the line follower robot: Lane keeping assistant of cars running on the road (lane departure warning system). guidance systems for industrial robots. Such robot also enjoys the ability of detecting any object on its path. the line of the course that the robot follows is black with white background or vice versa. And hence tomorrow's vehicle will be automatically driven with no need for a driver. If the robot detects any object within its given course it instantly stalls the whole vehicle and never continues its course until it is confirmed to the microcontroller that the object is no longer in the robot's course.Chapter one Introduction: The increase of traffic collisions every year around the world has led the world's largest car manufactures to start developing more intelligent cars. this will lead us to develop a line following robot that applies these simple but yet reliable security systems. In order to develop such car new security systems has to be implemented within the car to automatically correct the driver's fault controls if his/her controls will lead the car to exit its course or even to avoid possible collision when there is an obstacle is detected in the car's course. The line follower robot is a self-operated robot that detects and follow the line.

Depending on the condition of the sensors readings. each cell consists of infrared emitter and an infrared receiver lying just above the floor. PCB skills (Printed circuit board) may be also required so that the designed circuit can be manufactured in a way to make it possible to have a well fitted and reliable circuit perfectly connected to the robot.1.1 Project purpose In this project the simulation for the lane keeping assistant and the collision avoider requires to build line following robot that can also avoid obstacle if present on course as a prototype for tomorrow's intelligent car systems. so to be able to implement this algorithm a simple approach is to switch ON/OFF the motors depending on which side of the line is applied to the robot. the microcontroller takes corrective action on the motors. this causes the machine to sway from side to side all the time. Using PWM (Pulse Width Modulation) to control the individual speed of motors makes the line following smoother. 1. the error is the offset of the robot from the line read by the infrared sensors and controlling action takes place by applying PWM of the individual motors. 2 . Here. to keep the robot on the line which represents the lane in the actual real conditions. An even better approach is to implement a ProportionalDerivative control to further damp the oscillatory behavior.2 Required knowledge: In order to be able to understand and implement such kind of robot C Programming knowledge is required for the programming of the Atmel (AT89S52) microcontroller used in implementing of this robot also Digital system design is an essential to help in designing and implementing the circuits that controls this robot. and of course Electric circuits skills in order to know how to deal with all of the robot's components and put all phases together. The behavior of the robot largely depends on the algorithm of taking a corrective action when it gets deflected away from the line and restore its position on the line if it accidently exits the line. The main purpose of this robot is to follow a line marked on the ground using infrared sensors. However. The basic design includes four infrared cells. The analog values of the infrared cells are then read and sent to a comparator to have a binary value to detect if the robot lie above the line or not.

Chapter seven will basically be about conclusion of this project and possible future advances.1. 3 . Chapter five will discuss the source code that controls the microcontroller to apply the line tracking algorithm that was previously discussed in chapter two. Chapter three will be discussing the robot's line tracking algorithm that was used in the implementation of the robot that allows the robot to maneuver over the line. Chapter six will discuss the obstacle avoider algorithm and the circuit used to implement this algorithm. Chapter four will discuss the implementations of the microcontroller circuit of the robot.3 Outline Chapter two discusses the main concepts that contribute in the line tracking/obstacle avoiding robot.

1 Line following robot The line following robot is a prototype of a smart vehicle that can differs from the colors beneath it and take the appropriate decision during its journey according to its position. The two back wheels each is attached to a six volts motor (Right motor and Left motor). 4 . and once these rays are detected the robot stops immediately. The robot also has an infrared emitter and a receiver that is mounted in front of the robot. and a free wheel is mounted in the front middle of the vehicle.2 Structure of the robot The robot is a three wheeled vehicle. finally the architecture of the desired robot should be stated with a briefly discussion of the components that will be used to serve the robot's operation. 2. To make use of the ability of the robot's capability of differing colors beneath it the line following robot can be implemented.Chapter Two Project basics This chapter will basically be all about discussing the concepts that the project is based on. the emitter keeps on sending infrared rays waiting for these rays to be reflected back to its receiver. For example if the robot faces a right turn then the right motor slows down and the left one stays on a certain speed but have to be faster than the right motor. and contrary if a left turn is faced then the left motor slows down and the right one keeps on a certain higher speed. It also have the ability to sense obstacles if found in a certain range and stops completely before it to allow the robot to engage other actions. The two rear motors are clearly responsible for the robot's steering over the line. also to discuss the prototype of the robot that should be implemented. that robot can keep tracking a black line on a white background which in real life situations represents the lane and its white marks 2.

2. LM358) Motor driver (L293D) Infrared LEDs 6 volt motors 5 volts voltage regulator (LM7805) 5 volts relay (5 pins) 5 . The motor driver used is a dual channel motor driver that can control the speed of two motors simultaneously. while white surfaces (uncolored) reflects the light rays. Each sensor cell should contain infrared emitter and receiver. and switch it back on when obstacle is no longer in range of the robot. and once the infrared receiver detects the reflected infra from the sender it feeds a microcontroller connected to it with logic 1 (5 volts) via a comparator acknowledging the microcontroller with current position of the robot. On other hand if the robot faces any obstacle during its course it should be detected also with infrared sensors that also feeds another comparator. so based on this old physics rules the sensors for the line following robot should be implemented. but instead of feeding the microcontroller the comparator feeds a relay that switch of the microcontroller. So the components that should be used for both the line following and the obstacle avoiding features:        Microcontroller (AT89S52 or AT89C52) A comparator (LM324.3 Required components Since that colored surfaces absorbs the light falling on it. Once the microcontroller becomes aware of the robot's position it can now start making decisions on how to control the motor's speed by a motor driver.

the sensors help to provide the maximum number of information about line beneath the robot. First section will be discussing the number of cells in the sensors line. The fourth section will be basically about the control algorithm for the motors to allow the robot to maneuver and steer over the line. Third section will be discussing the idea of building the infrared sensor cells. each cell consists of an IR emitter and an IR receiver. 3. The sensor line helps in gathering the information about the line beneath the robot to provide the microcontroller about the robot's position and help it to navigate across the line and trace it. The line sensor cells act as the robot's eyes of course the more the better.1 Number of cells in the sensors line The sensor line used in the robot consists of four cells. 6 .Chapter Three Line tracking algorithm This chapter will discuss the concept that has been used for the implementation of the line tracking robot. Secondly the distance between each cell that can extremely affect the robot navigation as the spacing between the cells is one of the factors for the robot to predict its position over the line.

Instead of moving smoothly over the line. For example if only two cell were used the robot will only be able to define whether the line is on the left or the right so it is clear that this is a very poor source of information for the robot to know its exact position over the line.1 Sensors precision It is obvious that the sensor line precision and quality is affected by the number of cells used.1. to result in smooth line tracking system.Figure 1 3. hence to make the robot maneuver smoothly over the line there have to be an increase to the number of the cells. the robot will be brutally keep turning to the right and to the left. 7 . Four cells sensor line will provide the controller with acceptable amount of information about the line beneath the robot and give it the opportunity to take actions to correct the robot's position as much as possible.

The closer cells spaced from each other. As it was mentioned before the robot used consists of four cells numbered from one to four from the left to the right. which is the only source of information for the microcontroller that the robot is 10 degrees deviated. indicating that the robot is perfectly centered over the line.2 Largely spaced cells with deviation If the robot cells are greatly spaced from each other and got slightly gets deviated away from the line by an angle of 10 degrees.2.2 Distance between cells One of the issues that affect the sensors line is the cells spacing. 3.3. So the largely spaced cells will not no ce except large errors.1 When robot is centered First situation if the robot is centered over the line then cells two and three will detect the line. This situation is shown clearly in figure three. 8 .2. only cell number four will detect the line. the more will be the resolution of the sensors line. Actually the distance between cells can really affect the robot actions as robot can perform fault maneuvers over the line if they are not closely distanced from each other. In this situation spacing is not very critical just as shown in figure two. which will be more difficult to correct. Following examples will show how distance between cells is a really important factor that should be taken in to consideration in cells spacing. Figure 2 3.

so if the robot is also deviated by the same 10 degrees just as the previous situation but with much more closely located cells. the sensors three and four will notice the line beneath them so the microcontroller can be fed with more information about the line's position beneath the robot just as the situation shown in figure four.3 Closely spaced cells with deviation If the sensors line cells are closely placed. Figure 4 9 .2. this will increase the resolution of the robot.Figure 3 3.

3 Results In general for this differential steering robot it is important to keep the sensor line as far away as possible from the center of the steering which is the back of the robot because this will help to amplify the detected error so the microcontroller can notice it. Also support the sensors line with sufficient amount of cells to have a reliable source of information to the microcontroller.3. and of course it is important to place the sensor cells as close from each other as possible to gain more resolution for the robot. 10 . in order to feed the microcontroller with right information about the line as possible.

The sender IR diode always transmits Infra (Light). but with much lower output current. This is an electrical property of Light Emitting Diodes (LEDs) which is the fact that a LED Produce a voltage difference across its leads when it is subjected to light. and based on the old physics rules that state that a colored surface (Black Line) will absorb the light of different colors. and hence light is reflected over uncolored surfaces. each is basically composed of IR senders and IR receivers. Figure 5 11 . we are going to use a very original technique: we are going to use another IRLED. As if it was a photo-cell. and this mechanism is also used for the obstacle avoiding feature of the robot that will be discussed in details in chapter six. For detecting the reflected IR light.4 Building the cells Cells that are used in this robot are infrared cells. The robot consists of 4 cells each cell consists of an emi er and a receiver. The voltage generated cannot be used generate electrical power and also it can be barley be detected so that’s why an operational amplifier will be used to accurately detect very small voltage changes.3.

And if the sensor detects the white background then light will be reflected. So if the sensors are perfectly centered on the black line with the white background then the microcontroller ports receive as follows in figure 6. indication for the sensor is over the black line. hence logic one will be fed to the microcontroller sent from the Op-amp. Such design means that if sensor detects the black line then logic zero will be fed to the microcontroller sent from the operational amplifier.4. otherwise nothing is detected.3. 19 .1 Cell implementation So based on what was mentioned before about the cell structure. Figure 7 And just as before if the robot is deviated to the left then only the most right sensor will detect the logic Zero (black line). One cell should be implemented by the use of one sender IR LED and another IR LED as a receiver to have it connected to a comparator to detect any slight change of voltage across the LED as an indication for light being reflected ( sensor is over white ). Figure 6 And if the robot is deviated to the right then the microcontroller will receive as follows in figure 7.

R3.3.4.T2.T3. As shown in figure 9 (T1.R2.R4) are the IR receivers that is connected to an op-amp to maximize any detected voltage to +5 volts to be fed to the microcontroller Figure 9 13 .2 Circuit implementa on of the sensors As was mentioned before the designs will two IR LEDs (Senders and Receivers) and a comparator and a potentiometer to adjust the sensor's sensitivity.T4) are the IR transmi ers while (R1.

4. high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. So this requires the circuit be also in control of the motors connected to it via a dual channel motor driver in order to make use of its enables of each channel on each motor (right motor and left motor) to control the speed of the motors by the PWM waveform.asp?part_id=1918 Since the AT89S52 supports the In System Programming (ISP) this will give the ability to reprogram the microcontroller without removing it from the circuit which is a very useful feature for designing and upgrading the programs uploaded to the microcontroller. The device is manufactured using Atmel’s high-density nonvolatile memory technology.com/dyn/products/product_card_mcu.2 The 8051 Microcontroller: The AT89S52 has low-power consumption. 14 . The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer.Chapter four Implementation of the robot with the microcontroller 4.1 Introduc on In order to get benefit of the sensors that was designed and implemented in the previous chapter. and make the decision on how to maneuver the robot over the line. h p://www. circuit with a microcontroller has to be implemented so it can analyze the information provided to it from the sensors line.atmel.

15 .3 Program the Microcontroller with the ISP Since the at89s52 has the ISP ability. a parallel ISP programmer is implemented to be able to program or update the program uploaded on the microcontroller on the circuit without the need to remove it from the system.Figure 10 4.

MOSI.Figure 11 4. 16 . Connec ng both 2 inputs of the AND gates as shown makes it act like a buffer.1 Architecture of the In System Programmer To start using the parallel in system programmer the target device (in this case it is the at89s52) is connected from four main pins (MISO.3. RESET and CLK) to four and gates connected to the parallel port that is attached to the computer. to protect the parallel port.

Figure 12A Figure 12B 17 .

2 Programming the microcontroller To program the microcontroller any ISP programmer software can be used to upload the HEX files to the microcontroller.4.3. The ISP programmer (any version) Figure 13 18 .

When the sensors detect a black line the output of the comparator (LM324) will be low (0 Volt). LM324 (Comparator). the robot completely stops and activates its horn and front lights.4. 19 . the Infrared sensors under the robot detects the black line. then steer the robot on the track to keep it accurately on course.4. 4. The output of the comparator is then sent to the microcontroller as an input to accurately control the steering of the robot. 4. IR Sensors. One free wheel. hence the robot navigation can be controlled according to the information delivered to the microcontroller. According to which of the cells detects the black line the position of the robot on the track can be predicted. during the robot is navigating if it faces an obstacle with the range of 30 cm.2 Operation of the robot Capture the position on the line by the use of the infrared sensors.1 Design and implementa ons The robot was built using the AT89S52 microcontroller. and a plas c chassis or any other material can be used but the lighter the be er. while for white surface the output will be high (5 Volts). Two 6 volts DC motors. L293D (Motor Driver).4. The output of the microcontroller is used to control the motors via the motor driver (L293D).4 Line following robot circuit The circuit's main job is to analyze what the sensors line reads and control the motors to make the robot stay on the line and keep correcting any errors that may occur during the robot's course.

4.3 Overview Figure 14 20 .4.

4.4 Controlling motors using a motor driver Figure 15 28 .4.

4.4.5 The Full schema c of the circuit (Figure 16) 22 .

4. in addition to fabricate much reliable circuit and suitable sized one.4.6 PCB design of the circuit PCB design for such schematic is required to have the ability to mount the infra sensors beneath the robot. (Figure 17A & Figure 17B) 23 .

There have to be difference between the inputs of the channel in order to move the motors across the the outputs of the channel. which are used to turn motors on and off. 24 . then channel will be enabled and the motor should move according to input1 and input 2 or input3 and input 4 for the second channel. The L293D Motor driver has 4 inputs to control the motion of the motors. But if the enable is fed by logic 1. each channel consists of two inputs and one enable which if it was 0 then the channel will be disabled as if the motors are connected to very high impedance. Rapidly switching the voltage between Vs and GND gives an effective voltage between Vs and GND whose value depends on the duty cycle of PWM.4. and two enables one for each motor. To control the speed of the motors a PWM waveform with variable duty cycle is applied to the enable pins of the motor driver. for example if the input1 is fed 1 and input2 is fed 0 the motors moves right and if input 1 is 0 and input 2 is 1 then the motor moves left otherwise motors stay still. Figure 18 The L293D consists of two channels.5 Func oning of the microcontroller The 4 sensors cells are connected to port 0.

max_speed.Chapter five C code for the microcontroller The code used was written in C language. 25 .1 The C code #include <REGX52. unsigned char l1. The code implementation allows the 8051 microcontroller to read the sensor values and define the robot's posi on over the line and control the motors speed by the PWM algorithm that is fed to the motor driver enables to make it maneuver over the line to help it track the line and keep on correcting the robot's errors along the course. } stop(){ P3_0 = 1 .} } fwd(){ P3_0 = 0 . P3_2 = 1 .l2.pwm_l_. delay(unsigned int X){ unsigned int i.speed_amp.pwm.h> #include <math. float line.i++){. P3_5 = 1 .h> unsigned char pwm_r. P3_2 = 1 .counter.l4. for(i=0.pwm_l.max_pwm.l3.line_to_pwm_factor.i<X. P3_4 = 0 . 5.old_line.pwm_r_.

} pivot_right(){ P3_0 = 0 . P3_5 = 1 . P3_2 = 0 . } 26 . //pwm generator TH1 = 0. P3_5 = 1 . //Enable the Timer/counter 0 interrupt TR0 = 1. } setup_timers(){ EA = 1. TMOD = 0X22. //Enable Timer/counter 0 to count ET1 = 1. //Enable Timer/counter 1 to count TH0 = 150. P3_4 = 0 . P3_5 = 0 . ET0 = 1.P3_4 = 1 . //Enable the Timer/counter 1 interrupt TR1 = 1. } pivot_left(){ P3_0 = 1 . P3_4 = 1 . P3_2 = 1 .

//ON cycle }else{ P3_3 = 0. setup_timers(). while(1){ l1 =~ P0_0. //OFF cycle } if (pwm <= pwm_l){ P3_1 = 1. } if (pwm <= pwm_r){ P3_3 = 1. it is relativly slow speed to not have problem 27 . // Trial and error. //ON cycle }else{ P3_1 = 0. if (pwm > max_pwm){ pwm = 0.pwm_gen() interrupt 1{ pwm++. pwm_l = 20. //OFF cycle } } void main(){ max_pwm = 50. with robot's inertia pwm_r = 20. max_speed = 14.

line = line / (l1+l2+l3+l4).5. fwd(). if (pwm_l_ > (max_speed)){ //limit the motor's speed with the "max speed" pwm_l_ = (max_speed).5)). if ((l1+l2+l3+l4) != 0) { //one of the sensors if seeing the line old_line = line. } pwm_l = pwm_l_+2.//Returns the largest integral value pwm_r_ = floor(((9-line)*line_to_pwm_factor+0. } if (pwm_r_ > (max_speed)){ pwm_r_ = (max_speed).5)). l4 =~ P0_3. pwm_l_ = floor((line*line_to_pwm_factor+0.l2 =~ P0_1. l3 =~ P0_2. if (old_line == line){ if (counter < 255){ counter++. }else { } 28 . // To remember last time line was in range line_to_pwm_factor = (max_speed) / 2. pwm_r = pwm_r_. line = (l1*1) + (l2*2) +(l3*3)+(l4*4).

if (old_line > 2. pwm_l = 30. } } else { if (max_speed > 20){ max_speed--. }} }} 29 .5){ pivot_right(). } } }else{ pwm_r = 30. }else{ pivot_left(). } if (counter > 20) { if (max_speed < 35){ max_speed++.counter = 0.

5.Figure 19 5.2 Genera ng PWM to control motors speed This figure shows a relation between speed of each motor and the position over the line according to the sensor line readings which is numbered from 1 to 4 from le to the right. which is the average of sensors 2 and 3 when they can detect the line. Therefore the line is considered to be at the center of the robot when it reads 2. 30 .

Figure 20 31 .Chapter six Obstacle detection using Infrared LEDs It is the same principle in all Infra-Red sensors used for the line tracking as before. The basic idea is to send infra-red light through IR-LEDs. which is then reflected by any object in front of the sensor in range about 20-30 cm. Such small range is not a big issue as the robot is only used for modeling. but of course much greater range should be implemented for real life situations.

1 Circuit implementa on The sensor should be always ON. meaning that the IR led is constantly emitting Infra in case the robot is faced by an obstacle during it course. According to these outputs of the comparator. Contrary if the ambient light decreases (Obstacle in range) then the output of the comparator will be low (Zero Volt). then it is clear that it is required to gain the exact different outputs.1. To be able to gain the required output a NOT gate has to be used to invert the outputs. 32 . Using more than one NOT gate will allow the robot to do more than one action when it faces an obstacle. hence when obstacle is detected by the robot the output of the comparator will be zero volt (red LED will be off). Figure 21 6.6. as it is required to have a +5 volts output when an obstacle in range and stay Zero if no obstacle is in range. which means there will be always +5 Volts at the output.1 Noise effects Due to the presence of indoor ambient light that affects the robot. but the output of the NOT gate will be +5 volts. the output of the comparator (Red LED that presents the "OUT") will be always high.

and the third for a relay. and once the obstacle is out of range for the robot the relay is switched back to normally closed providing the microcontroller again with its essential +5 volts allowing the robot to con nue its course. and the second for a buzzer.2 Stopping the robot when obstacle in range The 5 volt relay is the circle of connec on between the obstacle avoider circuit and the microcontroller of the line follower robot. 6. The relay is used as a switch that when it is normally closed it connects the +5 volts generated from the voltage regulator of the microcontroller circuit with the pin 40 of the microcontroller (Vcc of the microcontroller). 33 . but only three gates will be used.1. one for the beamer. Hence when the relay coil is triggered with 5 volts from the NOT gate then the normally closed switch of the relay gets opened switching the relay to normally opened to cut off the 5 volts from the microcontroller's Vcc (pin 40) or in other words "Killing the robot". This device contains six independent gates each of which performs the logic INVERT function. Figure 22 IC 74LS04 contains alone six NOT gates.IC 74LS04 will be used for inver ng the output.

Figure 23 34 .

2 PCB design for the obstacle avoider The obstacle avoider circuit was also built in PCB to be well fitted in the robot's front and have the sensor in face of the obstacle.6. Figure 24A Figure 24B 35 .

but rather via a computer. 36 . It will allow the vehicle to stay in its lane during its whole course to overcome the input errors of the driver. more and more functions of the underlying engine. gearbox and even the steering wheel are no longer directly controlled by the driver by mechanical means. More powerful motors. Use lighter chassis. which receives instructions from the driver as inputs and delivers the desired effect by means of electronic throttle control. This security system will also allow the vehicle be aware of any obstacle found in front of the vehicle by a certain range so it can stop within the safe distance with the obstacle.1 Possible improvements        Use Ultrasonic techniques instead of infrared for obstacle avoiding. Use sharper infrared sensors.Chapter seven Conclusion This line following robot can be used in automated driving systems. Automotive technology matures. Use single power source instead of several batteries. this security system will allow the vehicle correct its course if the driver leaves his lane unintentionally. Apply the project in real car for real life situations. 7. Use low dropout voltage regulator. so it is expected soon to be enjoying a smooth journey in a completely driverless car that can make its own decisions for any expected or unexpected situation. it can also perform any other action such as engaging horn or point a beamer over the obstacle or even change its lane with a free one (no obstacles in the other lane).

The overall design of the robot Figure 25 37 .

ac.th/~kswichit/ROBOT/Follower.sea lerobo cs.pdf 38 .th/~kswichit/LFrobot/LFrobot.html [3] h p://www.sea lerobo cs.html [4] h p://www.uiuc.pdf [6] h p://www.com/tutorials/electronics/8051/line-follower [10] h p://ieee.wa4dsy.yahoo.org/encoder/200002/karllunt.edu/robo cs/index.edu/courses/phys405/P405_Projects/Fall2005/Robot_project_jas eung_.ermicro.scribd.rutgers.com/blog/?p=1097 [8] h p://www.kmitl.groups.org/encoder/200104/benny.com/group/booksbybibin/files/8051_Tutorial.org/encoder/200005/jeffspencer.com/doc/4662053/Line-Following-Robot [9] h p://www.php?op on=com_content&view=ar cle&id=51:linefollowing-kit-tutorial-line-sensor-board&ca d=34:line-following-robotcompetition&Itemid=54 [11] h p://online.htm [2] h p://www.kmitl.ac.botskool.html [5] h p://tech.References [1] http://www.net/robot/linefollower [7] h p://www.pdf [12] http://chaokhun.sea lerobo cs.physics.

Sign up to vote on this title
UsefulNot useful