0% found this document useful (0 votes)
65 views9 pages

Fuzzy Control of A Real Time Inverted Pendulum System

Uploaded by

Fajar Kavaleri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views9 pages

Fuzzy Control of A Real Time Inverted Pendulum System

Uploaded by

Fajar Kavaleri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/228633624

Fuzzy Control of a Real Time Inverted Pendulum System

Conference Paper  in  Journal of Intelligent and Fuzzy Systems · January 2010


DOI: 10.1007/978-3-540-85563-7_85 · Source: DBLP

CITATIONS READS

10 1,325

3 authors, including:

selçuk Kizir Z. Bingul


Kocaeli University Kocaeli University
12 PUBLICATIONS   82 CITATIONS    76 PUBLICATIONS   1,216 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

welding control View project

Advanced Robotics Analysis Toolbox (ARAT) View project

All content following this page was uploaded by selçuk Kizir on 09 April 2014.

The user has requested enhancement of the downloaded file.


Fuzzy Control of a Real Time Inverted
Pendulum System

Selcuk Kizir, Zafer Bingul, and Cuneyt Oysu

Kocaeli University, Department of Mechatronics Engineering,


41380, Kocaeli, Turkey
{selcuk.kizir,zaferb,coysu}@kocaeli.edu.tr

Abstract. In this study, a real-time control of the cart-pole inverted pendulum


system was developed using fuzzy logic controller. Swing-up and stabilization
of the inverted pendulum were implemented directly in fuzzy logic controller.
The fuzzy logic controller designed in the Matlab-Simulink environment was
embedded in a dSPACE DS1103 DSP controller board. Swing-up algorithm
brings the pendulum near to its inverted position in 10 seconds from downward
position. In order to test the robustness of the fuzzy logic controller internal
(changing model parameters) and external disturbances (applying external
forces) were applied on the inverted pendulum. The inverted pendulum system
was shown to be robust to the external and internal disturbances. The maximum
errors of the pendulum angle to the impulse input were between 1.89˚ and
4.6449˚ in the robustness tests.

Keywords: Inverted pendulum, swing up, stabilization, fuzzy logic.

1 Introduction
Inverted pendulum is very common and interesting nonlinear system in the control
applications. Nonlinear, unstable inverted pendulum system is used to test perform-
ance of the different control algorithms. Inverted pendulum problem is a very useful
system to utilize in the control education due to simplicity of establishing the system.
It is therefore very widely used laboratory tool in the control laboratories.
Fuzzy set theory is employed to model the amount of ambiguity or uncertainty sub-
ject to parameter inaccuracy and unmodeled dynamics. It offers a very attractive way
to extract information from data for designing a controller. Comparison of classical
set theory with fuzzy set theory helps one to understand the basic differences between
them. The main difference is that with fuzzy set theory a set membership is repre-
sented as a possibility distribution, while the classical set theory defines sets with a
clear-cut decision that a feature either belongs to a set or not [1].
In the literature, different inverted pendulum systems and their control methods
have been studied. The inverted pendulum systems can be grouped structurally as
cart-pole single pendulum systems [2-4], cart-pole double pendulum systems [5],
rotary single and double pendulum systems [6-7]. The control methods applied to
inverted pendulum systems can be summarized to linear methods such as PID, state

I. Lovrek, R.J. Howlett, and L.C. Jain (Eds.): KES 2008, Part I, LNAI 5177, pp. 674–681, 2008.
© Springer-Verlag Berlin Heidelberg 2008
Fuzzy Control of a Real Time Inverted Pendulum System 675

feedback [2,4,6,8,9] and nonlinear methods such as energy based, fuzzy logic,
feedback linearization and etc. [2,3,5,6,10-14]. Muskinja and Tovornik [3] proposed
energy based and fuzzy logic controllers for swing-up of inverted pendulum. Adap-
tive state controller is also suggested for the stabilization of inverted pendulum. Ji, Lei
and Kin [12] presented simulation results of inverted pendulum using fuzzy logic
controller for swing-up and stabilization routines.

2 The Structure of the Inverted Pendulum


