SlideShare ist ein Scribd-Unternehmen logo
1 von 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.

Weitere ähnliche Inhalte

Was ist angesagt?

Obstacle Avoidance ROBOT using ARDUINO
Obstacle Avoidance ROBOT using ARDUINOObstacle Avoidance ROBOT using ARDUINO
Obstacle Avoidance ROBOT using ARDUINOjovin Richard
 
Obstacle Avoidance Robot
Obstacle Avoidance RobotObstacle Avoidance Robot
Obstacle Avoidance RobotYash Sati
 
Line follower(theory + coding + videos)
Line follower(theory + coding + videos)Line follower(theory + coding + videos)
Line follower(theory + coding + videos)Yash Patel
 
Obstacle Avoidance Robot
Obstacle Avoidance RobotObstacle Avoidance Robot
Obstacle Avoidance RobotRatan Srikanth
 
Line Following Robot using Arduino UNO
Line Following Robot using Arduino UNOLine Following Robot using Arduino UNO
Line Following Robot using Arduino UNOViswanadh Ivaturi
 
2 D.O.F Robotic Arm (SCARA Robot) using Arduino Programming
2 D.O.F Robotic Arm (SCARA Robot) using Arduino Programming2 D.O.F Robotic Arm (SCARA Robot) using Arduino Programming
2 D.O.F Robotic Arm (SCARA Robot) using Arduino ProgrammingManpreet Singh
 
Line follower robot
Line follower robotLine follower robot
Line follower robotANU_110
 
Obstacle avoiding Robot
Obstacle avoiding RobotObstacle avoiding Robot
Obstacle avoiding RobotRasheed Khan
 
Traffic density dependent taffic light controller pdf
Traffic density dependent taffic light controller pdf Traffic density dependent taffic light controller pdf
Traffic density dependent taffic light controller pdf NAVODITA KUMARI
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following RobotVikram Jha
 
Obstacle Avoidance Robot Summer training Presentation
Obstacle Avoidance Robot Summer training Presentation Obstacle Avoidance Robot Summer training Presentation
Obstacle Avoidance Robot Summer training Presentation Wasi Abbas
 
Automatic Fire Fighting Robot by St John College
Automatic Fire Fighting Robot by St John CollegeAutomatic Fire Fighting Robot by St John College
Automatic Fire Fighting Robot by St John CollegeNidhiRaut7
 
Obstacle avoiding car project slide
Obstacle avoiding car project slideObstacle avoiding car project slide
Obstacle avoiding car project slideShourovSarkerJoy
 
Report - Line Following Robot
Report - Line Following RobotReport - Line Following Robot
Report - Line Following RobotDivay Khatri
 
Obstacle avoidance robot
Obstacle avoidance robotObstacle avoidance robot
Obstacle avoidance robotRahuldey1991
 

Was ist angesagt? (20)

Obstacle Avoidance ROBOT using ARDUINO
Obstacle Avoidance ROBOT using ARDUINOObstacle Avoidance ROBOT using ARDUINO
Obstacle Avoidance ROBOT using ARDUINO
 
Line Maze Solver Presentation
Line Maze Solver PresentationLine Maze Solver Presentation
Line Maze Solver Presentation
 
Obstacle avoiding robot
Obstacle avoiding robotObstacle avoiding robot
Obstacle avoiding robot
 
Obstacle Avoidance Robot
Obstacle Avoidance RobotObstacle Avoidance Robot
Obstacle Avoidance Robot
 
Line follower(theory + coding + videos)
Line follower(theory + coding + videos)Line follower(theory + coding + videos)
Line follower(theory + coding + videos)
 
Obstacle Avoidance Robot
Obstacle Avoidance RobotObstacle Avoidance Robot
Obstacle Avoidance Robot
 
Line Following Robot using Arduino UNO
Line Following Robot using Arduino UNOLine Following Robot using Arduino UNO
Line Following Robot using Arduino UNO
 
Arduino Projects
Arduino ProjectsArduino Projects
Arduino Projects
 
Edge detector & avoider robot
Edge detector & avoider robotEdge detector & avoider robot
Edge detector & avoider robot
 
2 D.O.F Robotic Arm (SCARA Robot) using Arduino Programming
2 D.O.F Robotic Arm (SCARA Robot) using Arduino Programming2 D.O.F Robotic Arm (SCARA Robot) using Arduino Programming
2 D.O.F Robotic Arm (SCARA Robot) using Arduino Programming
 
Line follower robot
Line follower robotLine follower robot
Line follower robot
 
Obstacle avoiding Robot
Obstacle avoiding RobotObstacle avoiding Robot
Obstacle avoiding Robot
 
Traffic density dependent taffic light controller pdf
Traffic density dependent taffic light controller pdf Traffic density dependent taffic light controller pdf
Traffic density dependent taffic light controller pdf
 
Line Following Robot
Line Following RobotLine Following Robot
Line Following Robot
 
Obstacle Avoidance Robot Summer training Presentation
Obstacle Avoidance Robot Summer training Presentation Obstacle Avoidance Robot Summer training Presentation
Obstacle Avoidance Robot Summer training Presentation
 
Automatic Fire Fighting Robot by St John College
Automatic Fire Fighting Robot by St John CollegeAutomatic Fire Fighting Robot by St John College
Automatic Fire Fighting Robot by St John College
 
Line follower robot
Line follower robotLine follower robot
Line follower robot
 
Obstacle avoiding car project slide
Obstacle avoiding car project slideObstacle avoiding car project slide
Obstacle avoiding car project slide
 
Report - Line Following Robot
Report - Line Following RobotReport - Line Following Robot
Report - Line Following Robot
 
Obstacle avoidance robot
Obstacle avoidance robotObstacle avoidance robot
Obstacle avoidance robot
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Kürzlich hochgeladen (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

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.