0% found this document useful (0 votes)
3 views

Modeling and DesignLinear Quadratic Regular controller for balance Inverted Pendulum

This paper presents a method for modeling and designing a Linear Quadratic Regular (LQR) controller for an inverted pendulum system using the Euler-Lagrange method. The study compares the performance of the LQR controller with a PID controller, demonstrating that the LQR controller outperforms the PID in balancing the pendulum. Simulation results validate the effectiveness of the proposed LQR controller in maintaining stability in the system.

Uploaded by

duclms2k3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Modeling and DesignLinear Quadratic Regular controller for balance Inverted Pendulum

This paper presents a method for modeling and designing a Linear Quadratic Regular (LQR) controller for an inverted pendulum system using the Euler-Lagrange method. The study compares the performance of the LQR controller with a PID controller, demonstrating that the LQR controller outperforms the PID in balancing the pendulum. Simulation results validate the effectiveness of the proposed LQR controller in maintaining stability in the system.

Uploaded by

duclms2k3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Hanoi University of Science and Technology

School Electrical and Electronic Engineering

Final Term:
EE2023 Technical Writing and Presentation

Student’s name: Duc Cuong Vu Student ID: 20202313

Son Tran Student ID: 20202691

Lecture: Dr. Van Tuynh Pham

Class ID: 134828

Semester: 2021.3

Ha noi, 9/2022
MODELING AND DESIGN A LINEAR QUADRATIC
REGULAR CONTROLLER FOR BALANCE INVERTED
PENDULUM 1
Duc Cuong Vu a , Son Tran a
a Student at School of Electrical - Electronic Engineering, HUST

ARTICLE INFO ABSTRACT

Last modify: This paper introduces a way to build equations of motion


December 15, 2022 for inverted pendulum by solving the Lagrange equation. The aim
is to linearize the system around the balance positione, in order to
design Linear Quadratic Regular (LQR) controller. Besides, to
Keyword: compare with the above solution , another PID controller is added.
LQR control The simulation results show that the former clearly surpass the
Inverted Pendulum latter in balancing the pendulum.
PID controller
Modeling Inverted Pendulum
Euler - Lagrange method

1 Introduction dulum system is a high-speed instant system, the


work of analyzing image was extremely difficult.
he inverted pendulum system is a com-
T mon phenomena in science section. It
is favouritely demonstrated in the research of
Besides, a number of modern technic, such as
backsteping-PID control has been used on the in-
verted pendulum in 2017 by C.Ghorbel, A.Tiga,
physics, dynamics and control.
S.Rannen and N.Benhadj Braiek [3].
Variety of control technic have been used on
the pendulum, for instances PID controller, Fuzzy Moreover, researches had been made using
controller, comparison can be listed, let take a LQR control for even more complex pendulum
group of authors: Chart Rithirun, Anuchit Charean, systems, for example, the double pendulum in pa-
Winyu Sawaengsinkasikit who published ”Com- per named ”Stabilization of Double Link Inverted
parison Between PID Control and Fuzzy PID Con- Pendulum Using LQR” by Ramashis Banerjee,
trol on Invert Pendulum System” [1]. NaiwritaDey, UjjwalMondal and BonhihotriHazra
Since 1998, Mario E. Magana and Frank [4].
Holzapfel had been success in balancing the pendu- Lastly, in range of the research area, this paper
lum, using Computer Vision. [2]. The researchers will introduce a new way to construct a system, us-
could only use a low-speed processor, as the pen- ing Euler - Lagrange method and design a motion-
1 This
article is an exam for Technical Writting and Presentation. It is not presented at any conferences. All simulation
results are correct, and are produced by my group.

Page 1
feedback LQR controller by learizing the system Assumption 1: Eliminating all friction, be-
around the balance point. Which means that the tween cart and rail, cart and pendulum, and in
subtended angle of the pendulum should be small bearings.
enough ϕ < 10o . Assumption 2: No external disturbances, sup-
The following sections present a step-by-step posing that the whole system is in vaccum space.
routine to design a single inverted pendulum sys-
tem (Section 2), build a motion-feedback LQR
controller (Section 3), simulation and comparison
with prepared PID controller (Section 4), and con-
clusion (Section 5).