In the cart-pole single inverted pendulum system, pendulum is attached to the cart
which can move in the limited horizontal track. The rod is attached to an optical en-
coder, so it can rotate very small friction. Inverted pendulum system has two equilib-
rium points: downward and upright positions. Stable downward equilibrium point
corresponds to θ = 0, θ = 0 . Unstable upright equilibrium point corresponds to
θ = π , θ = 0 .
The inverted pendulum developed here consists of several parts such as servo mo-
tor providing movement of the cart and applying the desired force to the pendulum,
the sensors measuring the state variables (cart position x and pendulum angle θ ) and
the controller supplying control signals. These parts are shown in Fig. 1. The control
algorithm is embedded in dSPACE DS1103 DSP controller board. This board takes
the sensor outputs and supply control signal. Photography of the inverted pendulum
system developed here is shown in Fig. 1.

+
Controller Sensors
Input -
Servo
Driver Motor
Measurement
dSPACE & Filtering
& Simulink

Fig. 1. Block diagram and setup of the inverted pendulum system

3 Controller Design
Generally, hybrid control approach is used in the control of inverted pendulum sys-
tems. The hybrid approach is implemented in two steps: swing-up and stabilization
routines. The intention of swing-up routine is to bring up the pendulum from down-
ward position to upright position. In stabilization routine, the pendulum is balanced
in a limited track. In hybrid approach, the controller decides which routines switch on
based on pendulum angle. However, the fuzzy logic control can handle both routines
in rules base. Swing-up and stabilization routines are explained below.
676 S. Kizir, Z. Bingul, and C. Oysu

3.1 Swing-Up Routine

In this study, a cart motion strategy was determined to swing up the pendulum based
on work effect of a given acceleration [3]. The basic strategy is to move the cart in
such a motion that energy is gradually pumped to the pendulum. How to add the best
energy to the pendulum should be explored and the strategy should be determined
based on the analysis. The pendulum model based on Newtonian approach is shown
in Fig. 2-a. Throughout this analysis, bold characters are used to denote vector quanti-
ties, while non-bold characters represent scalar quantities.
The forces act on the pendulum is,

Fr = Fr (sin θ ˆi + cos θ ˆj)


. (1)
F g = −mg ˆj

Using Newton’s law Fr is found,

Fr = m(sin θ x + lθ 2 + g cos θ ) . (2)

Using Fr the work is found,

δW = Fr • ∂x = Fr sin θ ∂x = m(sin 2 θ x + sin θ lθ 2 + g sin θ cos θ )∂x . (3)

The term sin 2 θ x in Equation 3 is important, because it describes the work effect
of a given acceleration at any angle. This term is shown in Fig. 2-b. For θ close to
±90°, a given acceleration and displacement does maximum work. For θ close to 0°,
hardly any work is done. The work is positive when the acceleration and displacement
are in the same direction. In this case, the energy is added to the system.

1
x

Fr 0.8
ĵ M
Sin2(Theta)

iˆ 0.6

0.4
l
0.2
m
θ Fg 0
-200 -150 -100 -50 0 50 100 150 200

(a) (b)
Fig. 2. (a) Coordinate system and free body diagram of the system. (b) Work effect of the
system.

Considering the work effect of the system, the strategy for a cart trajectory that is
driven by pendulum angle is developed. To maximize the positive work done on the
pendulum, the cart must be accelerated when θ near ±90° to achieve high work trans-
fer and decelerated when θ near 0° since there is low work transfer. Acceleration and
deceleration regions are shown in Fig. 3. The cart must be accelerated when the pen-
dulum is in region I, cart must be decelerated in region II and it must be waited while
pendulum reaches its maximum point in region III. This process is repeated until
pendulum reaches its inverted position. Because the pendulum begins at rest, hanging
Fuzzy Control of a Real Time Inverted Pendulum System 677

I I

III III

II II

Fig. 3. Swing-up strategy

