Vision and Control of Line Following Robots

Line following robots have been around for years, so many people have had chances to attack this sort of problem. Line following robots can be very basic or very sophisticated depending on the hardware used, efficiency wanted, and programming capabilities. In the history of line following robots the differential steering system is the most widely used way of keeping the robot on course. Infrared (IR) sensors are used more frequently in line following robots then any other sensor.

Hardware

The four main Hardware items needed to build and control a line following robot are Sensors, Micro-controllers, Drivers, and Motors.

Sensors

As mentioned before IR sensors are the most popular sensor used in the line following robot field. IR sensors have two IR LEDs, one is the Emitter and the other is the Receiver. An electrical property of these LEDs is that they produce a voltage difference across its leads when it is subjected to light. This voltage can barely be detected. An Op-Amp is normally used to increase this voltage to a reasonably detectable range. By amplifing the voltage, the changes in voltage will be easier to detect. [1]

There are many other sensors that can be used to detect lines. Photo-cells and Photoresistors are two other common sensors used.

The image below is a commercially available single line following IR sensor. It needs only 5 volts to run. The output signal ranges from 0V to 5V. This range is based off of it seeing white or black. This also means there is an Op-Amp already installed. The sensing distance is 0.04 in to 0.5 in. This short range is common for IR sensors. [2]

IR_Sensor.jpg

[2]

The image shown below is also a commercially available line following IR sensor. As you can see there are five IR sensors set up in an array. This board reads from all five sensors and ouputs a 0-127 signal, 0 meaning all sensors are seeing white and 127 means all are seeing black. It has the same input voltage and range as the single line following IR sensor. An array of sensors is the most efficient way of sensing and staying on a line. PID Controller

IR_Array_Sensor.jpg

[3]

Common Sensors

Micro-Controller

The type of micro-controller used in your application may vary depending on what other objectives you may need to accomplish. The simplest micro-controller that will be needed to just follow a line will need to have an Analog to Digital (ATD) port (or something equivalent "Comparator") and a couple basic I/O pins. The ATD port is to read from the sensor and the two I/O pins are to control the drivers which in part control the motors. The more ATD ports on the micro-controller used will greatly improve the efficiency of the robot if coded properly.

Drivers

There are many types of drivers offered but all of them have the same concept. An H-Bridge configuration is the most common.

461px-H_bridge_svg.png

[4]

The diagram above shows how simple the concept of an H-Bridge really is. To rotate the motor in one direction the controller would need to close switches S1 and S4. To rotate in the opposite direction, the controller would need to close switches S3 and S2.

The driver shown below is a Texas Instruments(TI) L293 quadruple high-current
half-H driver. The L293 is designed to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. The L293 is designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well as other high-current/high-voltage loads in positive-supply applications.[3]

Driver2(1).JPG

[4]

Most IC drivers like the TI L293 have Enable pins, which will turn on that half of the IC or the IC in general. Pin 1 is the Enable pin for the first two half-H bridges. From the diagram Pin 9 turns on the other two half-H bridges. Pin 8 is the motor supply voltage input pin. This voltage is normally higher then the voltage used by other components on the robot. Pins 2 & 7 are the input pins to turn on or off the motors. Pins 3 & 6 are the outputs to the motor. Everything from here on is mirrored across the IC. This driver offers multiple configurations for motor set-ups. The figure below shows two different configurations. By connecting the two half-H bridges through a motor the controller can rotate the motor in both directions(right side). If Pin 2 is high and Pin 7 is low the motor will rotate in one direction and vise versa for the opposite direction. The drivers can also be configured to run one motor in only one direction using only one of the half-H bridges as seen on the left side of the figure below.

Driver(1).JPG

Motors

The motors and gearing used will be based off of the objective the robot is trying to complete.
A concern when choosing motors and gear reduction for a line following robot would be keeping the speed of the motors slow enough the robot is not over shooting the edge of the line. If the robot does over shoot the edge of the line the robot could become lost. Depending on programming the robot may never find the line or could find the line but will be going in the wrong direction and not know.

Programming

Zig-Zag Method

The Zig-Zag method is the simplest and easiest way of programming a line following robot. The concept is the robot moves across the line it is following untill it meets an edge. Once it senses it has hit an edge it turns the current motor off and turns the opposite motor on. Once it senses the next edge it swaps the power to the first motor again. As you can see the robot Zig-Zags back and forth across the line.

One Sensor

The Zig-Zag method with one sensor is a very basic line following robot. Since there is only one sensor there will only be one reading. This reading will be either "I see Black" or "I see White". As mentioned before the Zig-Zag method crosses back and forth across the line being followed, this causes problems with wide lines. The robot will move across the line untill it senses the edge, by the time it gets to the edge it might not be facing the end point any more. Further thought into programming and powering both motors, one just more then the other will help with this problem.

Basic Zig-Zag Code
Two Sensors

The Zig-Zag method using two sensors becomes more efficient then using one sensor. There are two ways of setting the sensors on the robot. Depending on the width of the line and personal preference the robots sensors can be set up to straddle the line or can be set up to stay with-in the line's width. Both of these configurations makes the response of the robot faster at detecting the edge then the single sensor robot. The robot will Zig-Zag faster back and forth but will have a more true heading. Using two sensors makes the over shoot problem a little easier to handle. If over shoot happens it is possible one of the sensors is seeing the line and could straighten the robot out based off of the general Zig-Zag coding.

PID Control Method

Array of Sensors

In many applications an array of sensors is used. By using the array of sensors the robot can have a better understanding of where it is on the line and will be able to correct its trajectory a little more accurately. The figure below is a simple diagram of an array of sensors that could be used on a line following robot. It has four sensors on the right (R1-R4) and four on the left (L1-L4). As seen in the above explanations these can be 0's or 1's depending on the color of the line you are following.

sensorarray1.JPG

The figure below shows what the controller would see if the robot was centered on the line. When your robot is seeing this you will want your robot to supply both motors with an equal amout of power.

Centered.JPG

The Diagram below shows the robot trailing slightly to the right of the line. In this case the controller will want to power the right wheel slighty more then the left wheel to correct the trajectory of the robot back to centered on the line. If you are using a PID type of controller the error signal would be proportional to the magnitude the robot was off of center. In this case the robot is not far from center so the error would small.

LittleLeft.JPG

In the following figure you can see the robot is drifting further to the right. In this case the PID error signal would be greater then the above example. There for supplying a greater amount of power to the right wheel.

Left.JPG

When using an array of sensors the most common controller used is a PID controller. Most configurations using arrays will wire the signals into one whole eight pin ATD PORT on a micro-controller. By using the whole port the controller can read an 8 bit number from the sensors. By calibrating the sensors centered on the line to be followed, the controller can take that reading as "I'm on course". The PID control in the programming will try to keep the robot at the "I'm on course" reading by smoothly and constantly adjusting the right and left wheel speed. To learn more about PID Controlling please see PID Controller

Bibliography

http://www.ikalogic.com/ir_prox_sensors.php [1]

http://www.trossenrobotics.com/p/single-line-following-sensor.aspx [2]

http://www.trossenrobotics.com/p/I2C-Line-Following-Sensor.aspx [3]

http://focus.ti.com/lit/ds/symlink/l293.pdf [4]

http://www.kronosrobotics.com/application.shtml [5]

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License