You are on page 1of 5

Modeling and Simulation of the Inverted Pendulum Control System

Nahid Hasan1, LI Ling 1, YUAN De-Cheng 1, JING Yuan-Wei2


1. Department of Information Engineering, Shenyang University of Chemical Technology, Shenyang 110142, China
E-mail: uiu022071002@yahoo.com ,lengleng0604@163.com, yuandecheng@sohu.com
2. College of Information Science & Engineering, Northeastern University, Shenyang 110004, China
E-mail: ywjjing@163.com

Abstract: The inverted pendulum is a common, interesting control problem that involves many basic elements of control theory. This
paper deals with modeling and simulation of the inverted pendulum. This system is unstable and highly nonlinear with one input –
voltage of a DC motor which can change position of the cart and two outputs – cart position and angle of the pendulum rod. First, a
mathematical model of the inverted pendulum is derived, followed by stabilization of three basic control methods (Root locus, Frequency
response, PID). Then, the created mathematical model is implemented into the MATLAB/Simulink environment and its properties are
reflected by simulation results.
Key Words: Inverted Pendulum (IP), Transfer function (TF), Root locus, Frequency response, PID

system and linearize about the pendulum's angle, ߠ ൌ ߨ ,


1 INTRODUCTION assume that pendulum does not move more than a few
There are a lot of processes in industry that possess instable degrees away from the vertical, chosen to be at an angle of
behavior, such as various types of reactors, distillation ߠ.
columns, etc. Real-time experiments with these systems For this system we will assume that the system starts at
without proper control can be a real hazard. In such cases, steadiness and skills an impulse force of 1N. The pendulum
process modeling and simulation are often the only safe never move more than 0.05 (rad) away from the vertical and
tools to investigate properties of such systems. Nowadays, must return to its upright location within 5 (sec).
the role of modeling and simulation has risen mainly due to
[1-3]
the increasing performance of computer technology .
The Inverted pendulum (IP) has been a good example in the
field of control engineering. In general it is used to
determine a modern control theory and technology and
stabilizing a pendulum at the upright unstable position has
become an interesting object for physicists and engineers.
The paper is organized as follows: after the introduction a
description of the system, models of the mathematical
Fig 1. Free body diagram of dynamic cart system of IP
equation governing the system are deduced for the
operational range, like the non-linear, linearized equation, Table1. Free Body Diagram of Pendulum Cart System
transfer function. Next, three basic control methods (Root
Mass of the cart ݉଴ 0.618 kg
locus, Frequency response, PID) are used. Further, the
results of computer simulation are analyzed. mass of the pendulum, ݉ଵ 0.0737kg

1.1 Dynamic Analysis of IP length to pendulum center of mass,l 0.1225m


The length of the pendulum, L 0.350m
The system contains of a metal guiding bar along a cart
which can be relocate. A cylindrical rod weight is fixed to External force applied to the cart, F
the cart through an axis. Using a Newtonian methodology, Cart position coordinate, x
expressions can be imitative connecting pendulum and cart pendulum angle from vertical, ߠ
motion. With the cart under position control deliberate cart
position, velocity, and acceleration all as input factors
which we can advocate. Figure 1 shows a free body Conversely, expending state-space method we are capable
dynamic diagram of IP. In Table 1 we prescribe the certain to deal with a multi-output system. Consequently, IP
value for this specific system. Using Cartesian coordinates, system will attempt to control both the pendulum's angle
the motion and forces on the pendulum can be described. and the cart's position [4-5].
Figure 1 the cart with an IP is "bounced" with an impulse 1.2 Mathematical Modeling of IP
force, F. Regulate the dynamic equations of motion for the
According to the Newton’s Law applied on Dynamic
model, applied horizontal force count on pendulum and
This work is supported by National Nature Science Foundation under cart-
Grant 60874057

978-1-4799-7016-2/15/$31.00 2015
c IEEE 548
ሺ݉଴ ൅ ݉ଵ ሻ‫ݔ‬ሷ െ ݉ଵ ݈ߠሷ …‘• ߠ ൌ ݂଴ ‫ݔ‬ሶ െ ݉ଵ ݈ߠሶ ଶ •‹ ߠ ൅ ‫ܨ‬ (1)
Pendulum balancing port ‡“—୬ -
ሷ ݉ଵ ݈݃ •‹ ߠ െ ݂ଵ ߠሶ ൅ ݉ଵ ‫ݔ‬ሷ ݈ …‘• ߠ
ሺ‫ ܬ‬൅ ݉ଵ ݈ ଶ ሻߠ ൌ (2) Consuming maximum overshoot

