Vous êtes sur la page 1sur 12

LINE FOLLOWING ROBOT USING PID CONTROL

Regd NO:
2011-EE-196
2011-EE-202
2011-EE-203
2011-EE-205
2011-EE-211
2011-EE-219
Project:
Control Systems LAB
1
(A).INTRODUCTION TO PROJECT
DEFINITION OF A ROBOT:
A Robot has been dened by the Robot Institute of America as:
A robot is a reprogrammable, multifunction, manipulator designed for moving materials, tools, parts etc. through
various programmed motions to perform a variety of tasks.
A Robot has been dened by Webster dictionary as:
A robot is an automatic device that performs functions normally ascribed to humans or a machine in the form of
a human.
APPLICATIONS OF ROBOT:
Robot can replace humans job because robots can perform faster than humans. Robots need not to drink, to be
paid or rest as compared to humans.
Robot can be applied in military to reducing the number of casualties which occur during military actions has
been already been prioritized.
Robotic site of security sentries are able to work for long hours at consistency high level of vigilance and precision.
LINE FOLLOWING ROBOT:
A line follower robot is a robot that is capable of navigating while following a line on some terrain with the use
of sensors that tell the robot where it is. Just as we manipulate and interact with objects through gestures, these
robots have to be taught some way to manipulate and understand its surroundings to be able understand and
comprehensively take decisions. The decision variables are provided by these sensors also referred to as the line
sensors and the acquired decision variables are passed through a decision device (in our case the controller) The
micro-controller in turn commands the actuators to move the robot in the desired direction, giving the eect of
following the line.
APPLICATIONS OF LINE FOLLOWERS:
One most important application of line follower is in warehouses where the robots follow track to and from the
shelves they stock and retrieve from.
Automated driverless cars running on roads with embedded magnets.
Tour guides in museum.
Industrial equipment carriers.
OBJECTIVES OF PROJECT:
The main objective of this project is to design a line follower robot with PID controller having a dierential drive
steering mechanism.
To design and develop an autonomous robot that follows a black line drawn on the oor while smoothing the
tracking motion by using PID control.
To study the concept of infrared sensors, DC geared motors interfacing and PID controller tuning using STM -
micro-controller
BASIC OPERATIONS INVOLVED:
The basic operations of line follower are as follows:
Capture line position with optical sensors mounted at front end of the robot. For this a combination of IR
2
transmitter and receiver package has been used. Requirement for line sensing process are high resolution and high
robustness.
Steer robot requires steering mechanism for tracking. Two motors governing wheel motion based on dierential
drive scheme are used for achieving this task.
Application of PID algorithm to smooth the tracking motion. PID control is a closed loop system, which will
provide feedback and correct the error that occurs with fast response.
LINE FOLLOWING WITHOUT PID:
If the line followers are to be implemented without PID algorithm they will follow the black line but with a small
deviations even on a straight line. Once there is any curve in their path all the sensors would be o the line, this
will confuse the robots and they will not respond to any condition furthermore and they will continue moving in
their previous state. To avoid this problem, we have to sense the direction in which robot was moving when the
sensors were o the line. This will help us pull back the robot on the track. This phenomenon is also illustrated in
g. below.
COMPARISON OF LINE FOLLOWER WITH AND WITHOUT PID
(B).BLOCK DIAGRAM OF THE PROJECT:
Simple schematic of this project consists of three dierent stages as follows.
Sensor array for line detection.
Decision making circuit/controller to control direction of motion.
Motor driver circuit to steer the robot.
3
(C).HARDWARE COMPONENTS DESCRIPTION:
As stated above the description of the objectives of this project following components were employed in hardware
assembly of this robot.
Line Sensors.
Comparators.
Decision Device.
Power source.
Motor Drivers.
Opto-Couplers.
(1).LINE SENSORS:
The line sensors consist of an IR transmitter receiver pair for dierentiating between the line and the background.
The transmitter sends out IR rays and the receiver notes the amount, or in other words the intensity, of IR rays
received and based on this it calculates if it is over the line or the surrounding. If the line is of white in color then
it will reect more light as compared to any other color. This dierence in reected light helps us determine if the
sensor is on the line or on the surroundings.
The IR sensor pair used in this project is RPR-359F which is selected for the following two reasons.
To reduce the eect of ambient light on photo Detector.
To obtain High Accuracy
The sensors looks as:
4
ARRANGEMENT OF SENSORS ON ROBOT:
An array of 8 sensors arranged in a straight row pattern is bolted under the front of the robot. It locates the po-
sition of line below the robot. We can use any number of sensors. If we have low number then our robot movement
is not smooth and it may face problems during sharp turns. If higher number of sensors were, used robot movement
will become smooth and reliable for sharp turns rather it requires complex programming for micro-controller and
requires more hardware, which is its disadvantage. The output of the sensors is an analog signal which depends on
the amount of light reected back, this analog signal is given to the comparator to produce digital signals (0s and
1s) which are then fed to the micro controller.
Arrangement of sensor array is shown in gure below.
WORKING OF SENSORS:
The resistance of the sensor decreases when IR light falls on it. A good sensor will have nearly zero resistance in
presence of light and a very large resistance in absence of light. We have used this property of the sensor to form
a potential divider.
From the above circuit diagram potential at point 2 is Rsensor / (Rsensor + R1). Again, a good sensor circuit
5
should give maximum change in potential at point 2 for no light and bright light conditions.
ALGORITHM OF LINE DETECTION:
Let us assume that when a sensor is on the line it reads 0 and when it is o the line it reads 1.
1. Referring to the gure of sensor array shown above:
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.
For example
If sensors values are such that
Then in this case L=3; R=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
Go to step 4
3. Move Clock-wise if line was last seen on
Move Counter Clock-wise if line was last seen on Left
Repeat step 3 till line is found.
4. Go to step 1.
(2).COMPARATORS:
Comparator is a device, which compares two input voltages and gives output high or low. In circuit diagram below
it can be seen that it has two inputs Inverting (negative) and Non-Inverting (positive) Input (+), VCC, Ground,
Output. From the name it is very clear that the operation of this circuit is to compare the two values at its input
terminals.
If V+ > V- then Output = VCC (Digital High Output is 1).
If V+ < V- then Output = 0 (Digital Low Output is 0).
One input is from receiver, other is generated by potentiometer. The second voltage is reference voltage for
that sensor. We will x the reference voltage at the non-inverting terminal of the comparator and compare the
value whatever sensor receiver is generating as per position of robot on the line. The output thus produced will be
used for PID control of robot.
DECISION DEVICE:
Decision device is a unit where the decision variables passed by the line sensors are analyzed, processed and then
the appropriate actions/response are initiated. For our robot we have used the STM32L100RC microcontroller
6
board and C Programming Language for coding it.It is the brain of the robot and thus it can be said that the
robot, to a certain degree, has articial intelligence. Since the steering mechanism of the robot is a dierential
drive scheme which means we have to vary the speed of one motor relative to other to produce turning. This speed
control is being done using Pulse Width.
Modulation (PWM) technique. A PWM is a basically a square wave of two state levels i.e., 1 and 0. We can set
the intervals of high and low level for PWM by changing the values in auto reload register, counter register and
pre scalar register of this controller.
SPEED CONTROL USING PWM:
The logic high and logic low intervals correspond to duty cycle of PWM. For instance, if for a 16-Bit counter, we
have 70 percent duty cycle wave, then this means that from the interval of 65536 sec, 65536 * 0.7 sec will establish
a high logic level, while the remaining interval will retain the logic low state. Logic high level corresponds to +5V
and low to 0V means Ground level. This means that if we have to decrease the speed of one motor relative to the
other we will decrease the value of duty cycle of PWM signal applied to that motor which will be low for larger
time than high state and motor will be o for more time as compared to on thereby decreasing its over all speed.
ADVANTAGES OF PWM INCLUDE:
Motor consumes less power.
Increases eciency, reliability and ner motor control.
Selectivity of various speeds by mere duty cycle adjustment.
Below are shown some gures of the varying duty cycle PWM wave forms.
ACTUATORS:
The actuators in this robot are geared DC motors with that have sucient torque to carry the robot .They are
directly connected to the wheels of the robot and cause the robot to move in the desired direction. We have two
motors controlling the two wheels. Motion is achieved using the concept of dierential drive. Thus we can achieve
motions of moving front, back and turning left and right. The two motors are used to drive the robot using the
concept of dierential drive. In this the speed and direction of rotation of the individual wheels are used to both
7
move and turn the robot.
WHY DC MOTORS:
DC motors are most easy for controlling. One DC motor has two signals for its operation. Reversing the polarity
of the power supply across it can change the direction required. Speed can be varied by varying the voltage across
motor.
The DC motors dont have enough torque to drive a robot directly by connecting wheels in it. Gears are
generally used to increase the torque of dc motor on the expense of its speed because torque of the motor is related
inversely to its speed.
DIFFERENTIAL DRIVE SCHEME:
The rst and the top most requirement of this project was to implement motion of this autonomous vehicle using
dierential drive arrangement. As described in above sections that in this scheme the turning of the robot about
the turns of arena is controlled by the relative speeds of the two motors connected directly to wheels.
Few possible scenarios of the motion of vehicle are explained below.
FORWARD MOTION:
For forward rotation the motors must be rotated in same direction. For example if one motor is rotating in anti-
clockwise manner other will also have to rotate in anti-clockwise direction too.
RIGHT TURN:
In order to turn it in right direction, the motor on left side must have to move in the forward direction while the
right one has to be slowed down. It should be noted that for sharp right turn (90 degrees bend) right motor should
rotate in direction opposite to the left one and vice versa.
LEFT TURN:
In order to turn it in left direction, the motor on right side must have to move in the forward direction while the
left one has to be slowed down.
MOVEMENT OF ROBOT WITH VARIATION IN MOTOR DIRECTION.
8
(5).POWER SOURCE:
The power source provides electrical power to the robot and all its components. Since the mandatory requirement
of the project was that robot should be battery powered so we have used 4 dry cells as a battery source. The
specications of our power supply are as follows.
Classication: Re-chargeable
Chemical Sys.: Nickel-Metal Hydride(Ni-Mh)
Nominal voltage 1.2V
Capacity 1300mAh
Weight 28 g
Jacket Plastic label
(6).MOTOR DRIVERS:
The motor driver is a small circuitry that controls the power supplied to the motor based on the input from a
microcontroller. Motor driver is a current enhancing device; it can also be act as Switching Device. Many ICs
are available for driving the motors like L293d, l298, etc. These ICs are implemented by half and full H-bridge
circuits. Full H bridge ICs can make the motor rotate in forward as well as reverse direction. But we have used
NPN epitaxial Darlington pair IC TIP122 as a motor driver. These power BJTs have capability of deliver-
ing a high current up to 5A to the motor. Circuit diagram of power BJTs driving the motor is shown in gure below.
RATINGS OF TIP-122:
Collector current: 5A.
Base current: 120mA.
Vce(rated): 100V.
Vcb (rated): 100V.
(7).OPTO ISOLATORS:
Often when trying to drive a DC motor with a controller using transistors or H-Bridges, you will notice that the
controller is doing strange and unpredictable things. When this happens, the culprit is likely to be electrical noise
being injected into your circuit by the brushes and spinning magnets in the motor. Unfortunately, this noise is
9
very dicult to remove. One way of dealing with it is to try to lter out the noise by decoupling your motor driver
circuit and logic circuit with ferrite beads, inductors, capacitors, and resistors. A better method to isolate circuits
is to use opto-isolators. This allows you to completely separate your circuits, including the grounds. While this
scheme may add come complexity to your circuit, it is extremely eective.
An opto coupler or opto isolator is a cool little device that allows you to completely separate sections of an
electrical circuit. It transfers electrical signals between two isolated circuits by using light. Opto-isolators prevent
high voltages from aecting the system receiving the signal.
A common type of opto-isolator consists of an LED and a phototransistor in the same opaque package. Other
types of source-sensor combinations include LED-photodiode, LED-LASCR, and lamp-photo resistor pairs. Usu-
ally opto-isolators transfer digital (on-o) signals, but some techniques allow them to be used with analog signals.
We have used K817P IC as an opto-coupler. In the K817P part, each channel consists of a phototran-
sistor optically coupled to a gallium arsenide infrared-emitting diode in a 4 pin (single) plastic dual inline package.
The functional diagram of opto-coupler is shown below.
The signal coming from the uC is connected to (pin 1) anode of IC while cathode is grounded and the signal
from (pin 5) collector of photo transistor is then proceeded to the next section of the circuit which in our case is
power BJT. In this way, complete isolation is achieved between the controller and driver circuit.
(D).PID CONTROL, ALGORITHM AND TUNING
In the objectives of this project, we mentioned that the following of the line is smooth and much accurate if we
have a PID control. Before going into the algorithm for PID designing let us go through brief introduction of PID
controllers.
PID CONTROLLER:
Proportional-Integral-Derivative (PID) control is the most common control algorithm used in industry and has
been universally accepted. As the name suggests, a PID algorithm consists of three basic coecients: proportional
10
(Kp), integral (Ki) and derivative (Kd). These gains are varied to achieve an optimal system response. The general
structure of a PID controller is shown below.
From the above g. the mathematical equation for PID controller is:
PID ALGORITHM:
Before I tell you how to implement a PID algorithm for a line following robot, let me tell you the terms associated
with it.
Set Point:It is the position you want the line follower to always be (or try to be) that is, the center of the
robot. It is set to zero.
Measured Value: It is the current position of the robot with respect to the line. It can either be positive
or negative depending whether it is on left or right of set point. It involves calculating the distance between the
current position of the robot and the target position
Error: It is the dierence between the current position and the target. It can be negative, positive or zero.
Proportional: It tells us how far the robot is from the line like to the right, to the extreme right, to the
left or a little to the left. Proportional is the fundamental term used to calculate the other two.
Integral: It gives the accumulated error over time. 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. This component
prevents the overshooting of the robot from the line when correcting the error.
PID constant: There are 3 constants used in this algorithm. These are the Proportional Constant (Kp), In-
tegral Constant (Ki) and the Derivative Constant (Kd). The values of these constants are set beforehand by the
programme.
11
PID IMPLEMENTATION:
We initialized the various constants such as Kp, Ki and Kd. Also we have initialized last error, which is the previ-
ous error value & other variables such as integral, derivative and proportional. We set the value of the Measured
Position Variable for each sensor condition. Then we calculated the error value as
Error = Measured Value - Target Position
A higher error value tells us that the robot is farther away from the line, than a lower error value. We then
set the integral value as sum of current integral value & the error. The derivative value was updated to the sum of
current derivative value & the last error.
We then calculated TURN Value as the sum of the product of error value & the Kp constant, product of Ki
constant and integral and the product of Kd constant & the derivative. We then give the output to the left wheel
and the right wheel as a PWM (Pulse Width Modulation) output, which directly controls the speed of the motor.
Left PWM = BASE SPEED + TURN
Right PWM = BASE SPEED - TURN
This results in both the wheels moving at dierent speed, which depends on the sensor input and is computed
above. At the end of the program we set the last error value as current error value.
This algorithm keeps repeating in a loop to give an eective PID algorithm. The above explained computation
happens many times in a second to give an ecient line following robot. PID can be further improved by increasing
the number of sensors, which would cause the robot to go faster at curves and follow it more eciently.
A brief pseudo code of all the above dened steps is shown below.
Initialize the set point (S.P.).
Read sensors data (M.P.).
Calculate error.
Calculate output of PID controller.
Apply controller output to motors.
Go back to step 2.
PID TUNING:
Selecting the values of controlling parameters Kp, Ki and Kd is known as PID tuning. There are various mathe-
matical techniques of PID tuning but we have applied trial and error approach for this task.
1.First of all, we set the values of Ki and Kd zero and just vary kp so that robot somehow follows a line.
2.Once robot started following a line we increased the value of Kd until there was no wobbling and robot was stable.
3.Finally we set the value of Ki so there will be no jerky movements towards left and right.
CONCLUSION
12

Vous aimerez peut-être aussi