SlideShare uma empresa Scribd logo
1 de 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.

Mais conteúdo relacionado

Mais procurados

line following robot
line following robotline following robot
line following robotRehnaz Razvi
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following RobotSelf-employed
 
Line Following Robot using Arduino UNO
Line Following Robot using Arduino UNOLine Following Robot using Arduino UNO
Line Following Robot using Arduino UNOViswanadh Ivaturi
 
Line Following Robot Presentation
Line Following Robot PresentationLine Following Robot Presentation
Line Following Robot PresentationOli ullah
 
IR Sensor Working and Concepts
IR Sensor Working and ConceptsIR Sensor Working and Concepts
IR Sensor Working and ConceptsRobo India
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following RobotFarooq Saeed
 
line following robot ppt
line following robot pptline following robot ppt
line following robot pptSuchit Moon
 
Line following robot - Mini project
Line following robot - Mini projectLine following robot - Mini project
Line following robot - Mini projectAmit Upadhye
 
Tuning of pid
Tuning of pidTuning of pid
Tuning of pidAnkuseth
 
Distortion annalyser
Distortion annalyserDistortion annalyser
Distortion annalysermks mk
 
ROBOTICS – SENSORS AND MACHINE VISION
ROBOTICS – SENSORS AND MACHINE VISIONROBOTICS – SENSORS AND MACHINE VISION
ROBOTICS – SENSORS AND MACHINE VISIONTAMILMECHKIT
 
8051 timer counter
8051 timer counter8051 timer counter
8051 timer counterankit3991
 
Adaptive neural network controller Presentation
Adaptive neural network controller PresentationAdaptive neural network controller Presentation
Adaptive neural network controller PresentationNguyen Cong Dan
 
Pid control
Pid controlPid control
Pid controlAB Rizvi
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingAnkur Mahajan
 

Mais procurados (20)

line following robot
line following robotline following robot
line following robot
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following Robot
 
Line follower robot
Line follower robotLine follower robot
Line follower robot
 
Line Following Robot using Arduino UNO
Line Following Robot using Arduino UNOLine Following Robot using Arduino UNO
Line Following Robot using Arduino UNO
 
Line Following Robot Presentation
Line Following Robot PresentationLine Following Robot Presentation
Line Following Robot Presentation
 
IR Sensor Working and Concepts
IR Sensor Working and ConceptsIR Sensor Working and Concepts
IR Sensor Working and Concepts
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following Robot
 
line following robot ppt
line following robot pptline following robot ppt
line following robot ppt
 
Sensors and transducer
Sensors and transducerSensors and transducer
Sensors and transducer
 
Line following robot - Mini project
Line following robot - Mini projectLine following robot - Mini project
Line following robot - Mini project
 
Tuning of pid
Tuning of pidTuning of pid
Tuning of pid
 
Distortion annalyser
Distortion annalyserDistortion annalyser
Distortion annalyser
 
Line Follower Robot
Line Follower RobotLine Follower Robot
Line Follower Robot
 
Lm 35
Lm 35Lm 35
Lm 35
 
ROBOTICS – SENSORS AND MACHINE VISION
ROBOTICS – SENSORS AND MACHINE VISIONROBOTICS – SENSORS AND MACHINE VISION
ROBOTICS – SENSORS AND MACHINE VISION
 
8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
 
Adaptive neural network controller Presentation
Adaptive neural network controller PresentationAdaptive neural network controller Presentation
Adaptive neural network controller Presentation
 
Unit 3 machine vision
Unit 3 machine vision Unit 3 machine vision
Unit 3 machine vision
 
Pid control
Pid controlPid control
Pid control
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
 

Semelhante a 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
 
Line follower(theory + coding + videos)
Line follower(theory + coding + videos)Line follower(theory + coding + videos)
Line follower(theory + coding + videos)Yash Patel
 
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
 

Semelhante a 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
 
Pid lfr
Pid lfrPid lfr
Pid lfr
 
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
 
Line follower(theory + coding + videos)
Line follower(theory + coding + videos)Line follower(theory + coding + videos)
Line follower(theory + coding + videos)
 
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
 

Último

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 

Último (20)

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.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.