୬ M p = e − (ζ 1−ζ 2 )π
≤ 10% ˈ (13)
By (1) & (2) yields ‡“— -
ܽ ‫ݔ‬ሷ െ ܽଵ ߠሷ …‘• ߠ ൌ െܽଵ ߠሶ ଶ •‹ ߠ െ ݂଴ ‫ݔ‬ሶ ൅ ‫ݑ‬ We get ζ ≥ 0.5912 ൎ ζ = 0.6ˈ (14)
ቊ ଴ (3)
െܽଵ ‫ݔ‬ሷ …‘• ߠ ൅ ܾଵ ߠሷ ൌ െ݂ଵ ߠሶ ൅ ܽଵ ݃ •‹ ߠ ‫ ׵‬ζ = cos θ , we get θ = 0.9273rad (15)
4
[Here,ܽ଴ ൌ ݉ଵ ൅ ݉଴ Ǣܽଵ ൌ ݉ଵ ݈Ǣܾଵ ൌ ‫ ܬ‬൅ ݉ଵ ݈ ଶ ܽ and Also Consuming ts = ≤ 0.5s (16)
u=F] ζωn
We know, IP rod rotation angle is not too much large, i.e. We get ω n ≥ 1 3 .3 3 3 3 ൎ ω n = 1 3 .5 (17)
ߠ ‫ͳ ا‬ሺ‫݀ܽݎ‬ሻ.

After linearization Improved Transfer Function of the system-


K ( s + 7) 6.122 (18)
ܽ଴ ‫ ݏ‬ଶ ܺሺ‫ݏ‬ሻ െ ܽଵ ‫ ݏ‬ଶ Ĭሺ‫ݏ‬ሻ ൌ െ݂଴ ‫ܺݏ‬ሺ‫ݏ‬ሻ ൅ ܷሺ‫ݏ‬ሻ Q = KG c ( s )G ( s ) =
൜ (4) s + 24 s 2 − 60.06
െܽଵ ‫ ݏ‬ଶ ܺሺ‫ݏ‬ሻ ൅ ܾଵ ‫ ݏ‬ଶ Ĭሺ•ሻ ൌ െ݂ଵ ‫ݏ‬Ĭሺ‫ݏ‬ሻ ൅ ܽଵ ݃Ĭሺ‫ݏ‬ሻ
[Here, consuming mapping rules, get zero and pole ahead
Transfer Function of pendulum angle-
Ĭሺ‫ݏ‬ሻ of improvement respectively, zc = −7, z p = −24 ]
ܷሺ‫ݏ‬ሻ
െܽଵ ‫ ݏ‬ଶ

ሺെܽଵ െ ܽ଴ ܾଵ ሻ‫ ݏ‬ସ െ ሺܽ଴ ݂ଵ െ ܾଵ ݂଴ ሻ‫ ݏ‬ଷ ൅ ሺെܽ଴ ܽଵ െ ݂଴ ݂ଵ ሻ‫ ݏ‬ଶ െ ܽଵ ݂଴ ݃‫ݏ‬
The magnitude of the circumstance Q(sd ) = 1 , so feedback
(5) as a unit feedback, so we get k = 52.71 DŽ
To linearize ‡“—୬ (2) we get- ‫ ׵‬System controller is-
‫ߠܬ‬ሶ ൅ ݉ଵ ݈ ଶ ߠሷ ൌ ݉ଵ ݈݃ߠ െ ݂ଵ ߠ ൅
ሶ ݉ଵ ‫ݔ‬ሷ (6) 52.71(s + 7)
G(s) = (19)
According to dynamic model, for actual control motion s + 24