2 Modeling Inverted Pendulum


Figure 2: The forces taking effect in the system
u is the force put on the cart, Pp is the gravita-
tional force of the pendulum, θ is the subtended
angle of the pendulum The kinetic of whole sys-
tem include the kinetic of the cart and the kinetic
of the pendulum :
Figure 1: 3D model of Inverted Pendulum
T = Tc + Tp (1)
This system is a common nonlinear system, where,
comprising a rail, which allow a cart to run on; M ẋ2
Tc =
a cart, which receives external force DC Motor 2
or Servo Motor; and a single homologous pendu- and,
lum, which can swing freely on the cart and is Mv2p J θ̇ 2
provided sensor to note the subtended angle for Tp = +
2 2
control purpose . Combine those, the kinetic of whole system can
The routine of constructing this system is be written as follow:
straightforward, using Euler - Lagrange method,
M ẋ2 mv2p J θ̇ 2
Considering the main particles, Getting solution T= + + (2)
of the equation for each of the particles, then all 2 2 2
the equations of motion are illustrated. The velocity of the pendulum contains the velocity
In this section,It can be easily seen as 2 De- values following Ox and Oy:
grees of Freedom (DoF), which means that there v2p = v2x + v2y
should be two differential equations.The one for
= (ẋ + l θ̇ cos θ )2 + (l θ̇ sin θ )2
x, the motion values of the cart’s location. The
other for θ , the motion values of the pendulum’s = ẋ2 + 2ẋl θ̇ cos θ + (l θ̇ )2
subtended angle. Using above results to solve equation (2):
So, ẋ, θ̇ are the velocity of the cart and the
angle velocity of the pendulum ; ẍ, θ̈ are the ac- M ẋ2 m(ẋ2 + 2ẋl θ̇ cos θ + (l θ̇ )2 ) J θ̇ 2
T= + +
celeration of the cart and the angle acceleration of 2 2 2
the pendulum. which can be represented shortly as:
Assumptions: To simplify the system and 1 1
make an reliable system (acceptable errors), it is T = (M + m)ẋ2 + (ml 2 + J)θ̇ 2 + mẋl θ̇ cos θ
2 2
reputed that: (3)

Page 2
Using Euler - Lagrange equation, it is given that: and,
dT
! = −mẋl θ̇ sin θ (14)
d dT dT dθ
− = Qi (4)
dt d q̇i dqi Using eqs. (11) to (14), the second binding equa-
tion of x and θ is:
∑ δ A uδ x + Pp l sin θ δ θ
Qi =
δ qi
=
δ qi
(5) (ml 2 + J)θ̈ + mẍl cos θ = mgl sin θ (15)
with particle x : In conclusion, the equation of motion is written as
Qx = u (6) follow :
!
d dT dT
(M + m)ẍ + ml(θ̈ cos θ − θ̇ 2 sin θ ) = u (16a)

− = Qx (7)
dt d ẋ dx
(ml 2 + J)θ̈ + mẍl cos θ = mgl sin θ (16b)
From eq. (4),
dT ˙ + ml θ̇ cos θ
= (M + m)(x) 3 Design LQR controller
d ẋ
Control signal of the LQR controller is calcu-
Derivative of the above result,
lated by multiplying the matrix K with the motion-
! feedback signal.
d dT 2
= (M + m)ẍ + ml(θ̈ cos θ − θ̇ sin θ )
dt d ẋ
u = −Kx
(8)
and, The matrix K is designed to get optimal gain
dT matrix K, by minimize cost function [5] [4]:
=0 (9)
dx Z
Using eqs. (6) to (9), the first binding equation of JLQG = (xT Qx + uT Ru)dt
x and θ is:
In Table 1, the parameters describing the sys-
(M + m)ẍ + ml(θ̈ cos θ − θ̇ 2 sin θ ) = u (10) tem are listed.

