0% found this document useful (0 votes)
2 views6 pages

PID Line Follower: Preface

The PID line follower enhances the PD line follower by incorporating an integral component for better line tracking. Calibration of sensors is essential, ensuring their values range from 0 to 100, and the PID formula calculates the guiding influence for motor speed adjustments. Additionally, a line losing protection algorithm helps the robot regain the line by rotating towards it when lost.

Uploaded by

jafarov.rashad99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

PID Line Follower: Preface

The PID line follower enhances the PD line follower by incorporating an integral component for better line tracking. Calibration of sensors is essential, ensuring their values range from 0 to 100, and the PID formula calculates the guiding influence for motor speed adjustments. Additionally, a line losing protection algorithm helps the robot regain the line by rotating towards it when lost.

Uploaded by

jafarov.rashad99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PID line follower

Preface
PID line follower is an improved version of PD line follower. This line follower
has another component which contributes to guiding influence – the integral
one. This component takes into account e – e_old values on several iterations
(five in our case), which allows robot to even out on the line better. There are
two types of PID represented in this file – PID for three sensors with line losing
protection and PID for four sensors.

Calibration
Before using any kind of those PIDs the sensors need to be calibrated, which
means their diapason of values needs to be from 0 to 100. This is how it is done:
we remember sensor’s minimum and maximum values – on black and on white
values respectively:
PID_3:

Taken from Kalibrovka

PID_4:

Taken from Kalibrovka


After that we count the calibrated value with this formula:
curre𝑛𝑡 𝑣𝑎𝑙𝑢𝑒−𝑚𝑖𝑛𝑖𝑚𝑢𝑚 𝑣𝑎𝑙𝑢𝑒
value = ∗ 100
maximum value−minimum value

This is carried out in Sensors block:

Taken from Sensors

-1st parameter is the number of the sensor which


we need to calibrate.
-2nd output parameter is the calibrated sensor’s
value.

PID formula
PID is based on this formula: U = KP * e + KD * (e – e_old) + KI * sum
“U” is a so-called “guiding influence”. This is a correction to motors’ speed.
“sum” is the sum of e - e_old values on five iterations.
“KP”, “KD”, “KI” – some coefficients, they are found by selection. Usually KD =
KP * 10, KI < 1.
Now let’s see how “e” is counted.
100∗d1+200∗d2+300∗d3
e = 200 − in three sensors case;
d1+d2+d3
100∗d1+200∗d2+300∗d3+400∗d4
e = 250 − in four sensors case;
d1+d2+d3+d4

e_old is e on the previous iteration.

There is a special block PID in both PID_3 and PID_4 projects where the “sum”
and “U” are formed:

Taken from Sensors

As soon as “U” is formed we can add it to motors’ speed:

Taken from PID_3dat from PD_3 project


Taken from PID_4dat from PD_4 project

-1st parameter is speed.


-2nd parameter is KP.
-3rd parameter is KD.
-4th parameter is KI.

-1st parameter is speed.


-2nd parameter is KP.
-3rd parameter is KD.
-4th parameter is KI.

Line losing protection


This algorithm is incarnated in zaschita block in PID_3 project. The protection
does not allow the robot to lose the line by making the robot rotate until it finds
the line.
The robot remembers which sensor saw the line the last and rotates to the
needed direction of line when losing:
Taken from zaschita

Ports
In three sensors case the forth sensor is removed and the remaining sensors
are centered.
It is important to mention that in four sensor case there must be a gap between
2nd and 3rd sensors. But in three sensors case all the sensors must be right up to
each other.

You might also like