acceleration, put ‫ ܬ‬ൌ ݈݉ ଶ in ‡“—୬ (6)-
ଷ 40
Root Locus
ଷ௚ ଷ௙భ ଷ
ߠሷ ൌ ߠ െ ሶ
మߠ ൅ ‫ݔ‬ሷ (7)
ସ௟ ௠భ ௟ ସ௟ 30
In general, let f1=0.
Now, we get our required Transfer Function - 20

Ĭሺ௦ሻ ଷΤସ௟ ଺Ǥଵଶଶ


ൌ మ య೒ ൌ మ (8) 10
஺ሺ௦ሻ ௦ ି ௦ ି଺଴
Imaginary Axis

ర೗
It have two root,ߣ ൌ േ͹Ǥ͹Ͷ͸ 0

-10

2 THREE CONTROL METHODS -20

2.1 Root Locus Method -30

The design necessities for IP system consuming Root Locus


-40
method are: -25 -20 -15 -10 -5 0 5 10
Real Axis

• Adjustment time t s = 0 .5 s ˗ (9) Fig 3. The system Root locus figure after adjustment
• Maximum overshoot M p ≤ 10% (10) 2.2 Frequency Control Method
Block diagram of the controller scheme of Root Locus If two TF are different in equivalent numerator i.e.
method- (݀݁݊ଵ ൌ ݀݁݊ଶ ). So the streamlined TF-

మ ሺ୬୳୫ ሻሺୢୣ୬ୡ୭୬୲୰୭୪୪ୣ୰ሻ
ሺ•ሻ ൌ ሺୢୣ୬ୡ୭୬୲୰୭୪୪ୣ୰ሻሺୢୣ୬ሻା୏ሺ୬୳୫ୡ୭୬୲୰୭୪୪ୣ୰ሻሺ୬୳୫ (20)
భሻ


௦ା

Controller Scheme, ‫ܩ‬௖ ሺ‫ݏ‬ሻ ൌ ‫ܭ‬௖ భ (21)
௦ା
Fig 2. Dynamic control block diagram for Root locus control method of IP ഀ೅
system. In system has OLTF ‫ܩ‬௖ ሺ‫ݏ‬ሻ‫ܩ‬ሺ‫ݏ‬ሻ-
ୋమ ሺୱሻ ௡௨௠మ Τௗ௘௡మ ଺Ǥଵଶଶ‫כ‬௄
ሺ•ሻ ൌ ሺୱሻ
ଵା୏ୈሺୱሻୋభ
ൌ ೖሺ೙ೠ೘೗೐ೌ೏ሻሺ೙ೠ೘೗ೌ೒ሻሺ೙ೠ೘భሻ
‫ܨ‬ሺ‫ݏ‬ሻ
ଵା ሺ೏೐೙೗೐ೌ೏ሻሺ೏೐೙೗ೌ೒ሻሺ೏೐೙ ሻ
(11) ‫ܩ‬ଵ ሺ‫ݏ‬ሻ ൌ ‫ܩܭ‬ሺ‫ݏ‬ሻ ൌ మ (22)

௦ ି଺଴
To evaluate the gain,
Ǩ
If pole/zero at the foundation point i.e. (݀݁݊ଵ ൌ ݀݁݊ଶ ) was ௦ା ଺Ǥଵଶଶ

‫ ܭ‬ൌ Ž‹௦՜଴ ‫ܭ‬஼ భ ൈ ൌ ͳͲ (23)
cancelled. So the streamlined TF- ௦ା ௦ మ ି଺଴
ഀ೅

మ ሺ୬୳୫ ሻሺୢୣ୬୪ୣୟୢሻሺௗ௘௡୪ୟ୥ሻ ଽ଼ൈ଺Ǥଵଶଶ


ሺ•ሻ ൌ ሺୢୣ୬୪ୣୟୢሻሺௗ௘௡୪ୟ୥ሻሺୢୣ୬ሻା୏ሺ௡௨௠௟௘௔ௗሻሺ௡௨௠௟௔௚ሻሺ୬୳୫ (12) ‫ܩ ׵‬ଵ ሺ‫ݏ‬ሻ ൌ ; [Here, k=‫ܭ‬௖ ߙ ൌ ͻͺ] (24)
భሻ ௦ మ ି଺଴

2015 27th Chinese Control and Decision Conference (CCDC) 549