With particle θ , similarly calculated: Mass of cart (M) 1 (kg)


Mass of pendulum (m) 0.1 (kg)
Qθ = mgl sin θ (11) Length of rail (L) 1 (m)
! Length of pendulum (l) 0.2 (m)
d dT dT Inertial of pendulum (J) 0.083 (kg.m2 )
− = Qθ (12)
dt d θ̇ dθ Gravitational acceleration (g) 9.81 (m/s2 )
From eq. (4), Table 1: Parameter of inverted pendulum system
dT The pendulum is a homologous object, there-
= (ml 2 + J)θ̇ + mẋl cos θ
d θ̇ fore, gravitational center can be taken approxi-
Derivative of the above result mately at the midpoint of the pendulum.
! The pendulum swing around one of its tip, so
d dT the enertia of its can be discribed as:
= (ml 2 + J)θ̈ + mẍl cos θ − mẋl θ̇ sin θ
dt d θ̇ ml 2
(13) J=
3

Page 3
From eq. (16a) and eq. (16a), θ̈ and ẍ are determined:

ml(ml cos θ sin(θ )θ̇ 2 + u cos(θ ) − gm sin θ − Mg sin θ )



 θ̈ =
 m2 l 2 cos2 (θ ) + l 2 m2 + Ml 2 m + Jm + JM
 sin(θ )m2 l 3 θ̇ 2 − g cos(θ ) sin(θ )2 l 2 + u.ml 2 + J sin(θ )ml θ̇ 2 + Ju
ẍ =


−m2 l 2 cos(θ )2 + m2 l 2 + Mml 2 + J(m + M)
 T  T
Let, X = x1 x2 x3 x4 = x ẋ θ θ̇ therefore, the matrixes of Q, R will have weighted
      values ralative to x:
x˙1 ẋ f1 (x1 , x2 , x3 , x4 , u)  
x˙2   ẍ   f2 (x1 , x2 , x3 , x4 , u) 100 0 0 0
 = =   0 1 0 0
x˙3  θ̇   f3 (x1 , x2 , x3 , x4 , u)
Q=  0 0 1 0 , R = [0.01]

x˙4 θ̈ f4 (x1 , x2 , x3 , x4 , u)
0 0 0 1

The most improtant notice of designing a LQR As consequence,


controller is that it is a linear controller. Equations 
K = −100 −56.71 −163.66 −28.61

of motion around the balance position have been
made. Note that the subtended angle of the pendu-
lum is less than 10 degree. Equations of motion

can be written as below: x0 ≈ 0 0 0 0
T 4 Simulation
The LQR controller is a state feedback con-

ẋ = Ax + Bu
y = Cx troller given the following:
where,

0 1 0 0
 
0 −gm2 l 2
0 Mml 2 +J(M+m)
0
A=
 
0 0 0 1

mgl(M+m)
0 0 Mml 2 +J(M+m)
0
Figure 3: Design a LQR controller
 
0 To make it easy for showing the benefit of this
ml 2 +J
controller, another PID controller is shown.
 
1 0 0 0
 
2
B =  Mml +J(M+m)  C=
 
 0  0 0 1 0 A common PID controller calculates and con-
−ml trols error e. Discribed as below [6][3]
Mml 2 +J(M+m)
Zt
!
1 de
Substitute the values given in the above table, u= e+ edt + Td
Ti dt
    0
0 1 0 0 0 where, e is error between yre f và y.
0 0 −0.7178 0
 , B =  0.9756 
 
A= According to the pendulum system, which
0 0 0 1  0 
have one input and two outputs, The necessary
0 0 39.4793 0 −3.6585 PID controller must contain two smaller PID con-
trollers for the two motion values. The control
Because of the limited rail, it means that the signal is the combination of signals caculated by
cart can only move throughout the preset route, the two PIDs controllers. [7]

Page 4
benefit over the PID controller, in overshot rate
and converging rate.

At the angle of 20 degree, cart at position 0

