SlideShare une entreprise Scribd logo
1  sur  21
By,
Mahadev G
+919496370662
Intro..
 Line followers are autonomous robots that follow a line.
They might follow a visual line painted or embedded in
the floor or ceiling or an electrical wire in the floor. Most
of these robots operates on some specific algorithms.
 This tutorial guides you through a common control
system algorithm used in the industry, PID control and
how it can be implemented in a line follower system.
So lets start !!
The Basics..
 All basic control systems rely on feedback.. feedback of
the system output, to know what state the system is in at
that instant and adapt the system by changing its
parameters so that the system reaches the desired
output.. We call that a SETPOINT.. (S.P)
 To attain the S.P we change certain elements in the
system, these elements (variables) are called
Manipulated Variables (M.V)
 So on coming to line followers our goal is to keep the bot
on the track at all times, ideally the centre of the bot on
the centre of the line at all times.. For the time being let
this be our S.P... To achieve that we need to change the
way out bot moves, i.e we control the motors.. our M.V..
 Fore more on Closed loop control basics visit [ http://hsconntrol.blogspot.in/2011/03/control-loop-basics.html ]
What is PID control then...
 The PID control scheme is named after its three correcting
terms, whose sum constitutes the manipulated variable (MV).
The proportional, integral, and derivative terms are summed to
calculate the output of the PID controller.
Kp: Proportional gain
Ki: Integral gain
Kd: Derivative gain
e(t)=SP-PV : Error
t : Time or instantaneous time
(the present)
Now this dosent make much sence does it !! 
So what are these Kp,Ki n Kd..
 In simple terms, the proportional term changes the system
proportional to the error, more the error more the controller output.
Eg: if the bot is at the right extreme sensor* on the line(has to take a
right turn), the left motor is given more power to get back into the
centre of the line.
 The integral term is the summation of previous errors, so it looks into
the past of the system and compensates accordingly..
 The differential term does something like predicting what the future
error will be, it is not an absolute measure of the future error though..
*Assuming the bot has a odd sensor array.. 5 or 7 sensors or more..
The Algorithm..
1. Initialize the set point S.P
2. Read sensor data P.V
3. Calculate the error e(t)=SP-PV
4. Calculate the output of the PID controller u(t).
5. Apply controller output to the actuators(motors).
6. Go back to step 2.
So lets define our variables…
 Our aim is to keep the bot on the centre of the line,
for feedback we have sensors*; i.e. we need to keep
the centre sensor on the centre of the line..
 That’s ok, but how can we convert 5/7 or 2n+1
sensor inputs ot a single variable r(t)..
 That’s where simple mathematics and number
system comes into use..
The conversion..
 Lets assume we have 5 sensors..
 Im assigning weights to each sensor
like in the figure above
 Centre has 0 weight, left most has -2
etc..
 So when we take the input r(t) it will be
k(t)=(-2)*r2+(-1)*r1+(0)*c+(1)*l1+(2)*l2 .
 Generalizing..
-2 -1 0 +1 +2
r2 r1 c l1 l2
Lets make this unique..
 i’m assuming that sensors on
the line return 0 and off the
line return 1.
 Now that we have k(t), we will
divide this by the number of
sensors that return 1.. Here we
have 4 sensors that return 1..
 So the sum is 4.
Lets build on this a little more….
 Now that we have a single variable for the input, as a
number we can calculate what the set point S.P will be.
 So we have
 So our S.P is zero.. That makes the rest of the math easy
to understand.
Consider the bot on a 90’ right turn
 So in this case we have Si as [1 1 0 0 0].
 Calculate r(t)
 So its negative 3/2..
1 1 0 0 0
Consider the bot on a 90’ left turn
 This will be easy now..
 Its positive..
 So for all left turns we get positive
inputs, right turns we get negative inputs
and if its on the centre our input is zero.
 That’s basically calssifying
mathematically all our conditions.
0 0 0 1 1
Building…
 Initialize SP,e_int,e_diff
 We read Sensors Si;
 Compute r(t)
 Error e(t)= SP- r(t)
 Find e_int,e_diff
 Find u(t)
 Update e_diff
 Read sensors again
SP=0;
e_int,e_diff=0;
A:
Si=read();
r=compute();
e=SP-r;
e_int +=e;
e_diff=e-e_prev;
u=Kp*e+Ki*e_int+Kd*e_diff
e_prev=e;
Goto A:
Read() is the read sensor function, returning 1 if sensor is not on the
line and 0 otherwise.
Compute() finds the value of r(t) using the formula.
Also..
 The weight initialization Wk can also be other sequences,
like 0,1,2,3,4.. Accordingly you have to modify the error
control statement..
 the set point for 0,1,2,3,4 weight system will be 2.. Values
less than 2 correspond to left turn and greater than 2
correspond to right turn..
Putting it all together
 Now that we have the controller output u(t), we need to assign it to
the actuators, or the motors in our case..
 Using PWM signals we can vary the speed of the motors. Your
signals to the motors correspond to the output u(t), but we have two
motors..
 So we convert this signal u(t) to 4 signals..
 right1 and right2 connected to +ve and –ve of the right motor.
 left1 and left2 connected to +ve and –ve of the left motor.
How we do it…
if (u < 0)
{
left1 = 100% + u%;
left2 = 0% – u%;
right1 = 100%;
right2 = 0%;
}
else
{
right1 = 100% -u%;
right2 = u%;
left1 = 100%;
left2 = 0%;
}
• Following the same analogy, we have
negative output for left turn and positive
error for right turn.
• u will vary from +k to –k, where k is a
constant that can be calculated.
• Where 100% is 100 percent output (5V),
u% is the controller output in percentage(its
twice that actually).. Ie if controller output
ranges from -3 to +3, u% is (u/3)*100..
• Going through the math you find that if u
is 100% negative, the bot will turn using
differential steering.
How to select Kp,Ki and Kd
 Selection of these parameters is called tuning. There are various
mathematical methods like Z-N method and C-N method, but that
requires the mathematical model of the plant. So we move to a practical
approach.
 First we set Kp= a constant and set Ki and Kd to zero, which is
turning off differential and integral actions.
 The bot will be oscillating(sweeping left and right on the line) along
the line.
 Increase Ki till the oscillations subside and bot travels smoothly(small
oscillations will be there, one or two sweeps).
 Put Kd as 10% of Ki or a very small value.
Practical experiences on using this scheme..
 Though PID control is a very efficient control system logic, using a 5 sensor
array provides very small data for enough variations and hence you might
find the logic inadequate for sharp acute turns.
 The system however becomes an excellent constructor helping the user
map all the 2^N conditions for an N sensor robot using equations rather than
having to use Boolean algebra to map all the conditions.
 Hence using this scheme means that there will not be any unmapped
condition so that your uC gets locked in a loop.
 Extremely effective and useful if using more number of sensors.

Contenu connexe

Tendances

Density based traffic light control
Density based traffic light controlDensity based traffic light control
Density based traffic light controlRohit Nair
 
Decimation and Interpolation
Decimation and InterpolationDecimation and Interpolation
Decimation and InterpolationFernando Ojeda
 
Line follower robot
Line follower robotLine follower robot
Line follower robotPriya Hada
 
line following robot ppt
line following robot pptline following robot ppt
line following robot pptSuchit Moon
 
Line Following Robot Presentation
Line Following Robot PresentationLine Following Robot Presentation
Line Following Robot PresentationOli ullah
 
Obstacle avoidance robot
Obstacle avoidance robotObstacle avoidance robot
Obstacle avoidance robotRahuldey1991
 
Lic lab manual
Lic lab manualLic lab manual
Lic lab manualAJAL A J
 
Circular Convolution
Circular ConvolutionCircular Convolution
Circular ConvolutionSarang Joshi
 
Dsp U Lec08 Fir Filter Design
Dsp U   Lec08 Fir Filter DesignDsp U   Lec08 Fir Filter Design
Dsp U Lec08 Fir Filter Designtaha25
 
Adc.pptx ashvani 151503
Adc.pptx ashvani 151503Adc.pptx ashvani 151503
Adc.pptx ashvani 151503Ashvani Shukla
 
Types of time base generators
Types of time base generatorsTypes of time base generators
Types of time base generatorsKetki Jakatdar
 
Intelligent traffic control system using ardiuno
Intelligent traffic control system using ardiuno Intelligent traffic control system using ardiuno
Intelligent traffic control system using ardiuno kannansenthilkumar
 
Line following robot
Line following robotLine following robot
Line following robotsunil sah
 
FILTER DESIGN
FILTER DESIGNFILTER DESIGN
FILTER DESIGNnaimish12
 
FM demodulation using PLL
FM demodulation using PLLFM demodulation using PLL
FM demodulation using PLLmpsrekha83
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following RobotVikram Jha
 
Obstacle detection Robot using Ultrasonic Sensor and Arduino UNO
Obstacle detection Robot using Ultrasonic Sensor and Arduino UNOObstacle detection Robot using Ultrasonic Sensor and Arduino UNO
Obstacle detection Robot using Ultrasonic Sensor and Arduino UNOSanjay Kumar
 

Tendances (20)

Density based traffic light control
Density based traffic light controlDensity based traffic light control
Density based traffic light control
 
Decimation and Interpolation
Decimation and InterpolationDecimation and Interpolation
Decimation and Interpolation
 
Line follower robot
Line follower robotLine follower robot
Line follower robot
 
line following robot ppt
line following robot pptline following robot ppt
line following robot ppt
 
Line Following Robot Presentation
Line Following Robot PresentationLine Following Robot Presentation
Line Following Robot Presentation
 
Obstacle avoidance robot
Obstacle avoidance robotObstacle avoidance robot
Obstacle avoidance robot
 
Lic lab manual
Lic lab manualLic lab manual
Lic lab manual
 
Circular Convolution
Circular ConvolutionCircular Convolution
Circular Convolution
 
Dsp U Lec08 Fir Filter Design
Dsp U   Lec08 Fir Filter DesignDsp U   Lec08 Fir Filter Design
Dsp U Lec08 Fir Filter Design
 
Pid controller
Pid controllerPid controller
Pid controller
 
Adc.pptx ashvani 151503
Adc.pptx ashvani 151503Adc.pptx ashvani 151503
Adc.pptx ashvani 151503
 
Types of time base generators
Types of time base generatorsTypes of time base generators
Types of time base generators
 
Intelligent traffic control system using ardiuno
Intelligent traffic control system using ardiuno Intelligent traffic control system using ardiuno
Intelligent traffic control system using ardiuno
 
Class 17 integral and derivative control mode
Class 17   integral and derivative control modeClass 17   integral and derivative control mode
Class 17 integral and derivative control mode
 
Line following robot
Line following robotLine following robot
Line following robot
 
FILTER DESIGN
FILTER DESIGNFILTER DESIGN
FILTER DESIGN
 
Digital filter structures
Digital filter structuresDigital filter structures
Digital filter structures
 
FM demodulation using PLL
FM demodulation using PLLFM demodulation using PLL
FM demodulation using PLL
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following Robot
 
Obstacle detection Robot using Ultrasonic Sensor and Arduino UNO
Obstacle detection Robot using Ultrasonic Sensor and Arduino UNOObstacle detection Robot using Ultrasonic Sensor and Arduino UNO
Obstacle detection Robot using Ultrasonic Sensor and Arduino UNO
 

Similaire à Pid control for line follwoers

Digital Logic Counter.ppt
Digital Logic Counter.pptDigital Logic Counter.ppt
Digital Logic Counter.pptRaziyaSultana30
 
BALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptxBALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptxOthmanBensaoud
 
Frequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfFrequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfSunil Manjani
 
6. introduction to digital electronics
6. introduction to digital electronics6. introduction to digital electronics
6. introduction to digital electronicsSajjad Mehmood
 
Digital length measuring
Digital length measuringDigital length measuring
Digital length measuringAsmaa Ayyash
 
Control digital: Sistemas de control digital
Control digital: Sistemas de control digitalControl digital: Sistemas de control digital
Control digital: Sistemas de control digitalSANTIAGO PABLO ALBERTO
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC MicrocontrollerDivya Bansal
 
Pid controllers
Pid controllersPid controllers
Pid controllersmilind1076
 
Control tutorials for matlab and simulink introduction pid controller desig...
Control tutorials for matlab and simulink   introduction pid controller desig...Control tutorials for matlab and simulink   introduction pid controller desig...
Control tutorials for matlab and simulink introduction pid controller desig...ssuser27c61e
 
Four bit Signed Calculator.pptx
Four bit Signed Calculator.pptxFour bit Signed Calculator.pptx
Four bit Signed Calculator.pptxSUGAMRAJPUT2
 
Digital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav Raikar
Digital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav RaikarDigital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav Raikar
Digital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav RaikarGauravRaikar3
 
Introduction to control system 2
Introduction to control system 2Introduction to control system 2
Introduction to control system 2turna67
 

Similaire à Pid control for line follwoers (20)

Pid control for line follwoers
Pid control for line follwoersPid control for line follwoers
Pid control for line follwoers
 
Digital Logic Counter.ppt
Digital Logic Counter.pptDigital Logic Counter.ppt
Digital Logic Counter.ppt
 
BALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptxBALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptx
 
Control project
Control projectControl project
Control project
 
Frequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfFrequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdf
 
6. introduction to digital electronics
6. introduction to digital electronics6. introduction to digital electronics
6. introduction to digital electronics
 
L(1)
L(1)L(1)
L(1)
 
Digital length measuring
Digital length measuringDigital length measuring
Digital length measuring
 
Control digital: Sistemas de control digital
Control digital: Sistemas de control digitalControl digital: Sistemas de control digital
Control digital: Sistemas de control digital
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 
Timing and control
Timing and controlTiming and control
Timing and control
 
Pid controllers
Pid controllersPid controllers
Pid controllers
 
PID Control
PID ControlPID Control
PID Control
 
Control tutorials for matlab and simulink introduction pid controller desig...
Control tutorials for matlab and simulink   introduction pid controller desig...Control tutorials for matlab and simulink   introduction pid controller desig...
Control tutorials for matlab and simulink introduction pid controller desig...
 
1578385.ppt
1578385.ppt1578385.ppt
1578385.ppt
 
Four bit Signed Calculator.pptx
Four bit Signed Calculator.pptxFour bit Signed Calculator.pptx
Four bit Signed Calculator.pptx
 
Digital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav Raikar
Digital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav RaikarDigital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav Raikar
Digital clock (mod counters)using DSCH (DIGITAL SCHEMATIC) by Gaurav Raikar
 
Introduction to control system 2
Introduction to control system 2Introduction to control system 2
Introduction to control system 2
 
Projt1111
Projt1111Projt1111
Projt1111
 
REPORT
REPORTREPORT
REPORT
 

Dernier

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 

Dernier (20)

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Pid control for line follwoers

  • 2. Intro..  Line followers are autonomous robots that follow a line. They might follow a visual line painted or embedded in the floor or ceiling or an electrical wire in the floor. Most of these robots operates on some specific algorithms.  This tutorial guides you through a common control system algorithm used in the industry, PID control and how it can be implemented in a line follower system.
  • 4. The Basics..  All basic control systems rely on feedback.. feedback of the system output, to know what state the system is in at that instant and adapt the system by changing its parameters so that the system reaches the desired output.. We call that a SETPOINT.. (S.P)  To attain the S.P we change certain elements in the system, these elements (variables) are called Manipulated Variables (M.V)
  • 5.  So on coming to line followers our goal is to keep the bot on the track at all times, ideally the centre of the bot on the centre of the line at all times.. For the time being let this be our S.P... To achieve that we need to change the way out bot moves, i.e we control the motors.. our M.V..  Fore more on Closed loop control basics visit [ http://hsconntrol.blogspot.in/2011/03/control-loop-basics.html ]
  • 6. What is PID control then...  The PID control scheme is named after its three correcting terms, whose sum constitutes the manipulated variable (MV). The proportional, integral, and derivative terms are summed to calculate the output of the PID controller.
  • 7. Kp: Proportional gain Ki: Integral gain Kd: Derivative gain e(t)=SP-PV : Error t : Time or instantaneous time (the present) Now this dosent make much sence does it !! 
  • 8. So what are these Kp,Ki n Kd..  In simple terms, the proportional term changes the system proportional to the error, more the error more the controller output. Eg: if the bot is at the right extreme sensor* on the line(has to take a right turn), the left motor is given more power to get back into the centre of the line.  The integral term is the summation of previous errors, so it looks into the past of the system and compensates accordingly..  The differential term does something like predicting what the future error will be, it is not an absolute measure of the future error though.. *Assuming the bot has a odd sensor array.. 5 or 7 sensors or more..
  • 9. The Algorithm.. 1. Initialize the set point S.P 2. Read sensor data P.V 3. Calculate the error e(t)=SP-PV 4. Calculate the output of the PID controller u(t). 5. Apply controller output to the actuators(motors). 6. Go back to step 2.
  • 10. So lets define our variables…  Our aim is to keep the bot on the centre of the line, for feedback we have sensors*; i.e. we need to keep the centre sensor on the centre of the line..  That’s ok, but how can we convert 5/7 or 2n+1 sensor inputs ot a single variable r(t)..  That’s where simple mathematics and number system comes into use..
  • 11. The conversion..  Lets assume we have 5 sensors..  Im assigning weights to each sensor like in the figure above  Centre has 0 weight, left most has -2 etc..  So when we take the input r(t) it will be k(t)=(-2)*r2+(-1)*r1+(0)*c+(1)*l1+(2)*l2 .  Generalizing.. -2 -1 0 +1 +2 r2 r1 c l1 l2
  • 12. Lets make this unique..  i’m assuming that sensors on the line return 0 and off the line return 1.  Now that we have k(t), we will divide this by the number of sensors that return 1.. Here we have 4 sensors that return 1..  So the sum is 4.
  • 13. Lets build on this a little more….  Now that we have a single variable for the input, as a number we can calculate what the set point S.P will be.  So we have  So our S.P is zero.. That makes the rest of the math easy to understand.
  • 14. Consider the bot on a 90’ right turn  So in this case we have Si as [1 1 0 0 0].  Calculate r(t)  So its negative 3/2.. 1 1 0 0 0
  • 15. Consider the bot on a 90’ left turn  This will be easy now..  Its positive..  So for all left turns we get positive inputs, right turns we get negative inputs and if its on the centre our input is zero.  That’s basically calssifying mathematically all our conditions. 0 0 0 1 1
  • 16. Building…  Initialize SP,e_int,e_diff  We read Sensors Si;  Compute r(t)  Error e(t)= SP- r(t)  Find e_int,e_diff  Find u(t)  Update e_diff  Read sensors again SP=0; e_int,e_diff=0; A: Si=read(); r=compute(); e=SP-r; e_int +=e; e_diff=e-e_prev; u=Kp*e+Ki*e_int+Kd*e_diff e_prev=e; Goto A: Read() is the read sensor function, returning 1 if sensor is not on the line and 0 otherwise. Compute() finds the value of r(t) using the formula.
  • 17. Also..  The weight initialization Wk can also be other sequences, like 0,1,2,3,4.. Accordingly you have to modify the error control statement..  the set point for 0,1,2,3,4 weight system will be 2.. Values less than 2 correspond to left turn and greater than 2 correspond to right turn..
  • 18. Putting it all together  Now that we have the controller output u(t), we need to assign it to the actuators, or the motors in our case..  Using PWM signals we can vary the speed of the motors. Your signals to the motors correspond to the output u(t), but we have two motors..  So we convert this signal u(t) to 4 signals..  right1 and right2 connected to +ve and –ve of the right motor.  left1 and left2 connected to +ve and –ve of the left motor.
  • 19. How we do it… if (u < 0) { left1 = 100% + u%; left2 = 0% – u%; right1 = 100%; right2 = 0%; } else { right1 = 100% -u%; right2 = u%; left1 = 100%; left2 = 0%; } • Following the same analogy, we have negative output for left turn and positive error for right turn. • u will vary from +k to –k, where k is a constant that can be calculated. • Where 100% is 100 percent output (5V), u% is the controller output in percentage(its twice that actually).. Ie if controller output ranges from -3 to +3, u% is (u/3)*100.. • Going through the math you find that if u is 100% negative, the bot will turn using differential steering.
  • 20. How to select Kp,Ki and Kd  Selection of these parameters is called tuning. There are various mathematical methods like Z-N method and C-N method, but that requires the mathematical model of the plant. So we move to a practical approach.  First we set Kp= a constant and set Ki and Kd to zero, which is turning off differential and integral actions.  The bot will be oscillating(sweeping left and right on the line) along the line.  Increase Ki till the oscillations subside and bot travels smoothly(small oscillations will be there, one or two sweeps).  Put Kd as 10% of Ki or a very small value.
  • 21. Practical experiences on using this scheme..  Though PID control is a very efficient control system logic, using a 5 sensor array provides very small data for enough variations and hence you might find the logic inadequate for sharp acute turns.  The system however becomes an excellent constructor helping the user map all the 2^N conditions for an N sensor robot using equations rather than having to use Boolean algebra to map all the conditions.  Hence using this scheme means that there will not be any unmapped condition so that your uC gets locked in a loop.  Extremely effective and useful if using more number of sensors.