downward position in region II, this strategy does not produce an output, so swing-up
controller should include a series of quick cart movements that begin the pendulum
swinging. Finally, to bring the pendulum close to its inverted position and in low
angular velocity, cart movement amplitude should be gradually reduced when the
pendulum swings higher.
The rules mentioned above are very suitable to design a fuzzy controller. In the
proposed fuzzy swing-up controller, two input variables are used: pendulum angle θ
and pendulum angular velocity θ . The system has a limited track length but it is
enough to apply this control strategy. Seven fuzzy subsets [NLS (Negative large),
NBS (Negative big), SALN (Start swing negative), Z (Zero), SALP (Start swing posi-
tive), PBS (Positive big) and PLS (Positive large)] are used for the error of pendulum
angle. Three fuzzy subsets are chosen for the error of pendulum angular velocity. The
input membership functions are shown in Fig. 4, the rule base is given in Table 1 and
the output membership functions are shown in Fig. 6. The output membership func-
tions has nine fuzzy sets [NVVB (Negative very very big), NVB (Negative very big),
NB (Negative big), N (Negative), Z (Zero), P (Positive), PB (Positive big), PVB
(Positive very big), PVVB (Positive very very big)].
Response of the swing-up controller used here is shown in Fig. 5. Pendulum is
swung-up from downward position to inverted position in about 10 seconds. The
number of fluctuations and swing-up time can be reduced or increased by changing
amplitude of the output membership functions.
SALN

SALP
NBS
NLS

PBS

PLS

NEG ZS POS
Z

230

270

330
130

150
170
180
190
210
90
30

-10 -1 -0.1 0 +0.1 +1 +10

Fig. 4. Membership functions for θ and θ

Table 1. Fuzzy rule base for swing-up


eθ NLS NBS SALN Z SALP PBS PLS
NEG P Z PB
ZS P
POS NB Z N
678 S. Kizir, Z. Bingul, and C. Oysu

400

Pendulum Angle
200

0
0 2 4 6 8 10 12

10

Angular Velocity
0

-10
0 2 4 6 8 10 12

2
Output

-2
0 2 4 6 8 10 12
Time (Second)

Fig. 5. Response of the system during swing-up

3.2 Stabilization

In the proposed fuzzy stabilization controller, four input variables are used: pendulum
angle θ , pendulum angular velocity θ , cart position x and cart velocity x . In order to
balance the pendulum in the range of ±30˚, seven fuzzy subsets [NVB, NB, N, ZO, P,
PB, PVB] are chosen for the error of pendulum angle and five fuzzy subsets [NB, N,
ZO, P, PB] are chosen for the error of angular velocity. Also, five fuzzy subsets
[NBIG, NEG, Z, POS, PBIG] are chosen for the error of cart position and three fuzzy
subsets [NEG, Z, POS] are chosen for the error of cart velocity to return the cart to its
home position. Swing-up and stabilization rules use the same output fuzzy subsets.
These membership functions are shown in Fig. 6. The rule bases for cart position
control and pendulum angle control are given in Table 2 and Table 3, respectively.
Totally, 49 rules are used to control the whole system.

Table 2. Fuzzy rule base for cart position

ex
ex NBIG NEG Z POS PBIG
NEG PVVB PVB PB
ZERO Z
POS NB NVB NVVB

Table 3. Fuzzy rule base for stabilization


eθ NVB NB N ZO P PB PVB
NB NVVB NVVB NVB NB N Z P
N NVVB NVB NB N Z P PB
ZO NVB NB N Z P PB PVB
P NB N Z P PB PVB PVVB
PB N Z P PB PVB PVVB PVVB
Fuzzy Control of a Real Time Inverted Pendulum System 679

NVB NB N ZO P PB PVB NB N ZO P PB

eθ e θ

+16.5
+10.5
-4.5

+4.5
-30

+3

+30
-16.5

-10.5
-18

-3
-12

+18
+12
+9
-4.2 -3.6

-9

0
-6 -1.7 0 +1.7 +3.6 +4.2 +6

NBIG NEG Z POS PBIG NEG Z POS

ex ex

-0.4 -0.3 -0.15 0 +0.15 +0.3 +0.4 -1 -0.1 0 +0.1 +1

