This action might not be possible to undo. Are you sure you want to continue?
Submitted by Pratheek on January 3, 2010 - 9:06am. In this page I will be telling you what it takes to build a fast line follower. I will be talking about the design, steering mechanisms, sensors, algorithms, etc, which can be implemented. Robot Design The design of the robot plays an important role in deciding its speed and efficiency. The first thing you will want to decide in the design of your robot is the steering mechanism. The various steering mechanisms available are two wheel differential drive, four wheel differential drive, cartype steering mechanism, etc. From my experience, I can tell that two wheel differential drive is the best ± it is easier to build, control and is cheap (requires only two motors). Irrespective of the steering mechanism you use, the most important thing to keep in mind is to place the line sensors as far as possible from the steering wheel. This will give the robot, more time to react. Keeping the distance between the sensors and the steering wheel big, will largely reduce the number of over-shootings by the robot.
In my robot I kept the motor and the sensors at a distance of 12 cm
Another important thing is to keep the centre of mass as close to the ground as possible. This can be done by, placing all the heavy parts (batteries, motors) of the robot as close to the ground as possible. Keeping the centre of mass low will decrease the robot's moment of inertia enabling it to slow down quickly and then accelerate faster in curves. A robot with a high centre of mass will take a lot of time to slow down and a lot more time to accelerate afterwards owing to its high moment of inertia. Sensors
Sensors are the first requirement in the process of line following. There are many sensors one can use for line following ± IR LED and a Photodiode, LED and LDR (photoresistor), etc. When selecting the type of sensor there are three things you need to keep in mind ± response time, sensitivity and ambient light protection. LDRs (photoresistors) are excellent in terms of sensitivity, they can sense not only between two contrasting colours(one dark and one light) but also between two primary colours. Some competitions make the line following tougher by having a white line on a coloured surface (blue, red, grey). In such cases LDRs are the sensors to be used. But there is one big disadvantage in using LDRs - their slow responce time. A LDRs reaction time is around 0.1s. This may not seem much, but if you have a robot using LDRs following a line with a speed of 1 m/s then it will be getting data from the sensor every (0.1 * 1 = 0.1m) 10 cm ! IR LED and photodiodes give good response time. But they have two drawbacks, both of which can be dealt with ± they can sense only between two contrasting colours and they are easily affected by ambient light. Sensitivity can be improved in two ways. One by using LED which emits light of any other color other than the surface color and using a suitable photodiode to sense the light. Basically, if there is a white line on a red surface, you can use any other color LED, say green, to emit light and photodiodes which react to green colour. What happens is the surface, being red, absorbs all the green light emitted by the LED and no light reaches the photodiode. The line on the other hand, being white, reflects all the green light falling on it back to the photodiode. Using this method significantly increases the sensitivity of the sensors. Another way of improving sensitivity is by making modifications to the sensor circuit. Just by varying the resistance of some of the resistors in the sensor circuit, you can tune it to sense between two particular colors. Take a look at www.societyofrobots.com/schematics_infraredemitdet.shtm . The second draw back, that is, interference from ambient light, is much more difficult to deal with. IR photodiodes detect light of a particular wavelength, which usually between 700 - 850 nanometers. Unluckily, the wavelength of most of the IR radiations around us fall in this range. To the photodiode these radiations are same as the IR radiations emitted by the IR LED, and hence they get falsely triggered by them. Even red light (which comes just beyond the IR radiations in the electromagnetic spectrum) can affect these sensors. There are many methods you can employ to protect IR sensors from interference from ambient light. One of the easiest method is to physically shield the sensors from ambient light. You can also use sensors that provide ambient light protection like the TSOP 17** sensors.
To protect the sensors from ambient light. The sensor is placed in a position that is a little off centered to one of the sides. say right. my robots chassis is completely closed and the sensors are placed inside where they are shielded from any ambient light interference. When the sensor is detects no line the robot moves to the left and when the sensor detects the line the robot moves to the right. A robot with this algorithm would follow the line like shown in the picture below . The most basic algorithm I know is the one which uses only one sensor. Algorithm The algorithm is the one thing that determines the performance of your robot more than anything else.
The drawback of this method is that the line following is not smooth. A modification to this method is to add sensors on both sides of the robot and place them such that they just sense the line on either side. A robot with this algorithm would follow the line like shown in the picture below . And the algorithm would be to move forward if both the sensors sense the line or to move left if only the left sensor senses the line and move right if only the right sensor senses the line. The robot keeps wavering left and right on the track. wasting battery power and time.
This will make line following process much more smoother.This algorithm is faster than the previous algorithm but the robot will still wobble about the line and may not be fast enough. . faster and efficient. A much better algorithm is to use the PID to follow the line.
And that response time is from pure dark to pure light.10:06am. "A LDRs reaction time is around 0.. higher resolution (more sensors). as you suggested.Step 1: What it takes to build a fast line follower? Part: B ¾ y y Printer-friendly version Login to post comments distance of sensors from center of rotation Submitted by admin on April 8.2s. But why would one need a PID controller for a line following robot. when there are many simpler algorithms already available for line following. A conventional robot would follow a line as shown below(red line shows the path taken by the robot) . LDRs are just as affected by ambient light as IR sensors. Lets us see. In this page I will be explaining about the PID control PID stands for Proportional Integral and Derivative. Using the LED. would be better for faster robots. y Login to post comments Advanced Line Following Robot . and actually even just one sensor. your eyes can actually see what the interference is to help you debug. It is a popular control loop feedback control extensively used in industrial controls systems. making it negligible. As for number of sensors on the robot. you can get decently smooth motion with just two.Explaining the PID control will take a lot of time and space hence I will be explaining about it in the next page. 2010 .Step 1: What it takes to build a fast line follower? Part: B Submitted by Pratheek on January 27." Well. 2010 ..03s to 0. basically overwhelms ambient light. The difference is with LDR. I've seem them from 0.1s. But yes. depends on the type you use.10:32am. ½ An advanced line following robot with PID controlupAdvanced Line Following Robot .
A robot with PID control will follow the line as shown below . wasting valuable time and battery power. other wise the robot will overshoot the line.As you can see clearly in the picture the robot oscillates a lot about the line. By now you must have realized that there is a maximum speed beyond which you cannot use this algorithm.
let me tell you the terms associated with it ± Target ± It is the position you want the line follower to always be(or try to be).As you can see clearly the robot will follow the line smoothly keeping its centre always above the line. . It can be negative. positive or zero. Before I tell you how to implement a PID algorithm for a line following robot. Error . Current Position ± It is the current position of the robot with respect to the line. to the left or a little to the left. Proportional ± It tells us how far the robot is from the line like ± to the right . the robot will gradually stabiles go straight unlike a robot with the leftright algorithm. the center of the robot. This enables the robot to follow the line faster and more efficiently. It tells us if the robot has been on the line in the last few moments or not. Derivative ± It is the rate at which the robot oscillates to the left and right about the line. Proportional is the fundamental term used to calculate the other two.that is. to the extreme right. In straight lines. Integral ± It gives the accumulated error over time.It is the difference between the current position and the target.
the better will be the performance of the robot. Implementing PID control for a line following robot The first requirement in implementing PID for a line follower is calculating the error of the robot. the magnitude of the turn taken will be proportional to the error. the output of these sensors will be highly susceptible to interference from external light. the controller will then increase the magnitude of the turn further and further over time till the robot centers over the line. There are a number of ways of knowing this. Firstly. you have to ensure that the track is completely flat. Ki and Kd are the constants used to vary the effect of Proportional. When building a sensor array. For line following anything between 6 to 10 sensors (depending on your robot) will be sufficient. for this method to work.Kp. if the error does not decrease or decreases slowly. This is a result of the Integral control. Firstly. And lastly. Any change in the distance between the sensor and the surface will affect the sensor readings. The distance between each adjacent sensor determines the . To reduce the oscillating effect over time the Derivative control is used. a robot using this method will have problems following a line whose width is varying. Secondly. You can also use the robot as a grid solver. Then calculate the error based on the current position. This is a result of the Proportional control. Thus the robot may keep oscillating about the line in order to center over the line. Though this method may seem simple and easy to implement it has a few drawbacks. Integral and Derivative terms respectively. What the controller does is first calculate the current position. Using an array of sensors. The IR sensors should be tuned to give an output voltage that is promotional to the distance between the line and the sensor. When the 7th sensor from the left detects the line you can be sure that the centre of the robot is 2 cm to the right of the line. The output can then be connected to the ADC pin of a microcontroller and the error can be calculated. Using a sensor array the processor can calculate the error faster as there is no ADC required to be done and thus you can increase the sampling rate. It will then command the motors to take a hard turn. because more sensors translates to more range of error. there are a few things to keep in mind. Basically. A better approach would be to use the traditional sensor array. you can easily calculate the error by knowing which sensor is on the line. Even after this. In the process of centering over the line the robot may overshoot the target position and move to the other side of the line where the above process is followed again. Consider you have an array of 10 sensors each placed 1cm apart. if the error is high or a small turn if the error is low. To calculate the error we will need to know the current position of the robot with respect to the line. the more sensors you have in an array. A simple approach would be to place two IR sensors on either side of the line.
It is always best to place the sensors as close to each other as possible because your resolution will increase as you place the sensors closer (a resolution of +/.Step 2: The Parts List Submitted by Pratheek on December 30.Step 1: What it takes to build a fast line follower? Part: AupAdvanced Line Following Robot . because each loop takes almost the same time to execute. but I have skipped this step in my robot. The next important thing in implementing PID after the sensors is the writing the code itself. 2009 . While calculating the derivative.1cm is always better than a resolution of +/. Part No. .resolution of the readings.Step 2: The Parts List ¾ y y y y y y y y Printer-friendly version Login to post comm Advanced Line Following Robot .3 cm). the change in error can be divided by the time taken to get the rate of change of error. The algorithm for a PID control for line followers would be something like this ± Error = target_pos ± current_pos P = Error * Kp I = I + Error I = I * Ki D = Error ± Previos_error Correction = P + I + D //calculate error //error times proportional constant gives P //integral stores the accumulated error //calculates the integral value //stores change in error to derivate The next step is to add this correction term to the left and right motor speed. The following are the parts used in building the robot - Item Qty Price Vendor.12:54am. ½ Advanced Line Following Robot .
com www.futurlec.futurlec.com .futurlec.futurlec.futurlec.com www.com www.1 $0.99 $0.hobbyengineering.com www.1" Straight Male and Female Polarized 6 Headers 3 Pin .futurlec.com $0.9 $0.3 www.futurlec.9 $9.100" Straight Male Polarized Headers 6 Pin .5V Positive Regulator 1 1 1 1 $5.15 $0.com www.45 $0.futurlec.07 $0.27 www.futurlec.futurlec.com www.100" Straight Male Polarized Headers 8 Pin .futurlec.100" Straight Male Polarized Headers 4 Pin .com Miniature Pushbuttons 3 330 ohm resistor 10K resistor 0.futurlec.45 $0.com www.futurlec.com 2 8 1 1 $0.35 www.com www.com www.robokitsworld.22 uf ceramic disc capacitor 100 uF electrolytic capacitor 17 12 2 1 www.23 www.9 $2.47 $0.com www.1 $0.futurlec.futurlec.com 1 $0.100" Straight Male Polarized Headers IR LED pairs 16 Pin IC Socket 40 Pin IC Socket 1 $0.com 1 $0.22 www.Atmega16 L293D 16x2 LCD with backlight LM7805 .com 2 Pin .08 www.
From my experience differential drive is one of the best steering mechanisms for line following robots.co.com www. 2010 . Almost all of the fast line followers I have seen use differential drive or a variation of it. Apart from these parts you will also need the following tools and materials.12 V battery source Wires Advanced Line Following Robot .robokitsworld. Nuts and bolts 20³30 Small L³bracket Micelleneous Total y y 11 $85 Note: If you are building the robot. if you don¶t have them you may consider buying or borrowing them Soldering Iron Desoldering Pump(optional) Crimper Drilling machine A 8 . The Mechanics Nothing too complicated here.in Local hardware shop Local hardware shop Local hardware shop Wheels (dimeter of 8³ 2 10cm) Plywood One big piece Screws.100 uF electrolytic capacitor 200 rpm dc motors 1 2 $0.08 $4.triindia. I would suggest you to go through and understand the whole tutorial before ordering the parts.69 $5 $5 $8 $10 $10 www.com www.Step 3: The Mechanics Submitted by Pratheek on January 3. When the . The robot uses differential drive as its steering mechanism. It is easy to understand and implement and at the same time quite cheap (only needs two motors).12:40pm.futurlec. And above all writing a PID control for the differential drive is both simple and easy.
With this setup. This picture shows the plywood cut into pieces. indoors and in the competition The sensor board is mounted inside the closed chassis and is completely shielded by external light Designing I used Google SketchUp for designing the robot. Then I drilled four holes to mount the L-Brackets to attach the sides. the corresponding motor is slowed down and the robot stays on line. Moreover it is quite light(keeping the robot light has many advantages). circuit board. The chassis is completely closed. sensors ± are placed inside the chassis. you will be shielding them from any ambient light thus avoiding any interference from the surrounding light sources.robot¶s left or right sensor senses the line. The chassis is quite intriguing. . Construction The robot is built in plywood. Google sketchup was used because it is easy to learn and it is available as a free download. Plywood was used because it is easy to work with ± cutting and drilling holes in plywood is easy and requires no special tools. I can calibrate the sensors once at home and use the robot in outdoors. I used plywood of 3 mm thickness. All the parts ± motors. This is done so because by keeping the sensors enclosed in the chassis.
The robot's base The L-Brackets attached to the base. .
The top piece is then attached to the chassis. .The sides attached to the base. A hinge is attached in its front end.
changing batteries. etc.The front piece is attached to the top through the hinge. Such an arrangement is made so that the back piece can be opened and the main circuit board can be accessed easily. The front piece is attached to the hinge so that. the front piece may be opened for calibrating sensors. I added a similar hinge to the back and attached the back piece as shown. .
Make sure that the holes are correctly aligned or the robot's wheel will not be aligned and the robot will not go straight even on straight tracks.Then I drilled two holes for the motors on the sides. .
. The motors I used had a nut around the shaft.Then I mounted the motors and the wheels. which enable me to drill a hole in the side of the chassis (as seen in the above picture) just enough for the shaft to go through it and tightened the nut from the other side (as seen in the picture below).
For more than an hour I thought there was some problem in the algorithm !) ½ Advanced Line Following Robot . It is always a good idea to use polarized connectors for DC motors because if you connect them the other way around. Electronics In this parts I will be explaining the constuction of the sensor array and the main controll board.Mounting the wheels was even easier. The Sensor Array .Step 2: The Parts ListupAdvanced Line Following Robot Step 4: The Electronics ¾ y y Printer-friendly version Login to post comments Advanced Line Following Robot .Step 4: The Electronics Submitted by Pratheek on February 1. 2010 . Then I drilled three holes of diameter 3mm at the back of the top peice and cut a 3cm by 8 cm peice for the LCD as shown in the next picture. The wheels I used had a set screw which I used to mount it to the motor's shaft. Note: As you can see in the picture.8:12am. I have used polarized connectors for the DC motors. then that motor will be turning back instead of turing forward and it will take a lot of time to figure out whats happening(this happened to me and it took me more than an hour to figure out what had happened.
The sensor board PCB is shown below. I used EaglePCB for the designing because it is quite easy to learn and comes free. The solder side (the board is 10cm x 4. The sensor board is single sided so it should be possible to etch at home.5 cm) The silkscreen side R1 . Just print the board to size and etch it. There is a onboard preset to calibrate the sensors. The sensors are placed 1.10K L1 to L8 are IR LEDs PD1 to PD8 are photodiodes .2 cm apart from each other.The sensor board consists of 8 IR sensors.120 ohms R2 to R9 .Two on oboard LM324 onboard convert the anaglog signals from the IR photodiode and convert them to digital signals.
5 cm. It is 10 cm x 4. The main board's PCB is shown below. The Main Board The main board consists of the microcontroller and the motor driver. The microcontroller I used is the Atmega16. I used the L293d because it is quite cheap and also you can control the motor speed with its enable feature. . It is also single sided.The final sensor board is shown below I attached two l brackets on both sides of the sensor board to mount it to the robot chassis. The motor driver I used is the L293D.
The solder side The silkscreen side .
It is pin compatible with the L293D so you can use the same circuit. the L293D. can drive motors which consume upto 600 ma of current. .The final board Note: The motor driver I have used. If your motor requires more current. you can use the L239NE which can drive motors upto 1 A.
Step 3: The MechanicsupAdvanced Line Following Robot Step 5: The Programming ¾ y Printer Advanced Line Following Robot . I used a serial programmer to program the robot. You can also download the Eagle schematic files below.http://www.Programming.png to view the schematic. Programming In this page I will explain the final process of building the robot .shtml The program consists of the following files Lotl.This file contains all the function and variable definitions used by the program. It contains the main function. Attachment Size Lotl Schematic. Lotl.98 KB ½ Advanced Line Following Robot .c and lcd.h . The program for the robot is written in WinAVR and the programmer used to transfer the program to the microcontroller is PonyProg. 2010 .com/albums/nn236/pratheekn/Lotl.photobucket. I won't be explaining how to program the robot as this step varies a lot from the software and the hardware programmer you use.Visit http://i305.8:31am. For programming the microcontroller. I downloadeed them from http://extremeelectronics.c .Step 5: The Programming Submitted by Pratheek on February 3.co. lcd.png 91.h .This is the most important file.societyofrobots.in/ .these files are used to control the LCD. . you can follow the instructions in this page .com/step_by_step_robot_step4.
switch on and off the power LED. It has to be called just one at the start of the program.This method reads the sensor values and calculates the current error. Once JTAG is disabled these pins can be used as standard IO pins. I ususally keep a separate function for initialization as the program becomes more clear and since all the initialization has been done in one place. additions and modifications become simpler. PowerLEDOn() and PowerLEDOff() . The Atmega16 comes shipped with the JTAG feature enabled and this renders some pins of PORTC unusable which are required to control the LCD in this project.Initializes all the pins as inputs or outputs. Here is an explanation of the functions used in the program - InitPorts() . InitInterrupts() .switch on and off the LCD backlight.Drives the left motor forward. . BacklightOn() and BacklightOff() .Initializes the timer registers for Pulse Width Modulation for controlling the motor speeds. InitPWM() .Note: You will have to disable the JTAG fuse of the microcontroller. CalcError() .This function sets the interrupt registers. LeftMF() .
Tune the Kp value till the robot smoothly follows the line. Ki and Kd values to get the best results. After which. By now you will have observed that the robot goes with no acceleration on straight lines. First. First time I just gave an approximate value. In this step one should tune the Kp. You can only know these optimum values by testing. And the best way to determine the optimum values is by trial and error. set all values to 0 and start with tuning the Kp value. Seeing the robot perform will determine what you should do next. RightMS() . RightMF() .Drives the left motor backward. I cannot give you the values because what works for me will not work for you. LeftMS() . The optimum Kp.Stops the left motor. If the robot wobbles a lot reduce the Kp value. if the doesn't follow the line (goes straight in curves) increase the Kp value. Ki and Kd values vary a lot even from track to track. tune the Kd term. After tuning the Kd term move to the Ki term.LeftMB() . Tuning the PID control This is the most interesting part in building a PID control. Time taken for building the robot . Note: The optimum Kp. you will see the robot first center over a straight line and then accelerate also. RightMB() . Ki and Kd values vary a lot from robot to robot. Now.Stops the right motor.Drives the right motor forward.Drives the right motor backward.
5 hrs Testing: 15 . . I myself haven't figured out how to do it but implementing an algorithm that will enable the robot map the line it is following will be a great project in itself.6 hrs Programming: 4 . 5. Use encoders for wheels this will give you input like your speed. acceleration and even position if possible. 4. Implementing an onboard charger will be really useful. 3.40 hrs Possible Upgrades 1.11 hrs Designing: 3 .poly batteries.ion or Li .Research: 10 . 2. Use Li . Store the Kp. black to white) on the go. Add another two sensors in the front to detect the surface color and implement a algorithm that will detect changes in surface color(eg.20 hrs Total time taken: 35 . Ki and Kd values in the microcontroller's EEPROM so that you don't have to set them every time you need to use the robot(I really wanted to do this but did not due to lack of time).4 hrs Mechanics and Electronics: 5 . These will improve performance quite a lot owing to their low weight and the power they can provide.
2(SOR).Attachment Size Code V2.Step 4: The Electronicsup y Printer-friendly vers .zip 98.45 KB ½ Advanced Line Following Robot .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.