Figure 4: PID controller for 1 input, 2 outputs sys-


tem

In the first PID controller, error signal e1 =


xr − x, K p1 = 2, Ki1 = 0, Kd1 = 2
In the second PID controller, error signal
e1 = θr − θ , K p2 = 20, Ki2 = 0, Kd2 = 2

At the angle of 10 degree, cart at position 0

Figure 7: Angle of pendulum with θ0 = 20o and


x0 = 0m

Figure 5: Angle of pendulum with θ0 = 10o and


x0 = 0m

Figure 8: Posion of cart with θ0 = 20o and x0 = 0m

Even that the subtended angle is over 20 de-


gree, LQR controller still work perfectly, which
means that it remarkable better than PID controller.
The time it takes to balance the pendulum is 3 sec-
onds, 1 second faster than the PID’s.
Figure 6: Posion of cart with θ0 = 10o and x0 = 0m

It can be clearly seen that, neaby the balance At the angle of 10 degree, cart at position of
position, the LQR controller show ı́t outstanding -0.4m, guide the cart to position 0

Page 5
Figure 11: Angle of the pendulum when reference
of cart is a pulse signal

Figure 9: Angle of pendulum with θ0 = 10o and


x0 = −0, 4m
Figure 12: Position of the pendulum when refer-
ence of cart is a pulse signal
Chasing speed of LQR controller is outper-
formed, otherwise, the subtended angle of the pen-
dulum will have a high adjusting rate.

5 Conclusion
In conclusion, the work of constructing the
paradigms and design of the system is demon-
Figure 10: Posion of cart with θ0 = 10o and strated above. Building a LQR controller make it
x0 = −0, 4m possible to control the system around the balance
Eventhough it takes the same amount of time point in a easy and optimal way. Tt can be seen
to get the angle of 0, the former takes 3 seconds to necessary for a nonlinear system as the inverted
move to the preset point, while the latter takes 3.5 pendulum.
seconds. Moreover, the PID controller is made using
well-prepared parameters. Hence, pointing out the
noteworthy benefits of LQR controller in balanc-
Control the position of cart follow a pre- ing the inverted pendulum.
pared routine, the chosen route here is pulse sig-
nal, with cycle of 13 seconds, pulse width of 50%,
interesting results can be collected:
References
[1] W. S. Chart Rithirun, Anuchit Charean, “Com-
parison between pid control and fuzzy pid con-
trol on invert pendulum system,” IEEE, 2021.
[2] M. E. Magana and F. Holzapfel, “Fuzzy-logic
control of an inverted pendulum with vision
feedback,” IEEE, 1998.
[3] S. C.Ghorbel, A.Tiga and N. Braiek, “Com-
bined backstepping-pid control of inverted
pendulum,” IEEE, 2017.

Page 6
[4] U. Ramashis Banerjee, NaiwritaDey and Bon-
hihotriHazra, “Stabilization of double link in-
verted pendulum using lqr,” IEEE, 2018.

[5] M. Nenad Muskinja and M. Boris Tovornik,


“Swinging up and stabilization of a real in-
verted pendulum,” IEEE, 2006.

[6] S. Bennett, “Development of the pid con-


troller,” IEEE, 1993.

[7] Y. K. S. Omatu, T. Fujinaka and M. Yosh-


ioka, “Self - turning neuro pid for simo sys-
tem,” IEEE, 1999.

Duc Cuong Vu, enter-


ing Hanoi University of Sci-
ence and Technology in
2020, is currently a 2nd
year student majoring in
Automation and Control
Engineering. He is working
and researching at MEG lab
on self-balancing devices
Inverted Pendulum, Ball-
Bot,..
Contact: [email protected]
Son Tran, studied at
Hanoi Amsterdam High
School for the Gifted. He
entered Hanoi University
of Science and Technology
in 2020. Currently he is
a 2nd year student, major-
ing in Control and Automa-
tion Engineering. Son is
working in iPAC lab, he re-
searches issues of internet
of things
Contact: [email protected]

Page 7

You might also like