Now, consuming matlab command appeal Bode and 2.3 PID method
Nyquist plot to increse gain.
In this PID method of IP system pendulum angle is output
Bode Diagram
where equilibrium position is upright. System dynamic
Magnitude (dB) 50
control block diagram is shown in Figure 7. In the figure 7.
0 KD (s) is the controller TF, G (s) is the TF of the controlled
-50
-179
object.
Phase (deg)

-180

-181
0 1 2
10 10 10
Frequency (rad/sec)

-8
x 10 Nyquist Diagram
1
20
-2
2-10
-4
10
-6
-20
dB
6dB
4dB
0
dB
dB
dB
dB
dB
0.5
Imaginary Axis

0 Fig 7. PID control system structure chart



-0.5 [Here, ‫ܦܭ‬ሺ‫ݏ‬ሻ ൌ ‫ܭ‬஽ ‫ ݏ‬൅ ‫ܭ‬௉ ൅ ೗ ] to obtain satisfactory

-1
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 control results, essentially PID controller factors need to be
Real Axis
adjusted.
Fig 4. IP Bode and Nyquist plot after adding gain
From Bode and Nyquist plot we got-
ߙൌ
ଵିୱ୧୬ ‫׎‬೘
=0.0994; ‫׎‬௠ ൌ ͷͷ° and (25)
3 SIMULATION ANALYSIS
ଵାୱ୧୬ ‫׎‬೘
߱ ൌ ߱௖ ൌ ͳΤξߙܶ ൌ ͶʹǤͻ͵ (26) 3.1 Root Locus Method
[Here,߱௖ ൌ …”‘••‘˜‡”ˆ”‡“—‡‡…›] A controller for the inverted pendulum system will be
ଵ ଵ ఠ
ൌ ξߙ߱௖ ൌ ͳ͵Ǥͷ͵ͷ and ൌ ೎ =136.166 (27) designed by using the root locus method. In the design
் ξఈ் ξఈ
So the static error quantity adjustment is- process a single-input, single-output plant will be assumed.
௦ାଵଷǤହଷହ ௌାଶ That is, we will attempt to control the pendulum's angle
‫ܩ‬௖ ሺ‫ݏ‬ሻ ൌ ͻͺͲ ൈ ൈ (28) without regard for the cart's position. Simulink diagram for
௦ାଵଷ଺Ǥଵ଺଺ ௦ା଴Ǥଵଽ଼଼
Bode diagram and Nyquist plot after increasing adjustment Root Locus method of IP system is shown in Fig 8.Step
in the system response curve is gained in Fig 9. This simulation result has
shown that the IP system dynamic performance is good.
Bode Diagram
Phase (deg)Magnitude (dB)

100

-100
-90

-135

-180
-1 0 1 2 3 4
10 10 10 10 10 10
Frequency (rad/sec)

Nyquist Diagram
Fig 8. Simulink diagram for Root Locus method of IP system.
0.5
10 dB 6 dB 4 dB 2 dB 0 dB -2 dB -4 dB
-6 dB
-10 dB
Imaginary Axis

20 dB -20 dB
0

-0.5
-1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0
Real Axis

Fig 5. IP Bode and Nyquist plot after adjustment

Impulse Response
10

6
Figure 9. Simulation results for root locus after correction.
Amplitude

4
To attempt this paper more challenging first we add an extra
positive step signal as a positive noise in root locus method
2
and we observe the output of the system after controller.
Simulink diagram for Root Locus method of IP system with
0
noise is shown in Fig 10. Noise curve and step response
curve is gained in Fig 11. This simulation result has shown
-2
0 0.5 1 1.5 2 2.5 3 that the IP system dynamic performance is good even
Time (sec)
though we add an extra positive step signal as a noise after
Fig 6. IP Impulse Response plot after adjustment controller.

550 2015 27th Chinese Control and Decision Conference (CCDC)


Figure 10. Simulink diagram for Root Locus method of IP system adding
an extra (noise) step signal.

Fig 15. Simulation result for Frequency response method after correction.

At this instant, Simulink diagram for Frequency Response