NVVB NVB NB N Z P PB PVB PVVB

output

-6 -4.8 -3.6 -2.4 -1.2 0 +1.2 +2.4 +3.6 +4.8 +6

Fig. 6. Membership functions for θ , θ , x , x and output

Response of the controller developed here is shown in Fig. 7. In the figure, the
fuzzy logic controller based on the rules switches from swing-up to stabilization.
After the switching stabilization routine, pendulum angle and cart position are
brought to their desired values.

400 0.4
Pendulum Angle (Degree)

Cart Position (meter)

Stabilization
0.2
200
0
0
-0.2

-200 -0.4
0 1 2 3 4 5 0 1 2 3 4 5
Time (Second) Time ( Second)

Fig. 7. Controller response during switching from swing-up to stabilization

4 Experimental Results
In order to test the robustness of the designed fuzzy controller, several experiments
were implemented using the rods with different lengths and masses. In these experi-
ments, two types of disturbances were applied to the system: external and internal
disturbances. Internal disturbances were implemented by changing the system pa-
rameters: rod mass and rod length. Minimum and maximum values of the state vari-
ables are given in Table 4 as the system parameters change. The fuzzy controller was
designed for the inverted pendulum with the rod shown in Fig. 1 (0.65m and 0.2 kg).
This rod is called as a normal. Its physical properties were changed by:
• choosing heavier mass of the rod • same mass and different length of the rod
• increasing length of the normal rod • decreasing length of the normal rod
• attaching a moving mass to the end of the normal rod.
680 S. Kizir, Z. Bingul, and C. Oysu

According to Table 4, longer and lighter pendulum has a minimum error, and
shorter and heavier pendulum has a maximum error in state variables of the system.
Natural frequency of inverted pendulum is based on length of the rod about
equlibrium point so longer pendulum has a lower natural frequency. Longer pendu-
lum is controlled more easily because of its low natural frequency. It causes a high
rotational inertia giving a high resistance to a rotational change.

Table 4. Errors in the state variables

∫θ ∫x ∫u
Rod spec
θ peak x peak
Pendulum length Pendulum mass
0.65m 0.2 kg -2.6952 0.0655 0.0540 0.0444 0.0492
0.97 m 0.3 kg -1.89 0.0384 0.0426 0.0065 0.0410
0.325 m 0.1 kg -4.6449 0.1482 0.1568 0.0816 0.1388
0.42 m 0.2 kg -3.8655 0.1881 0.0988 0.1131 0.0731
0.65 m 0.3 kg -2.79 0.1027 0.0782 0.0680 0.0643
0.4 kg
0.65 m -2.3400 0.0440 0.0575 0.0121 0.0435
(moving mass)

Length=0.97m Mass=0.3kg Length=0.65m Mass=0.2kg Length=0.65m Mass=0.3kg Length=0.42m Mass=0.2kg


pendulum angle

pendulum angle

4 4
2 2
(degree)

2 2
(degree)

0 0 0 0

-2 -2 -2 -2
-4 -4
0 5 10 15 20 25 30 0 5 10 15 20 25 30 0 5 10 15 20 25 30 0 5 10 15 20 25 30

0.1 0.1 0.2 0.2


cart position

cart position
(meter)

(meter)

0 0 0 0

-0.1 -0.1 -0.2 -0.2


0 5 10 15 20 25 30 0 5 10 15 20 25 30 0 5 10 15 20 25 30 0 5 10 15 20 25 30

2 2 2 2
output

output

0 0 0 0

-2 -2
-2 -2 0 5 10 15 20 25 30 0 5 10 15 20 25 30
0 5 10 15 20 25 30 0 5 10 15 20 25 30
Time (Second) Time (Second)
Time (Second) Time (Second)

(a) (b)

Fig. 8. (a) System responses for longest and normal rod experiments. (b) System responses for
heavier and shorter rod experiments.

Length=0.325m Mass=0.1kg Moving Mass External Forces


pendulum angle

5 2 5
(degree)

0
0 0
-2

