Paper 21
Paper 21
Research paper
Abstract
A Cart Inverted Pendulum System is an unstable, nonlinear and underactuated system. This makes a cart inverted pendulum system used
as a benchmark for testing many control method. A cart must occupy the desired position and the angle of the pendulum must be in an
equilibrium point. System modeling of a cart inverted pendulum is important for controlling this system, but modeling using assumptions
from state-feedback control is not completely valid. To minimize unmeasured state variables, state estimators need to be designed. In this
paper, the state estimator is designed to complete the state-feedback control to control the cart inverted pendulum system. The mathemat-
ical model of the cart inverted pendulum system is obtained by using the Lagrange equation which is then changed in the state space
form. Mathematical models of motors and mechanical transmissions are also included in the cart inverted pendulum system modeling so
that it can reduce errors in a real-time application. The state gain control parameter is obtained by selecting the weighting matrix in the
Linear Quadratic Regulator (LQR) method, then added with the Leuenberger observer gain that obtained by the pole placement method
on the state estimator. Simulation is done to determine the system performance. The simulation results show that the proposed method
can stabilize the cart inverted pendulum system on the cart position and the desired pendulum angle.
Keywords: Cart Inverted Pendulum; Lagrange Equation; LQR; State Estimator; State-Feedback Control
model of the system can be described. 𝑛 is the total established The potential energy is only affected by the mass of the pendulum
equalised coordinate and 𝑞𝑖 is an exempt degree of freedom from 𝑚
the system.
𝑃 = 𝑚𝑔ℎ = 𝑚𝑔𝑙 cos 𝜃 (12)
−𝑚𝑔𝑙 cos 𝜃
The dynamics of the system must be declared in terms of 𝜃 and 𝑥
as the two degrees of freedom of the system. The equation for
each generalised coordinate can be derivated as follows
Fig. 1: System of a cart inverted pendulum
𝑑 𝜕ℒ 𝜕ℒ
( )− =𝑓 (14)
The Lagrangian equation 𝓛 can be described as 𝑑𝑡 𝜕𝑥̇ 𝜕𝑥
𝑑 𝜕ℒ 𝜕ℒ
𝓛 = 𝑲(𝐪, 𝐪̇ ) − 𝑷(𝐪) (1) ( ) − =0 (15)
𝑑𝑡 𝜕𝜃̇ 𝜕𝜃
where the equalised coordinate 𝐪 and the derivation of it 𝐪̇ are The equation shows that the DC motor or external force only af-
used in the function of kinematic energy. The equalised coordinate fect the cart in 𝑖̂ direction. The external force does not affects the
𝐪 used in the function of potential energy. The term of 𝑥 and 𝜃, pendulum. The differential equation from Eq.(14) and Eq.(15) can
thus 𝐪 = [𝑥, 𝜃] are the cart inverted pendulum system coordi- be derived as
nate.The desired position can be derived as follows
𝑑 𝜕ℒ 𝜕ℒ 𝜕ℒ
(
𝑑𝑡 𝜕𝑞𝑖̇
)−
𝜕𝑞𝑖
= 𝑄𝑖 (2) ( ) = (𝑀 + 𝑚)𝑥̇ + 𝑚𝑙𝜃̇ cos 𝜃 (16)
𝜕𝑥̇
𝑑 𝜕ℒ
where 𝑄𝑖 is the external force that applied in term of 𝑞𝑖 coordinate. ( ) = (𝑀 + 𝑚)𝑥̈ + 𝑚𝑙𝜃̈ cos 𝜃 − 𝑚𝑙𝜃̇ 2 sin 𝜃 (17)
𝑑𝑡 𝜕𝑥̇
The Lagranges equation shown in Eq.(2). The total kinetic energy
of the cart obtained with the movement of the cart is only in hori- 𝜕ℒ
=0 (18)
zontal axis 𝑖̂ direction as 𝜕𝑥
1
𝐾𝑀 = 𝑀𝑥̇ 2 (3) and
2
where 𝑀 is the mass of the cart and 𝑥̇ is the translational velocity
𝜕ℒ
of the cart. The total kinetic energy of the pendulum obtained with ( ̇ ) = 𝑚𝑙𝑥̇ cos 𝜃 + 𝑚𝑙 2 𝜃̇ (19)
the movement of the pendulum in the vertical and the horizontal 𝜕𝜃
The cart and pendulum has a total kinetic energy as 2.2 DC Motor
𝑲𝒓
𝒄𝟐 = (38)
𝒓𝟏
from the Eq.36), the term 𝒍𝜽̈ and Eq.(25) into Eq.(36), the differ-
ential equation in a cart of the system can be derived as
𝟏
𝒙̈ = (𝒄𝟐 𝒗𝒂 − 𝒄𝟏 𝒙̇ − 𝒎𝒈𝜽) (39)
𝑴
Fig. 2: Equivalent Circuit of DC Motor Armature
Rearrange Eq.(25), the equation derived as
The equation for the DC motor armature circuit can be derived as
𝟏
𝒅𝒊𝒂 𝜽̈ = (𝒈𝜽 − 𝒙̈ ) (40)
𝒊𝒂 𝑹𝒂 + 𝑳𝒂 + 𝒗𝒃 = 𝒗𝒂 (26) 𝒍
𝒅𝒕
The next differential function in the pendulum of the system can
𝒗𝒃 , the generated emf (back electromotive force) is proportional to be derived from Eq.(39) and Eq.(40), as
the rotor rotational speed
𝟏 𝟏
𝒅𝜽𝟏 𝜽̈ = (𝒈𝜽 − (𝒄𝟐 𝒗𝒂 − 𝒄𝟏 𝒙̇ − 𝒎𝒈𝜽)) (41)
𝒗𝒃 = 𝑲𝒃 (27) 𝒍 𝑴
𝒅𝒕
𝒄𝟐 𝒄𝟏 (𝑴+𝒎)𝒈
𝒅𝜽 =− 𝒗𝒂 + 𝒙̇ + 𝜽 (42)
where 𝑲𝒃 is the constant of back emf and 𝝎𝟏 = 𝟏. The motor 𝑴𝒍 𝑴𝒍 𝑴𝒍
𝒅𝒕
torque 𝝉𝟏 with the armature current 𝒊𝒂 are proportional , hence Lastly, the function of the differential cart and pendulum move-
ment using Lagranges equation has been obtained, and the dynam-
𝝉𝟏 = 𝑲𝒕 𝒊𝒂 (28) ic actuators have been respected in the development of mathemat-
ical models.
where 𝑲𝒕 is the constant of motor torque. Eq.(27) and Eq.(28) (in
term of 𝒊𝒂 ) substituted into Eq.(26), then 2.3 State Space Representation
𝝉𝟏 𝒅𝟐 𝝉 𝟏 𝒅𝜽𝟏
𝑹𝒂 + 𝑳𝒂 + 𝑲𝒃 = 𝒗𝒂 (29) Figure.3 represents the system in state space model.
𝑲𝒕 𝒅𝒕𝟐 𝒅𝒕
The inductor 𝑳𝒂 can be ignored along with the small size of the
inductor in the rotor, and the function of DC motor armature cir-
cuit in term of 𝝉𝟏 becomes
𝑲𝒃 𝑲𝒕
𝝉𝟏 = −𝑲𝒕 𝝎𝟏 + 𝒗𝒂 (30)
𝑹𝒂 𝑹𝒂
3. State Feedback Control with Full-state Ob- where (𝑞1 , 𝑞2 , ⋯ 𝑞𝑗 ) are greater than 0. The Laplace transfer func-
tion of the closed-loop system in Figure.4 can be used to found the
server denominator.
3.1. State Feedback Control 𝐷(𝑠) = 𝑠𝑰 − (𝑨 − 𝑩𝑲) (52)
Figure.4 shows a diagram of the control system using state feed-
where identity matrix is 𝑰. Therefore, the stability and characteris-
back control. The feedback gain 𝑲 in state feedback control is
tics of the transient response of the closed-loop system can be
used to position the closed loop eigenvalues in desired locations.
determined with all eigenvalues of (𝑨 − 𝑩𝑲). The choosing of the
The main purpose of feedback control is to bring the output of the
feedback gain design is an effort to do, 𝑲 so that the eigenvalues
system 𝒚 to tracks the desired position even though there is inter-
of (𝑨 − 𝑩𝑲) have negative real parts. By solving the following
ference.
Equation of Riccati for a positive definite matrix 𝑷, the optimal
feedback gain 𝑲 can be obtained as
𝑨𝑻 𝑷 + 𝑷𝑨 − 𝑷𝑩𝑅−1 𝑩𝑇 𝑷 + 𝑸 = 0 (53)
The system dynamic equation using state feedback control is de- For a unit step reference input, the transfer function 𝑇(𝑠) of a
rived as follows closed-loop has dc gain 𝑁, 0 < 𝑁 < 1. The closed loop system
transfer function shown in Figure.4 is declared as
𝒙̇ = (𝑨 − 𝑩𝑲)𝒙 + 𝑩𝒖 (45)
𝑇(𝑠) = 𝑪(𝑠𝑰 − (𝑨 − 𝑩𝑲))−1 𝑩 (55)
𝒚 = 𝑪𝒙 (46)
where the dc gain 𝑁 can be derived by 𝑇(𝑠)|𝑠=0 . 𝑁̅ in the system
𝒖 = 𝒓 − 𝑲𝒙 (47) is added as shown in Figure.5 can be the settlement to repair the
̅ is calculated
performance of the steady state error. The pregain 𝑁
where 𝑲 ∈ 𝑹𝒋 . Therefore, the controllability and observability of as 𝑁̅ = 1.
𝑁
the system model checking are necessary to do before the control-
ler is implemented. The controllability(Eq.48)) of the system
means that for each initial state value, control efforts 𝒖 can direct
the state to each final state value in a limited time window if only
𝑪 is equal to the number of state variables. Observability (Eq.49))
of the system is a property of the plant without pay attention to the
selection of the actuator with suitable sensor selection. The rank of
matrix O must be same with the number of the state to test that the Fig. 5: Closed loop system with pregain
system is a system with observability.
The equation of state space can be derived as follow, where 𝑲 ∈
𝑪 = [𝑩|𝑨𝑩|𝑨𝟐 𝑩| ⋯ |𝑨𝒋−𝟏 𝑩] (48) 𝑹𝑗 .
̅ − 𝑲𝒙
𝒖 = 𝒓𝑵 (58)
Linear Quadratic Regulator Controller as shown in Figure.4 is a
method based on full state-feedback control. By minimising the
performance cost function, the control gain K can be obtained, it 3.3. Full-state Observer
described as
In systems with many states, it is impossible to know all infor-
∞ mation about the state. However, not all states can be sensed by
𝑱 = ∫𝟎 (𝒙𝑻 𝑸𝒙 + 𝒖𝟐 𝑹) 𝒅𝒕 (50)
sensors, and can be reversed. The system with state feedback re-
quires an ideal sensor that has an infinite bandwidth. In fact there
where 𝑹 is a scalar 𝑸 ∈ 𝑹𝒋×𝒋 is a real symmetric matrix which
are no ideal sensors and sensors also have limited bandwidth. The
must be chosen. 𝑹 and 𝑸 establish the relative concern of errors
actual observer concept is that if we do not have all the states, it is
and energy costs. Hence, the matrix 𝑹 and 𝑸 signifies a trade-off possible to estimate these states by using the system inputs and
both in control efforts and performance. If 𝑸 is smaller than 𝑹, outputs. This concept can be done if observability conditions are
control systems have become expensive since then 𝑱 especially the met. The concept of the full-state observer is as shown in Figure.6.
use of the control energy. If not, when 𝑸 is bigger than 𝑹, control
systems become cheap because small arbitrary control efforts can
be used to stabilize the system, but the system response will be
slow. It is a general training to let 𝑹 > 𝟎 and 𝑸 be a diagonal
matrix in the form of
𝑞1 0 ⋯ 0
0 𝑞2 ⋯ 0
𝑸=[⋮ ⋮ ⋱ 0] (51)
0 0 ⋯ 𝑞𝑗
International Journal of Engineering & Technology 207
move the unstable poles to the stable poles in the left side of the
complex plane such that the obtained control gain 𝑳 can satisfy the
designed criteria. The characteristic polynomial of the system can
be derived as Eq.(68). 𝒂𝒊 are the polynomial coefficients and 𝑰 is
an identity matrix. If the desired eigenvalues 𝝁𝟏 , ⋯ , 𝝁𝒏 are con-
sidered, the desired characteristic polynomial of the system be-
comes as Eq.(69). Then, the output feedback gain matrix that re-
quired 𝑳 can be calculated using Eq.(70).
|𝒔𝑰 − 𝑨| = 𝒔𝒏 + 𝒂𝟏 𝒔𝒏−𝟏 + ⋯ + 𝒂𝒏−𝟏 𝒔 + 𝒂𝒏 (68)
∏𝒏𝟏=𝟏(𝒔 − 𝝁𝒊 ) = 𝒔𝒏 + 𝜶𝟏 𝒔𝒏−𝟏 + ⋯ + 𝜶𝒏−𝟏 𝒔+𝜶𝒏 (69)
𝑳 = [𝜶𝒏 − 𝒂𝒏 |𝜶𝒏−𝟏 − 𝒂𝒏−𝟏 | ⋯ |𝜶𝟐 − 𝒂𝟐 |𝜶𝟏 − 𝒂𝟏 ]𝑻−𝟏 (70)
where 𝑻 is the transformation matrix that changes the state equa-
tion of the system into the controllable canonical form. The trans-
formation matrix 𝑻 can be calculated by
𝑻 = 𝑪𝑾 (71)
Fig. 6: Closed loop system with full-state observer
Where
For the systems as in Eq.(43) and Eq.(44), with the state estima-
tion of 𝒙 defined as follow 𝒂𝒏−𝟏 𝒂𝒏−𝟐 ⋯ 𝒂𝟏 𝟏
𝒂𝒏−𝟐 𝒂𝒏−𝟑 ⋯ 𝟏 𝟎
̂̇ = 𝑨𝒙
𝒙 ̂ + 𝑩𝒖 + 𝑳(𝒚 − 𝒚
̂) (59) 𝑾= ⋮ ⋮ ⋮ ⋮ ⋮ (72)
𝒂𝟏 𝟏 ⋯ 𝟎 𝟎
̂ = 𝑪𝒙
𝒚 ̂ (60) [ 𝟏 𝟎 ⋯ 𝟎 𝟎]
The value of 𝒚 ̃ = 𝒚−𝒚 ̂ is attempted to be as small as possible,
which indicates that the estimator works well. To make 𝒙 ̂ as close
4. Simulation and Result
as possible 𝒙, state error estimator is defined.
Before doing a simulation, the parameters of the system defined in
̃=𝒙−̂
𝒙 𝒙 (61) Table 1 are used. The open loop system has the eigenvalues that
shown in Figure.3 are (0, 5.3622, -5.4316, -0.3696) which can be
̂̇
̃̇ = 𝒙̇ − 𝒙
𝒙 (62) obtained by det(𝒔𝑰 − 𝑨). That eigenvalue is shown in pole-zero
mapping in Figure.7.
̃̇ = (𝑨𝒙 + 𝑩𝒖) − (𝑨𝒙
𝒙 ̂ 𝒙))
̂ + 𝑩𝒖 + 𝑳(𝑪𝒙 − 𝑪 (63)
̃̇ = 𝑨(𝒙 − ̂
𝒙 𝒙) − 𝑳𝑪(𝒙 − ̂
𝒙) (64)
̃̇ = (𝑨 − 𝑳𝑪)𝒙
𝒙 ̃ (65)
In the design of the controller, the pole location of the system on Table.1: The cart inverted pendulum parameters
the complex plane can verify the system stability . The system is No Parameter Value Units
unstable if it has a pole on the right side of the complex plane. In 1 M 1.04 Kg
other words, the system is said to be stable when all the poles are 2 Ra 1 Ω
on the left side of the complex plane[11]. Therefore, a system that 3 l 0.4 m
has a pole in the right side of the complex plane requires a control 4 Kt 0.01 N.m/A
method that can carry the pole that located in the right side of the 5 r1 0.1 M
complex plane to the left side of the complex plane. As with the 6 Kb 0.407 V.s/rad
previous LQR method, controllability and observability of the 7 m 0.19 Kg
system must be fulfilled. The suitable gain matrix can be selected
𝟎 𝟎. 𝟐𝟎𝟎 −𝟎. 𝟎𝟎𝟖 𝟎. 𝟕𝟖𝟓
for the state feedback as shown in Figure.4, to have closed-loop 𝟎 −𝟎. 𝟖𝟎𝟎 𝟎. 𝟎𝟑𝟐 −𝟑𝟒. 𝟓𝟑𝟑
poles at the desired locations, it is possible to force the system, 𝑪=[ ]
𝟎. 𝟐𝟎𝟎 −𝟎. 𝟎𝟎𝟖 𝟎. 𝟕𝟖𝟓 −𝟎. 𝟎𝟔𝟑
provided that the original system completely states controllable. −𝟎. 𝟖𝟎𝟎 𝟎. 𝟎𝟑𝟐 −𝟑𝟒. 𝟓𝟑𝟑 𝟏. 𝟓𝟎𝟕
All the variables of state must be available and measurable in pole
placement control method. The pole placement method is used to
208 International Journal of Engineering & Technology
𝟏 𝟎 𝟎 𝟎
𝟎 𝟏 𝟎 𝟎
𝟎 𝟎 𝟏 𝟎
𝟎 𝟎 𝟎 𝟏
𝑶=
𝟎 −𝟎. 𝟗𝟖𝟏 −𝟎. 𝟎𝟒𝟎 𝟎
𝟎 𝟒𝟑. 𝟏𝟔𝟒 𝟎. 𝟏𝟔𝟎 𝟎
𝟎 𝟎. 𝟎𝟑𝟗 𝟎. 𝟎𝟎𝟐 −𝟎. 𝟗𝟖𝟏
[𝟎 −𝟎. 𝟏𝟓𝟕 −𝟎. 𝟎𝟎𝟔 𝟒𝟑. 𝟏𝟔𝟒 ]
5. Conclusion
State feedback control with a full-state estimator for a cart invert-
ed pendulum system has been successfully conducted. The gain
state feedback 𝑲 has been obtained using Linear Quadratic Regu-
lator. The gain of full-state observer 𝑳 also been obtained using
pole placement control method. The simulation result shows that
the cart inverted pendulum system can reach the desired position
Fig. 9: Pendulum Angle Response and angle with the optimal responses. The simulation also shows
that the system using state feedback control and state feedback
The cart position response shows that the cart can't reach the de- control with full state observer have similar responses. Its because
sired position, otherwise, the pendulum can reach the equilibrium. the initial state and the observer state have same state variables in
The bigger 𝒒𝒊 that is given to the system, the responses become mathematical modeling. The implementation can be done to know
faster. Because the response of the cart that shown in Figure.8 the response of the cart inverted pendulum system on a real im-
̅ added to the system for
can't reach the desired position, pregain 𝑵 plementation.
a better performance. Figure.10 and Figure.11 shows the response
of the cart position and angle pendulum respectively. It can be
seen that both of the cart and pendulum can reach the desired posi-
Acknowledgment
tion.
The authors would like to thank Kemenristekdikti and State Poly-
technic of Malang for their support.
References
[1] I. Siradjuddin, Z. Amalia, B. Setiawan, F. Ronilaya, E. Rohadi, A.
Setiawan, S. Adhisuwignjo, ”Stabilising a cart inverted pendulum
with an augmented PID control scheme,” In MATEC Web of Con-
ferences, EDP Sciences, 2018, Vol. 197, p. 11013.
[2] I. Siradjuddin, B. Setiawan, A. Fahmi, Z. Amalia, E. Rohadi, ”State
space control using LQR method for a cart-inverted pendulum line-
arised model,” International Journal of Mechanical & Mechatronics
Fig. 10: Cart Position Response
Engineering IJMME-IJENS, 2017, Vol:17, No:01
[3] I. Siradjuddin, Z. Amalia, B. Setiawan, R. P. Wicaksono and E.
Yudaningtyas, ”Stabilising a cart inverted pendulum system using
pole placement control method,” 2017 15th International Confer-
ence on Quality in Research (QiR) : International Symposium on
Electrical and Computer Engineering, Nusa Dua, 2017, pp. 197-
203.
[4] Zhenkai Guo, Jianqin Mao and Ping Wang, ”An Approach of
Adaptive Fuzzy Modeling and Application to Inverted Pendulum
International Journal of Engineering & Technology 209