method of IP system is shown in Fig 16. Step response
Figure 11. Simulation results for root locus after correction with extra curve gain and noise signal in Fig 17. Here, we add an extra
input (noise). positive step signal as a noise. This simulation result has
shown that the IP system stability is good and the steady
Supplementary, now we add an alternatively extra negative
state error is very small even though we add a negative step
step signal as a noise in root locus method and we observe
signal as a noise but we did not find any small amount of
the output of the system after controller. Simulink diagram
change, that’s mean output step response gain is remain
for Root Locus method of IP system with noise is shown in
same.
Fig 12. Noise curve and step response curve is gained in Fig
13. This simulation result has shown that the IP system
dynamic performance is stable on a negative stage when we
add an extra negative step signal as a noise after controller.

Fig 16. Simulink diagram for Frequency Response method adding a step
signal as a noise of IP system.
Figure 12. Simulink diagram for Root Locus method of IP system with a
negative step noise signal before controller.

Figure 13. Simulation results for root locus with subtract a step noise
signal as a feedback signal before controller after correction.
Fig 17. Simulation result for Frequency response method adding a step
signal as a noise after correction.
3.2 Frequency response
A controller for the inverted pendulum system will be 3.3 PID
designed by using Frequency Response method. Simulink A controller for the inverted pendulum system will be
diagram for Frequency Response method of IP system is designed by using PID method. Simulink diagram for PID
shown in Fig 14.Step response curve is gained in Fig method of IP system is shown in Fig 18. Step response
15.This simulation result has shown that the IP system curve is gained in Fig 19 and Fig 20.Because we will
stability is good and the steady state error is very small. attempt to control the pendulum's angle without regard for
the cart's position, the cart's position curve is unstable in Fig
19 and the pendulum's angle curve is stable in Fig 20.

Fig 14. Simulink diagram for Frequency Response method of IP system.

2015 27th Chinese Control and Decision Conference (CCDC) 551


Fig 18. Simulink diagram for PID method of IP system.

Fig 21. Simulink diagram for PID method of IP system after adding a step
signal as a noise.

Figure 22. Simulation result of PID controller output graphs car position
and increase integral control parameters PID controller after adding a step
signal as a noise.
Figure 19. Simulation result of PID controller output graphs car position
4 CONCLUSION

The intention of this paper was modeling and simulation of


the IP. This paper designed three kinds of controllers for an
inverted pendulum system and successfully balanced it in
computer simulations. The simulation results showed these
controllers are of good steady-state characteristics and
dynamic performances. From the design process it was
discovered that the traditional control methods, such as
Root locus, Frequency response, PID, are much better in
the control of a single input and a single output (SISO)
system. It was discovered that the artificial intelligence
Figure 20.Increase integral control parameters PID controller simulation
result. controller method, e.g. the Fuzzy logic controller is known
as all that work in a nonlinear systems while the PID is
Simulink diagram for PID method of IP system with known as a conventional controller which needs the system
positive step signal as a noise is shown in Fig 21. Step to be linearized. Further work these controller methods and
response curve with noise curve is shown in Fig 22. algorithms should be implemented into hardware for more
Because we will attempt to control the pendulum's angle analysis and comparative results and better performances.
without regard for the cart's position, the cart's position The proposed approaches will have great advantage in the
curve is unstable and angle curve is stable in Fig 20 even future for the stabilization of complex systemˊ
though we add a noise. At this instant, even though we add
a negative step signal as a noise but we did not find any
REFERENCES
changes at the output response, so that we can say output
step response gain is remain same. [1] JiĜí Marholt, František Gazdoš, Modeling, identification and
simulation of the inverted pendulum PS600, Acta
Montanistica Slovaca Roþník Vol.15, No.1, 14-18, 2010.
[2] Franklin, Gene F., Powell, David J. and Emami-Maeini,
Feedback Control of Dynamic Systems, Addison-Wesley,
New York, 1994.
[3] Astrom K.J., Fnrnta K. Swinging up a pendulum by energy
control, Automatic, Vol.36, No.2, 287-295, 2000.
[4] Yavin Y, Control of a Rotary Inverted Pendulum, Applied
Mathematics Letters, Vol.25, No.12, 131-134, 1999.
[5] Ken Maeda, Nonlinear control system of inverted pendulum
based on input-output linearization, Yokohama: Yokohama
National University, 2003.

552 2015 27th Chinese Control and Decision Conference (CCDC)

You might also like