-5 -4 -5
0 10 20 30 0 10 20 30 0 5 10 15 20

0.2 0.05 0.2


cart position
(meter)

0 0 0

-0.2 -0.05 -0.2


0 10 20 30 0 10 20 30 0 5 10 15 20

2 1 1
output

0 0
0
-2 -1

-4 -2 -1
0 10 20 30 0 10 20 30 0 5 10 15 20
Time (Second) Time(Second) Time (Second)

Fig. 9. System responses for shortest rod, moving mass and external disturbances experiments
Fuzzy Control of a Real Time Inverted Pendulum System 681

5 Conclusion
The real-time fuzzy logic control of the cart-pole inverted pendulum system was
developed for swing-up and stabilization. The controller was implemented in
dSPACE-1103 development board. Several experiments were conducted to verify the
robustness of the fuzzy controller under external and internal disturbances. Based on
these experiments, the inverted pendulum system was seen to be robust to the distur-
bances. During disturbance experiments, the peak errors of the pendulum angle to the
impulse input were obtained between 1.89˚ and 4.6449˚.
Acknowledgements. One of the authors (S.K.) acknowledges the financial support of
TÜBİTAK-BİDEB. This work is also partially supported by the Turkish State
Planning Organization (DPT) under the Grant No. DPT-2003K120790.

References
1. Bingül, Z., Cook, G.E., Strauss, A.M.: Application of Fuzzy Logic to Spatial Thermal
Control in Fusion Welding. IEEE Transactions on Industry Applications 36(6) (2000)
2. Bugeja, M.: Non-Linear Swing-Up and Stabilizing Control of an Inverted Pendulum Sys-
tem. In: EUROCON Ljubljana, Slovenia (2003)
3. Muskinja, N., Tovornik, B.: Swinging Up and Stabilization of a Real Inverted Pendulum.
IEEE Transactions on Industrial Electronics 53(2) (2006)
4. Stimac, A.K.: Standup and Stabilization of the Inverted Pendulum., Massachusetts Institute
of Technology (1999)
5. Zhong, W., Röck, H.: Energy and passivity based control of the double inverted pendulum
on a cart. In: IEEE Conference on Control Applications (2001)
6. Krishen, J., Becerra, V.M.: Efficient Fuzzy Control of a Rotary Inverted Pendulum Based
on LQR Mapping. In: IEEE International Symposium on Intelligent Control, Germany, pp.
2701–2706 (2006)
7. Craig, K., Awtar, S.: Inverted Pendulum Systems: Rotary And Arm-Driven A Mechatronic
System Design Case Study. Mechatronics 12, 357–370 (2001)
8. Mirza, A.: Inverted Pendulum. Journal of AMSE 55(3,4), France (2000)
9. Nundrakwang, S., Benjanarasuth, T., Ngamwiwit, J., Komine, N.: Hybrid PD - Servo State
Feedback Control Algorithm for Swing up Inverted Pendulum System. In: ICCAS 2005,
KINTEX, Gyeonggi-Do, Korea, June 2-5 (2005)
10. Magana, M.E., Holzapfel, F.: Fuzzy-logic control of an inverted pendulum with vision
feedback. IEEE Transactions on Education 41(2), 165–170 (1998)
11. Yasunobu, S., Mori, M.: Swing up fuzzy controller for inverted pendulum based on a hu-
man control strategy. In: Proceedings of the Sixth IEEE International Conference on Fuzzy
Systems, vol. 3, pp. 1621–1625 (1997)
12. Ji, C.W., Lei, F., Kin, K.: Fuzzy logic controller for an inverted pendulum system. In:
IEEE International Conference on Intelligent Processing Systems, ICIPS 1997, pp. 185–
189 (1997)
13. Becerikli, Y., Celik, B.K.: Fuzzy control of inverted pendulum and concept of stability us-
ing Java application. Mathematical and Computer Modeling 46(1-2), 24–37 (2007)
14. Passino, K.M., Yurkovich, S.: Fuzzy Control. Addison Wesley Longman, Menlo Park
(1998) (later published by Prentice-Hall)

View publication stats

You might also like