Professional Documents
Culture Documents
TECHNOLOGY
School of Electrical and Electronic Engineering
Control and Automation Department
PROJECT REPORT
LINEAR CONTROL THEORY
THREE – WHEELED LINE FOLLOWER ROBOT MODELING
Hanoi, 2022
1
Contents
I. Introduction ......................................................................................................................................... 3
1.1. Wheeled Mobile Robot .................................................................................................................... 3
1.2. Wheeled Mobile Robot Types ......................................................................................................... 3
1.2.1. Differential Wheeled Robot...................................................................................................... 3
1.2.2. Bicycle Drive Robot .................................................................................................................. 3
1.2.3. Tricycle Robot ........................................................................................................................... 3
1.2.4. Car Drive Robot .................................................................................................................. 4
1.2.5. Omni Wheeled Robot................................................................................................................ 4
1.3. Differential Wheeled Robot............................................................................................................. 5
II. Main Components ........................................................................................................................... 5
2.1. IR Sensor........................................................................................................................................... 5
2.2. Wheel................................................................................................................................................. 7
2.3. DC Motor .......................................................................................................................................... 8
2.4. Battery............................................................................................................................................... 9
2.5. Microcontroller Arduino Uno R3 ................................................................................................. 10
2.5. Motor Drive L298N........................................................................................................................ 11
III. Modeling ........................................................................................................................................ 13
3.1. State Space Model .......................................................................................................................... 13
3.2. Controller........................................................................................................................................ 13
3.3. Voltage Regulator .......................................................................................................................... 16
3.4. Deviation Calculation .................................................................................................................... 17
IV. Realistic Simulation: ..................................................................................................................... 19
4.1. Build programs and algorithms .................................................................................................... 19
4.2. Flow chart ....................................................................................................................................... 21
4.3. Run simulation ............................................................................................................................... 21
4.4. Code Arduino ................................................................................................................................. 22
V. Results: ............................................................................................................................................... 27
VI. References:..................................................................................................................................... 27
2
I. Introduction
1.1. Wheeled Mobile Robot
- Wheeled Mobile Robot (WMR) have the capability to move around in their
environment and are not fixed to one physical location. Wheeled Mobile
Robot can be "autonomous" which means they are capable of navigating an
uncontrolled environment without the need for physical or electro-
mechanical guidance devices.
- Mobile robots have become more commonplace in commercial and
industrial settings. Mobile robots are also found in industrial, military and
security settings.
- The components of a mobile robot are a controller, sensors, actuators and
power system.
1.2. Wheeled Mobile Robot Types
1.2.1. Differential Wheeled Robot
- A differential wheeled robot is
a mobile robot whose movement is
based on two separately
driven wheels placed on either side of
the robot body. It can thus change its
direction by varying the relative rate of
rotation of its wheels and hence does
not require an additional steering
motion. Robots with such a drive
typically have one or more castor wheels to prevent the vehicle from tilting.
1.2.2. Bicycle Drive Robot
- Unlike Differential Dive, Bicycle
Drive also has 2 wheels, but its 2
wheels are arranged in a straight line,
and usually, only one wheel is active
and one wheel can control the steering
angle, similar in structure. like a
bicycle. This type of robot is sporadic
due to its low practical application.
1.2.3. Tricycle Robot
- Tricycle Drive is a combination of the 2 types of WMR mentioned above, it
has 3 wheels and in which 2 rear wheels are arranged coaxially, and one
front wheel acts as a steering wheel; 2 of the 3 wheels will be attached to the
3
actuator for control and the other wheel to be free, or the actuator can also be
used to control only one front rudder at the desired speed and steering angle.
1.2.4. Car Drive Robot
- This type of WMR has a structure similar to a car with 2 front wheels that
can change the steering angle.
1.2.5. Omni Wheeled Robot
- Omni Wheels are another option for wheeled robots, an Omni wheel has an
axis perpendicular to the axis of the core wheel. This allows the wheels to
move in two directions, Omni-wheeled robots can move at any angle in any
direction, without rotating beforehand.
4
1.3. Differential Wheeled Robot
- For this project, our team chooses Differential Wheeled Robot model which
has three – wheel. We have developed a Line Follower Robot based on
differential drive mechanism.
5
- Specifications:
• Use 1 LED emit infrared.
• 1 led infrared receiver.
• Main IC LM358 SMD.
• LED indicator light.
• 10K square VR adjustment rheostat.
• Pins AO – DO – GND – VCC
• Operating voltage: 3.3 – 5 VDC
• VCC= 3 – 5 VDC
• GND = 0V.
• DO = Output signal 0/1
- Signal Processing Algorithm: Comparative Method
• Use the comparator to determine the on/off status of the sensors, then infer
the vehicle position according to a predefined table of states. With this
method, the line detection error will depend on the number of states of the
system, or the distance between sensors and this method has fast processing
speed.
6
- We will use PID method to adjust position of wheel mobile robot. We set value for
middle point of sensor array. Then, using PID method to make error value
between middle point and other point is minimum. From that, the wheel mobile
robot can track the predetermine line.
2.2. Wheel
- Fixed wheels: Because the vehicle moves on flat terrain at high speed, we choose
ordinary rubber wheels that have a large tank and no spikes.
➔ We use 2 yellow wheels: diameter 66mm. They are attached at the behind of mobile
robot.
- Free wheel: Wheel has the ability to change direction easily, small friction.
- This wheel can move in all directions, when changing direction does not slip and
change the vehicle’s center of gravity of robot when moving.
7
2.3. DC Motor
- DC motor is any kind of rotary electrical motors that converts direct current (DC)
electrical energy into mechanical energy. The output wire of this motor usually
consists of two wires (power wire - VCC and ground wire - GND).
- Input parameters:
Load and vehicle mass 2.7 Kg
Diameter of fix wheel 66mm
Max of velocity 1 m/s
Acceleration 0.5 𝑚/𝑠 2
Fraction coefficient 0.6
Safe coefficient 3
- We consider that:
• I: moment of inertia (kg.𝑚2 )
• T: Torque (N.m)
• R: Radius of wheel (m)
• 𝐹𝑓 : Friction force (N)
• 𝛾: Angular acceleration (rad/𝑠 2 )
• Ω: Angular velocity (rad/s)
• a: Acceleration (𝑚/𝑠 2 )
• M: Mobile robot mass
• m: Wheel mass
- Inertia moment of fixed wheel:
1
𝐼 = 𝑚𝑅2 = 0.18 × 10−3 (𝑘𝑔. 𝑚2 )
2
- Friction force at 1 wheel:
𝐹𝑓 = (0.5𝑀 + 𝑚)𝑎 = 0.65 (𝑁)
- Equation:
8
𝑇 − 𝐹𝑓 . 𝑅 = 𝐼𝛾
𝑎
⇒ T = 𝐹𝑓 . 𝑅 + 𝐼𝛾 = 𝐹𝑓 . 𝑅 + 𝐼. = 23.89 (𝑁. 𝑚𝑚)
𝑅
Power of motor need:
𝑣
𝑃 = 𝑐. 𝑇. 𝜔 = 3 × 23.89 × = 2.2 (𝑊)
𝑅
➔ Choose Yellow DC motor
- Specification:
• Voltage: 3 – 12V
• Load current: 70 mA (at 3V)
• Torque: 800 gfcm = 0.08 Nm
• Gear ratio: 1:48
• Speed: 300 rpm (at 10V)
𝑇.𝑛
• Power: 𝑃 = = 2.5 𝑊
9.55
2.4. Battery
- An 18650 is a lithium ion rechargeable battery. Their proper name is “18650 cell”.
The 18650 cell has voltage of 3.7V and has between 1800mAh and 5000mAh
9
- Specification:
• Quantity: 3 pins
• Voltage: 3.7V
• Capacity: 5000mAh
- 3 pins are connected in series, so total Voltage is approximately 12V. This voltage
is suitable for requirement of robot
2.5. Microcontroller Arduino Uno R3
- The Arduino Uno is an open-source microcontroller board which is developed
by Arduino.cc based on the Microchip ATmega328P microcontroller. It is
programmable with the Arduino IDE (Integrated Development Environment) via a
type B USB cable.
- The board is equipped with sets of digital and analog input/output (I/O) pins that
may be interfaced to various expansion boards (shields) and other circuits. It can
be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts.
- Specification:
10
• It is an Atmega328P based Microcontroller
• The operating voltage of the Arduino is 5V
• The recommended input voltage ranges from 7V to 12V
• The i/p voltage (limit) is 6V to 20V
• Digital input and output pins – 14
• Digital input & output pins (PWM) – 6
• Analog i/p pins are 6
• DC current for each I/O Pin is 20mA
• DC current used for 3.3V Pin is 50mA
• Flash Memory – 32KB, and 0.5 KB memory is used by the boot loader
• SRAM is 2 KB
• EEPROM is 1 KB
• The speed of the CLK is 16 MHz
• Built-in LED
• Length and width of the Arduino are 68.6mm X 53.4mm
• The weight of the Arduino board is 25g
2.5. Motor Drive L298N
- This L298N Motor Driver Module is high power motor driver module for driving
DC and Stepper Motors. This module consists of an L298 motor driver IC and a
78M05 5V regulator. L298N Module can control up to 4 DC motors, or 2 DC motors
with directional and speed control.
- Specification:
• Driver Model: L298N 2A
• Driver Chip: Double H Bridge L298N
• Motor Supply Voltage (Maximum): 46V
• Motor Supply Current (Maximum): 2A
• Logic Voltage: 5V
• Driver Voltage: 5 – 35V
11
• Driver Current: 2A
• Logical Current: 0 – 36mA
• Maximum Power (W): 25W
• Current Sensor for each motor
• Heatsink for better performance
• Power – on LED indicator
- Configuration Pinout:
• IN1 & IN2: Motor A input pins. Used to control the spinning direction of
Motor A
• IN3 & IN4: Motor B input pins. Used to control the spinning direction of
Motor B
• ENA: Enables PWM signal for Motor A
• ENB: Enables PWM signal for Motor B
• OUT1 & OUT2: Output pins of Motor A
• OUT3 & OUT4: Output pins of Motor B
• 2V: 12V input from DC power Source
• 5V: Supplies power for the switching logic circuitry inside L298N IC
• GND: GND pin
- The L298N Motor Driver module consists of an L298 Motor Driver IC, 78M05
Voltage Regulator, resistors, capacitor, Power LED, 5V jumper in an integrated
circuit
- ENA & ENB pins are speed control pins for Motor A and Motor B while IN1 & IN2
and IN3 & IN4 are direction control pins for Motor A and Motor B.
12
III. Modeling
13
• 𝑭(𝒒̇ ) 𝑖𝑠 𝑡ℎ𝑒 𝑓𝑟𝑎𝑐𝑡𝑖𝑜𝑛 𝑣𝑒𝑐𝑡𝑜𝑟
• 𝑮(𝒒) 𝑖𝑠 𝑡ℎ𝑒 𝑔𝑟𝑎𝑣𝑖𝑡𝑎𝑡𝑖𝑜𝑛𝑎𝑙 𝑣𝑒𝑐𝑡𝑜𝑟
• 𝑬(𝒒) 𝑖𝑠 𝑡ℎ𝑒 𝑖𝑛𝑝𝑢𝑡 𝑡𝑟𝑎𝑛𝑠𝑓𝑜𝑟𝑚𝑎𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥
• 𝒖 𝑖𝑠 𝑎 𝑐𝑜𝑛𝑡𝑟𝑜𝑙 𝑖𝑛𝑝𝑢𝑡 𝑣𝑒𝑐𝑡𝑜𝑟
• 𝑨(𝒒) 𝑖𝑠 𝑎 𝑚𝑎𝑡𝑟𝑖𝑥 𝑎𝑠𝑠𝑜𝑐𝑖𝑎𝑡𝑒𝑑 𝑤𝑖𝑡ℎ 𝑛𝑜𝑛ℎ𝑜𝑙𝑜𝑛𝑜𝑚𝑖𝑐 𝑐𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠
• 𝝀 𝑖𝑠 𝑡ℎ𝑒 𝑣𝑒𝑐𝑡𝑜𝑟 𝑜𝑓 𝐿𝑎𝑔𝑟𝑎𝑛𝑔𝑒 𝑚𝑢𝑙𝑡𝑖𝑝𝑙𝑖𝑒𝑟𝑠
• 𝒒̇ 𝑎𝑛𝑑 𝒒̈ 𝑑𝑒𝑛𝑜𝑡𝑒 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 𝑎𝑛𝑑 𝑎𝑐𝑐𝑒𝑙𝑒𝑟𝑎𝑡𝑖𝑜𝑛 𝑣𝑒𝑐𝑡𝑜𝑟𝑠
- As we consider the Wheeled Mobile Robot running in ideal environment and on a
flat ground, the fraction vector and the gravitational vector are eliminated. This
means 𝑭(𝒒̇ ) = 𝟎 and 𝑮(𝒒) = 𝟎. Suppose that the centripetal Coriolis matrix equals
zero – 𝑪(𝒒, 𝒒̇ ) = 𝟎.
- After considering Kinematic and Dynamic Model of WMR, we have
𝑴(𝒒)𝒒̈ = 𝑬(𝒒)𝒖 − 𝑨𝑻 (𝒒)𝝀
, where
𝑚 0 0
𝑴 = [ 0 𝑚 0]
0 0 𝐽
cos 𝜑 cos 𝜑
1 sin 𝜑 sin 𝜑
𝑬= [ 𝐿 −𝐿 ]
𝑟
2 2
𝜏𝑅
𝒖 = [𝜏 ]
𝐿
− sin 𝜑 cos 𝜑 0
𝑨=[ ]
− sin(𝛼 + 𝜑) cos(𝛼 + 𝜑) 𝑑 cos 𝛼
𝜆
𝝀 = [ 1]
𝜆2
- Matrix S contains two columns presenting the possible moving direction of WMR:
cos 𝜑 0 −𝜑̇ sin 𝜑 0
𝑺 = [ sin 𝜑 0] 𝑎𝑛𝑑 𝑺̇ = [ 𝜑̇ sin 𝜑 0]
0 1 0 0
- Moreover, we have the relationship between 𝑨, 𝑺, 𝒒̇ and 𝒗:
𝑨. 𝑺 = 𝟎
𝒒̇ = 𝑺. 𝒗
14
- To simplify the Dynamic Equation, we temporarily eliminate the dependence in 𝒒
of matrix vectors
𝑴. 𝒒̈ = 𝑬. 𝒖 − 𝑨𝑻 . 𝝀
- Take the derivative of 𝒒̇ , we have 𝒒̈ = 𝑺̇. 𝒗 + 𝑺. 𝒗̇
𝑴. 𝑺̇. 𝒗 + 𝑴. 𝑺. 𝒗̇ = 𝑬. 𝒖 − 𝑨𝑻 . 𝝀
- Multiply both sides by 𝑺𝑻
𝑺𝑻 . 𝑴. 𝑺̇. 𝒗 + 𝑺𝑻 . 𝑴. 𝑺. 𝒗̇ = 𝑺𝑻 . 𝑬. 𝒖
- Denote
𝑺𝑻 . 𝑴. 𝑺̇ = 𝑽 ̃
{𝑺𝑻 . 𝑴. 𝑺 = 𝑴 ̃
𝑺𝑻 . 𝑬 = 𝑬 ̃
𝑚 0 0 −𝜑̇ sin 𝜑 0
̃=[ cos 𝜑 sin 𝜑 0 0 0
𝑽 ] [ 0 𝑚 0] [ 𝜑̇ sin 𝜑 0] = [ ]
0 0 1 0 0 𝐽 0 0
0 0
𝑚 0 0 cos 𝜑 0
̃ = [cos 𝜑 sin 𝜑 0] [ 0 𝑚 0] [ sin 𝜑 0] = [𝑚 0]
𝑴
⇒ 0 0 1 0 0 𝐽 0 𝐽
0 1
cos 𝜑 cos 𝜑
cos 𝜑 sin 𝜑 0 1 sin 𝜑 sin 𝜑 1 1 1
̃
𝑬=[ ]. .[ 𝐿 𝐿 −𝐿]
0 0 1 𝑟 −𝐿 ] = 𝑟 . [
{ 2 2
2 2
𝑣 ̃ −𝟏 . 𝑬
̃. 𝒖
⇒ 𝒗̇ = [ ] = 𝑴
𝜔
- The difference between practical velocity and reference velocity:
𝑣 𝑣𝒓
𝒗𝒆 = 𝒗 − 𝒗𝒓 = [ ] − [𝜔 ]
𝜔 𝒓
15
• lim 𝒗𝒆 = 𝟎
𝑡→∞
16
- From the block diagram of DC motor, we have:
1 1
(𝑉𝑎 − 𝐾𝜔𝑚 ) . 𝐾. = 𝜔𝑚
𝑅𝑎 + 𝑠𝐿𝑎 𝐵 + 𝑠𝐽
𝐾 2 + (𝑅𝑎 + 𝑠𝐿𝑎 )(𝐵 + 𝑠𝐽) 𝑉𝑎 𝐾
⇒ 𝜔𝑚 =
(𝑅𝑎 + 𝑠𝐿𝑎 )(𝐵 + 𝑠𝐽) (𝑅𝑎 + 𝑠𝐿𝑎 )(𝐵 + 𝑠𝐽)
𝐾
⇒ 𝜔𝑚 = 𝑉𝑎 .
𝐾 2 + (𝑅𝑎 + 𝑠𝐿𝑎 )(𝐵 + 𝑠𝐽)
, where:
• 𝑉𝑎 : 𝑎𝑟𝑚𝑎𝑡𝑢𝑟𝑒 𝑖𝑛𝑝𝑢𝑡 𝑣𝑜𝑙𝑡𝑎𝑔𝑒
• 𝐼𝑎 : 𝑎𝑟𝑚𝑎𝑡𝑢𝑟𝑒 𝑐𝑢𝑟𝑟𝑒𝑛𝑡
• 𝐸𝑏 : 𝑏𝑎𝑐𝑘 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑑 𝐸𝑀𝐹 (𝐸𝑏 = 𝑅. 𝜔𝑚 )
• 𝑅𝑎 : 𝑎𝑟𝑚𝑎𝑡𝑢𝑟𝑒 𝑟𝑒𝑠𝑖𝑠𝑡𝑎𝑛𝑐𝑒
• 𝐿𝑎 : 𝑎𝑟𝑚𝑎𝑡𝑢𝑟𝑒 𝑖𝑛𝑑𝑢𝑐𝑡𝑎𝑛𝑐𝑒
• 𝐵: 𝑑𝑎𝑚𝑝𝑖𝑛𝑔 𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡
• 𝐽: 𝑚𝑜𝑡𝑜𝑟 𝑏𝑜𝑑𝑦 𝑖𝑛𝑒𝑟𝑡𝑖𝑎
• 𝑇𝐿 : 𝑙𝑜𝑎𝑑 𝑡𝑜𝑟𝑞𝑢𝑒
• 𝑇𝑚 : 𝑚𝑜𝑡𝑜𝑟 𝑒𝑙𝑒𝑐𝑡𝑟𝑖𝑐 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑑 𝑡𝑜𝑟𝑞𝑢𝑒
• 𝜔𝑚 : 𝑎𝑛𝑔𝑢𝑙𝑎𝑟 𝑠𝑝𝑒𝑒𝑑
- The relationship between linear velocity and angular velocity of DC motor:
𝑣 = 𝑅. 𝜔𝑚
3.4. Deviation Calculation
18
IV. Realistic Simulation:
- After choosing main components, we have the circuit design on Proteus and the
practical one of Wheeled Mobile Robot
19
00010 Line is on the right of the robot
00001 Line is on the right of the robot
- We will use PID method to adjust position of wheel mobile robot. We set value for
middle point of sensor array. Then, using PID method to make error value
between middle point and other point is minimum. From that, the wheel mobile
robot can track the predetermine line. So we have table transformation between
sensor value and PID variables.
Sensor value PID values
00100 0
10000 2
01000 1
00010 -2
00001 -1
20
4.2. Flow chart
- After having signal from sensor, we check one by one case and calculate PID
variables to control motor.
21
- We change PID variables and calculate the velocity of each wheels.
// Motor Variables
int ENA = 6;
int motorInput1 = 11;
int motorInput2 = 10;
int motorInput3 = 9;
int motorInput4 = 8;
int ENB = 5;
// PID Constants
float Kp = 4;
float Ki = 0.1;
float Kd = 0;
int deltaV;
int Vl;
int Vr;
const int V0 = 45;
float error = 0, P = 0, I = 0, D = 0;
float previous_error = 0, previous_I = 0;
int flag = 0;
void setup()
{
pinMode(sensor1, INPUT);
pinMode(sensor2, INPUT);
pinMode(sensor3, INPUT);
23
pinMode(sensor4, INPUT);
pinMode(sensor5, INPUT);
pinMode(motorInput1, OUTPUT);
pinMode(motorInput2, OUTPUT);
pinMode(motorInput3, OUTPUT);
pinMode(motorInput4, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
void loop()
{
/*x1 = digitalRead(sensor1);
x2 = digitalRead(sensor1);
x3 = digitalRead(sensor1);
x4 = digitalRead(sensor1);
x5 = digitalRead(sensor1);
Serial.print(x1);
Serial.print(x2);
Serial.print(x3);
Serial.print(x4);
Serial.println(x5);
delay(500);*/
/*read_sensor_values();
Serial.print(sensor[0]);
Serial.print(sensor[1]);
Serial.print(sensor[2]);
24
Serial.print(sensor[3]);
Serial.println(sensor[4]);
delay(500);*/
//dieu_khien_robot(90, 90);
read_sensor_values();
calculate_pid();
calculate_velocity(deltaV);
dieu_khien_robot(Vl, Vr);
Serial.println(Vl);
Serial.println(Vr);
delay(500);
}
void read_sensor_values()
{
sensor[0] = digitalRead(sensor1);
sensor[1] = digitalRead(sensor2);
sensor[2] = digitalRead(sensor3);
sensor[3] = digitalRead(sensor4);
sensor[4] = digitalRead(sensor5);
void calculate_pid()
{
P = error;
I = I + previous_I;
D = error - previous_error;
25
previous_I = I;
previous_error = error;
}
void calculate_velocity(int dv)
{
Vl = V0 - dv;
Vr = V0 + dv;
}
void dieu_khien_robot(int vl, int vr)
{
motor_control(1, vl);
motor_control(0, vr);
}
void motor_control(int motor, int v) // 0 is right, 1 is left
{
int en;
int input1;
int input2;
if(motor == 0)
{
input1 = motorInput1;
input2 = motorInput2;
en = ENA;
}else{
en = ENB;
input1 = motorInput3;
input2 = motorInput4;
}
if( v >= 0)
{
digitalWrite(input1, LOW);
digitalWrite(input2, HIGH);
analogWrite(en,v);
}
else{
digitalWrite(input1, HIGH);
digitalWrite(input2, LOW);
analogWrite(en,-v);
}
}
26
V. Results:
- Our team has builts the mathematical model and control algorithms for the
Line Follower Mobile Robot
- The Mobile Robot is able to follow the line on flat ground. Sometimes, the
Mobile Robot fluctuates due to the delayed response time and the error of
hardware components
VI. References:
[1] https://www.mathworks.com/help/supportpkg/arduino/ref/arduino-robot-
line-follower-application.html
[2] https://quartzcomponents.com/blogs/electronics-projects/line-follower-
robot-using-arduino
27