Modeling and DesignLinear Quadratic Regular controller for balance Inverted Pendulum
Modeling and DesignLinear Quadratic Regular controller for balance Inverted Pendulum
Final Term:
EE2023 Technical Writing and Presentation
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
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).
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.
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
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.
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
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.
Page 7