Line Follower Robot Design
Line Follower Robot Design
net/publication/377666058
CITATIONS READS
0 1,856
3 authors:
Enes Devecioğlu
Abdullah Gul University
5 PUBLICATIONS 0 CITATIONS
SEE PROFILE
All content following this page was uploaded by Onur Erbay on 25 January 2024.
Abstract— This paper aims to improve autonomous navigation control leads to a faster system response to disturbances.
in mobile robotics by developing and implementing a line- However, beyond a certain point, raising the proportional
following robot that utilizes the Proportional-Integral- gain can result in unstable oscillatory behavior. The integral
Derivative (PID) control algorithm and register-level ARM C control in the PID controller helps eliminate steady-state error
code. The primary objectives include successfully traversing the
track and minimizing the time required to complete the task.
by keeping track of past errors in the system. However,
The focus is on overcoming the challenges associated with increasing the integral gain can cause overshooting, which
guiding the robot along a predetermined path in a controlled can lead to unstable behavior. The derivative control plays a
environment. To deploy the algorithm, a basic system has been role in minimizing overshooting and speeding up the transient
constructed using low-cost and off-the-shelf components response. It acts as a mechanism to anticipate future errors in
including a microcontroller, reflectance sensor, and motor the system. By using derivative control to reduce
driver. This paper describes the heuristic approach used in the overshooting, the robustness of the system can be improved.
identification of the system specifications as well as the Nevertheless, in the presence of noise, a derivative controller
optimization of the controller. The PID controller is analyzed in can introduce instability due to the amplification of high-
detail and the effect of each term is explained in the context of
stability. Lastly, the challenges encountered during the
frequency signals.
development of controller and robot are discussed.
By adjusting the parameters based on sensor readings, the
Keywords — Line follower robot, Microcontroller robot becomes better at navigating complex paths. By
(STM32F103C8), Reflectance Sensor, PID controller combining traditional line tracking with PID control, this
project improves precision and deepens our understanding of
I. INTRODUCTION closed-loop control strategies in autonomous robotic
navigation. The study focuses on fulfilling two primary
The purpose this study is to design and implement a line- requirements. Firstly, the robot must successfully traverse the
following robot utilizing the Proportional-Integral-Derivative entire track. Secondly, the completion time of the task should
(PID) control algorithm and register level arm C code. The be minimized to the greatest extent possible.
development of a Line Follower Robot equipped with PID
control represents a significant advancement in autonomous In this study, a PID controller was utilized to design a line
navigation. This project focuses on mobile robotics and tracking controller that achieves both high speed and high
addresses the challenge of guiding the robot along a accuracy. The DC motors of the robot was controlled via a
predetermined path in a controlled environment reliably and microcontroller and the microcontroller was coded in ARM
efficiently. Line tracking is an essential behavior in mobile C language at the register level. The PID controller computes
robotics where robots use identifiable markers like magnetic errors based on data obtained from the reflectance sensor
tape, surface voids, or reflective tape to navigate. They rely array. The primary purpose of incorporating PID control in
on sensors like Hall-Effect sensors or Photo-interrupters, the development of the line tracking controller is to mitigate
using infrared or visible light technology, to detect and follow overshooting, reduce steady-state error, and prevent system
these paths [1]. Traditionally, line tracking has been done oscillations.
digitally. Digital sensors send their signals to a
microcontroller, which adjusts the robot's motor speeds based
II. MATERIALS
on its position relative to the center of the line. Finding the
right motor speed involves trial and error to ensure accurate In this chapter, the mechanical and electronic components
line tracking. which utilized in the robot system will be described.
A. Mechanical Components
This project takes a step further by using PID control, a
more advanced method that fine-tunes motor responses. PID
control uses three components - Proportional, Integral, and In figure 2.1, it can be observed the line follower robots
Derivative - to achieve smoother and more precise line utilized as the test platform in this project. This robot is
tracking. The PID controller is a widely used closed-loop equipped with affordable DC gear motors. The motors have
control system in various industries. Its purpose is to drive built-in gearboxes, which enables them to deliver adequate
the system towards a desired state by calculating the error, torque for rapid responses. An advantage of these motors is
which is obtained by comparing the reference input with the their cost-effectiveness, and if necessary, a higher input
system's output. Increasing the proportional gain in the PID voltage can be applied to achieve higher speeds for shorter
durations. The mounting of the DC motors to the frame was 2) Motor Driver(L298N): To control the two DC motors,
achieved using two plastic components and two screws for a motor driver module with an L298N dual full-bridge driver
each motor. Another important point is that the stability of was utilized. This motor driver module operates on a 12V (3
the robot is directly influenced by the position of its center of batteries with 4.2V) DC voltage supply. It also includes a 5V
mass. Manipulating the location of the battery on the chassis DC voltage regulator that powers the STM32
allows for control over the center of mass, as the battery is microcontroller. . It has two input pins for controlling the
the heaviest component. When the center of mass is closer to speed of each motor (IN1, IN2 for Motor A and IN3, IN4 for
the front of the robot, there is an increased risk of slipping. Motor B) and two output pins for controlling the direction of
Conversely, when the center of mass is closer to the rear, the each motor (OUT1 and OUT2 for Motor A and OUT3 and
front side of the robot experiences more pronounced up and OUT4 for Motor B). The motor driver module features four
down movements during sharp turns. Therefore, to maintain
input pins where PWM signals are applied to control the
stability, the center of mass has been aligned with the center
direction and speed of the motors. The output pins of the
of the frame. Additionally, keeping an optimum distance (7
module are specifically designed for DC motors and can
mm) between the ground and QTR-8 reflectance sensor
contributes to stability, particularly during sharp turns. The deliver a maximum current of 2 A for each motor.
distance of the sensor from the ground is so crucial that if the
sensor is too far or too close to the ground, the robot fails to
track the line at all.
B. Electronic Components
1) Microcontroller (STM32F103C8): To read sensor
values and drive the DC motors accordingly, a
microcontroller was utilized. A microcontroller is a compact
integrated circuit that incorporates a processor, memory, and
input/output (I/O) peripherals. STMicroelectronics produces
the STM32F103C8 microcontroller, which belongs to the
STM32 family. These microcontrollers are based on the
ARM Cortex-M3 processor core. The STM32F103C8
microcontroller is equipped with a 32-bit ARM Cortex-M3
processor that can operate at a maximum clock speed of 72 (Figure 2.3 – Motor Driver (L298N))
MHz. It offers various I/O peripherals, including 12-bit
analog-to-digital converters, UARTs, and general-purpose 3) Batteries: Three rechargeble 4.2V Li-ion batteries was
input/output (GPIO) pins. Additionally, it includes a built-in used to power the robot system. The system utilizes a 13 V
RTC (Real Time Clock) and a low-power mode to minimize DC input voltage (from the batteries), with the positive
power consumption. Notably, the STM32F103C8 terminal of the battery connected to the 12 V input pin of the
microcontroller supports the ARM Cortex-M3's memory motor driver. It has been determined that a minimum input
protection unit (MPU), enhancing security and reliability in voltage of 7 V is necessary to ensure a stable 5 V output
operation. The STM32F103C8 microcontroller finds wide- voltage from the motor driver's internal regulator. This
ranging applications in consumer electronics, industrial voltage level is crucial for the efficient operation of both the
control systems, and automotive systems. It is also a popular STM32 microcontroller and the QTR-8 reflectance sensor.
choice among hobbyists and educational projects due to its
affordability, widespread availability, and extensive 4) Reflectance Sensor (QTR-8RC): The QTR-8 sensor
documentation and support provided by the manufacturer. module is employed to enable the robot to track the line. This
Also, it is important to have an original STM32F103C8 card module consists of eight reflectance sensors (see in fig. 2.4)
to operate the system properly. that comprise infrared light emitters, MOSFETs that switch
in response to infrared light, and capacitors. The MOSFETs
control the grounding of the capacitors. Each of the eight pins
corresponding to a sensor is connected to the GPIO pins of
the STM32 microcontroller, as depicted in Figure 2.5 , for
performing read and write operations. When the MOSFETs
are exposed to infrared light, the capacitors are connected to
ground and discharged. After a brief period of a few
milliseconds, the GPIO pins are switched to input mode. If a
specific sensor reads a logic 0, it indicates the presence of a
reflective surface. Conversely, if the reading is logic 1, it
signifies a non-reflective surface, typically dark in color. This
mechanism enables the microcontroller to determine the
position of the line that needs to be followed. It is essential to
note that the distance between the sensors and the track must
(Figure 2.2 – Microcontroller (STM32F103C8)) not exceed 7 mm.
(Figure 2.4 – Reflectance Sensor (QTR-8RC)
∑9𝑛=1 1000 ∙ 𝑆𝑛
𝑥= (1)
∑9𝑛=1 𝑆𝑛
(Figure 3.2 - Location of the right sensors)
∑9𝑛=1 1000 ∙ 𝑆𝑛
𝑒 = 4500 − (2)
∑9𝑛=1 𝑆𝑛
The Proportional term, denoted as P, is a crucial When using proportional control alone, it has been noticed
component of the Proportional-Integral-Derivative (PID) that a steady-state error persists. The mathematical
control algorithm. It plays a primary role in correcting the representation of integral control is given by equation (5).
system's output and reducing the error towards zero. The The integral term involves the accumulation of past errors.
Proportional term is calculated by multiplying the error by a By combining the integral term with the integral gain (𝑘𝑖 ),
constant factor called the proportional gain (𝐾𝑝 ). The value integral feedback is introduced, which effectively reduces
steady-state tracking error by introducing a pole at the origin
of the proportional gain can be adjusted to control the
[3].
controller's responsiveness to changes in the error. A higher
proportional gain leads to a larger control output for a given 𝑡
error, resulting in a faster response. However, a high 𝑢(𝑡) = 𝑘𝑖 ∫ 𝑒(𝜏)𝑑(𝜏) (5)
proportional gain can also lead to overshooting and 𝑡0
instability, so it's important to select an appropriate value
based on the system's characteristics. The Proportional term
primarily drives the correction process for the system's D) Derivative Term (𝐾𝑑 )
output. It is responsible for a significant portion of the
correction when the error is relatively large. As the error The Derivative term in a control system serves two
approaches zero, the Proportional term's influence purposes: providing stability and anticipating future errors. It
diminishes. At this point, the integral and derivative terms is determined by calculating the rate of change of the error
come into play to fine-tune the controller's output and and multiplying it by a constant known as the derivative gain
eliminate steady-state errors. ( 𝐾𝑑 ). The derivative gain is an adjustable parameter that
governs how responsive the controller is to changes in the
Formula (4) represents the mathematical representation of error rate. A higher derivative gain leads to a larger control
proportional control. It has been noticed that when employing output for a given change in the error rate, resulting in a faster
only proportional control, the robot exhibits a faster response response to those changes. However, using a higher
to errors encountered during line tracking. However, if the derivative gain can also lead to overshoot and instability, so
value of the proportional gain ( 𝐾𝑝 ) exceeds a certain it is crucial to select an appropriate value based on the
threshold, the robot experiences significant oscillations. system's characteristics.
Decreasing the proportional gain reduces oscillations, but at
the expense of slower error response. To address this, The Derivative term enhances stability by anticipating
derivative control has been incorporated into the system. future errors. It is computed based on the error's rate of
change, allowing the controller to predict and address errors
𝑢(𝑡) = 𝑘𝑝 𝑒(𝑡) (4) before they occur. This helps to mitigate overshoot and
oscillations that may arise when using only the proportional
and integral terms. It is worth noting that the derivative term
C) Integral Term (𝐾𝑖 ) is sensitive to noise, which can lead to erratic and unstable
control outputs. To mitigate this issue, techniques such as
The Integral term in a control system plays a crucial role in filtering or using a derivative of the measurement instead of
eradicating steady-state errors by progressively driving the the error can be employed.
error towards zero over time. It is computed by multiplying
the accumulated error by a constant known as the integral Equation (6) is the mathematical expression for the
gain (𝐾𝑖 ). The integral gain is an adjustable parameter that classical derivative control. Derivative control has been
governs the rate at which the accumulated error is reduced. A added to eliminate oscillation and overshooting caused by
higher integral gain leads to a larger control output for a given proportional and integral terms.
accumulated error, resulting in a faster reduction of the error.
However, using a larger integral gain can also lead to 𝑑𝑒(𝑡)
𝑢(𝑡) = 𝑘𝑑 (6)
overshoot and instability, so it is essential to select an 𝑑𝑡
appropriate value based on the system's characteristics.
selected to produce outputs on PB10 and PB11 for the first
The derivative (D) control plays a role in preventing two channels without any remapping. By employing the PID
overshooting in the system and enhancing the transient controller and the calculated PID value, the duty cycle (i.e.,
response. However, it is important to acknowledge that the D speed) of the two motors was controlled.
control is sensitive to noise. The reason for this sensitivity is
that the D control acts as a high-pass filter, amplifying sudden After completing all the necessary configurations, the line
changes in the error signal. Throughout the development of follower robot was ready to navigate along the track. It can
the robot, the impact of noise has not been extensively be found the codes of line follower with detailed explanation
observed [3]. and demonstration video in the following links.
Link for the codes:
As a result, during the final design phase, the values of 𝐾𝑝 , https://drive.google.com/drive/folders/1KFhX2eJ4PyPlXyp
𝐾𝑖 , and 𝐾𝑑 were determined to be 0.015, 0.003, and 10, _5h_219WkmtiNEEo2?usp=sharing
respectively, using a trial-and-error approach on the track. It
was observed that setting 𝐾𝑑 too low caused significant Link for the video:
oscillations in the robot's movements. Similarly, 𝐾𝑝 was https://drive.google.com/file/d/1y-DiEAl0--
adjusted to ensure smooth and stable movement. Lastly, 𝐾𝑖 TdewfIteiGaYC-k6pkNZDZ/view?usp=sharing
was fine-tuned to improve line tracking and reduce steady-
state error. These PID control coefficients was determined V. CONCLUSION
based on test track given in figure 3.5.
[2] Kose, O., & KARAS, I. R. (2014). PID controlled line follower robot
design on indoor 3D networks. In IAES Intern. Conf. on Electrical
Engineering, Computer Science and Informatics (EECSI-2014). –
Yogyakarta, Indonesia (pp. 20-21).
https://core.ac.uk/download/pdf/296975585.pdf
[3] Oguten, S., & Kabas, B. (2021). PID Controller Optimization for Low-
cost Line Follower Robots. arXiv preprint arXiv:2111.04149.
https://arxiv.org/pdf/2111.04149.pdf