Sunteți pe pagina 1din 6

750

DESIGN OF FUZZY LOGIC CONTROLLER FOR NONLINEAR


MODEL OF INVERTED PENDULUM-CART SYSTEM
Mohan Akole
#1
, Barjeev Tyagi
#2

#
Electrical Engineering Department,
Indian Institute of Technology, Roorkee, India
1
mohanakole@gmail.com
2
btyagfee@iitr.ernet.in


Abstract This paper presents the design of a fuzzy logic
controller for the inverted pendulum-cart system. Inverted
pendulum is well known as a testing bed for various
controllers. Fuzzy logic controller is one of the most
important applications of fuzzy-rule-based system that
models the human decision processing with a collection of
fuzzy rules. In this work two fuzzy logic controllers have
been designed for Cart and Pendulum, separately. Twin
controller is useful in controlling the Cart and Pendulum
independently. The simulation results of fuzzy logic
controller are compared with conventional PID type
controller.

Keywords Inverted Pendulum, Modelling, PID controller,
Configuration of Fuzzy Logic system, Fuzzy Logic Controller,
I. INTRODUCTION
The cart type inverted pendulum system is a multivariable,
nonlinear, fast reaction, unstable and high order system. It has
become an excellent testing bed for various control techniques
and new control theories. Furthermore, inverted pendulum
system may also simulate many phenomena in the nature,
such as walking robots, flying objects in space, missile
guidance etc.
This paper contains some results of investigation on
the problem of inverted pendulum-cart system. Generally
there are two types of inverted pendulums. One is the moving-
cart (also referred to as moving-carriage or moving-wagon)
type and the other is rotation type. The moving-cart inverted
pendulum has a cart that can only move back and forth along
the track. In this paper, control of the movingcart type
inverted pendulum problem has been considered. In
conventional control theory, most of control problems are
usually solved by mathematical tools based on system models.
But in true sense, there are many complex systems whose
accurate mathematical models are not available or difficult to
formulate. As an alternative to conventional control approach,
the fuzzy control techniques can provide a good solution for
these problems by introducing linguistic information. The
most difficult aspect in the design of fuzzy controller is the
construction of the rule base [1]. The construction of fuzzy
rules has been mainly based on the operators control
experience or actions. Also tuning of the fuzzy rule
membership functions is an important task in the design of
fuzzy system.
In this work, a new control structure, for controlling
the nonlinear inverted pendulum-cart system with a nonlinear
friction has been proposed. To simplify the design of fuzzy
controller for balancing the inverted pendulum and moving
the cart to the origin, the inverted pendulum-cart system is
decomposed into the pendulum and cart subsystem [9], [10].
For these subsystems twin controllers for stabilizing the cart
position and the up-right position of the pendulum have been
proposed. Main aspect of this paper is the control of the
nonlinear inverted pendulum directly without linearizing it, by
conventional PID controller and the rule-based fuzzy logic
controller. The proposed scheme has a simple structure that
decreases the number of fuzzy rules.
II. MODELLING AND SIMULATION
Fig. 1 is the schematic drawing of the inverted
pendulum on a cart system. The cart is able to move on a
limited horizontal rail length.


Fig. 1 Inverted Pendulum-Cart system

Fig.2 shows two free body diagrams of the inverted
pendulum-cart system.

XXXII NATIONAL SYSTEMS CONFERENCE, NSC 2008, December 17-19, 2008
751


Fig.2 Free body diagram of Inverted Pendulum-Cart system

In this system the rod is considered as mass less, F is
the control (applied) force, x is the displacement of the cart,
is the angle of the pendulum with respect to vertical axis, g is
gravity acceleration. Other parameters are: the mass of cart M,
the mass of pendulum m, the friction coefficient of cart b, the
length between axle centre and the centre of pendulum L, the
inertia of pendulum I [3].
For simulation purpose the dynamic equations of the
actual inverted pendulum system are as follows.
By Newtons equation
For cart
H
J
2
x
Jt
2
= F
cut
1

F = Hx +bx +N 2

Where, N and P are the interaction forces between the cart and
pendulum.

J
2
x
Jt
2
=
1
H
_F -N -b
Jx
Jt
] S

For pendulum
I
J
2
0
Jt
2
=
pcnd
4
J
2
0
Jt
2
=
1
I
(Nlcos0 +Plsin0) S

It is necessary, however, to include the interaction forces N
and P between the cart and the pendulum in order to model the
dynamics. The inclusion of these forces requires modelling the
x and y dynamics of the pendulum in addition to its theta
dynamics. Therefore, the additional x and y equations for the
pendulum are modelled as:

m
J
2
x
p
Jt
2
= F
x
pcnd
= N 6

N = m
J
2
x
p
Jt
2
7

m
J
2
y
p
Jt
2
= F

pcnd
= P -mg 8

P = m_
J
2
y
p
Jt
2
+g_ 9

However x
p
and y
p
are exact functions of theta.
Therefore, their derivatives are represented in terms of the
derivatives of theta.
x
p
= x -l sin0 1u

J x
p
Jt
=
Jx
Jt
-l cos 0
J0
Jt
11

J
2
x
p
Jt
2
=
J
2
x
Jt
2
+l sin0 _
J0
Jt
]
2
-l cos 0
J
2
0
Jt
2
12

And
y
p
= lcos0 1S

Jy
p
Jt
= -lsin0
J0
Jt
14

J
2
y
p
Jt
2
= -lcos0 _
J0
Jt
]
2
-lsin0
J
0
2
Jt
2
1S

After substituting these equations into eq. 7 and 9, we get

N = m
J
2
x
p
Jt
2
= m_
J
2
x
Jt
2
+l sin0 _
J0
Jt
]
2
-l cos 0
J
2
0
Jt
2
_ 16

P = m
J
2
y
p
Jt
2
= m_-lcos0 _
J0
Jt
]
2
-lsin0
J
2
0
Jt
2
_ 17

Using these nonlinear equations, a MATLAB
SIMULINK model has been developed. This SIMULINK
model is used in this work for stabilizing the upright position
of the pendulum and to move the cart at desired position.

III. DESIGN OF PENDULUM UPRIGHT POSITION
AND CART POSITION CONTROLLER

Controller design is a key content of the Inverted
Pendulum system. Controllers are used to stabilize the
unstable system and make it robust to disturbances. In this
paper, conventional PID type controller and rule based Fuzzy
Logic controller has been implemented for inverted
pendulum-cart system. The framework of this Inverted
Pendulum-cart system Controller is presented in Fig.3.


Fig. 3 Block diagram of Inverted Pendulum-cart controller system
752


In Fig.3 inverted pendulum-cart system is controlled
by two separate controller, pendulum angle controller and
cart position controller. From the dynamic equations of this
system, it is found that there are two dynamic objects in the
inverted pendulum-cart system. One is the pendulum and the
other is the cart. To consider the control of the pendulum and
cart separately, would be easier for the design of a controller
with the rule base mechanism.
However, there is only one control action is allowed
for the inverted pendulumcart system. Therefore, the control
action Fp for the pendulum subsystem and the control action
Fc for the cart subsystem need to be combined into one
control action F for the inverted pendulum-cart system. It can
be seen that to provide a control action to push the cart toward
left-hand side will move the pendulum to the right-hand side.
This instinctive knowledge indicates that the control actions to
move the cart and pendulum to the same direction have
opposite sign [2]. Since the main purpose for the position
control of the inverted pendulum-cart system is to balance the
pendulum at the straight upward direction, the combination of
Fp and Fc is defined as F=Fp - Fc.

A . Conventional PID Controller

Model of the inverted pendulum-cart system is an
unstable model. This model can be stabilized by using the
controllers. In this work two PID controllers have been
designed. First one for Pendulum angle control and other for
the Cart position control. These PID controllers attempt to
correct the error between a measured process variable and a
desired set point by calculating and then outputting a
corrective action that can adjust the process accordingly. For
both PID controllers, the structure is taken as:

u = K
P
c +K
I
_c Jt +K

Jc
Jt
18

Where u is PID output control action, e is the error i.e.
difference between set point input and actual output e=yref -
yactual, and K
P
, K
I
, K
D
are the proportional, integral and
derivative gains respectively.
As mentioned above, the output of pendulum angle
controller and the cart position controller are opposite sign.
The selection of PID controller parameters (K
P
, K
I
, K
D
) are
important. If these parameters are chosen incorrectly, the
controlled process input can be unstable. Tuning a control
loop is the adjustment of its control parameters to the
optimum values for the desired control response. There are
several methods for tuning the PID loop. In this paper, we
used Ziegler-Nichols criteria for tuning the control parameters
of the PID controller.

B. Fuzzy Logic Controller (FLC)

FLC is one of the most successful applications of fuzzy
set theory, introduced by Zadeh in 1965 [4]. Its major features
are the use of linguistic variables rather than numerical
variables. Linguistic variables, defined as variables whose
values are sentences in natural language (such as small and
large) may be represented by fuzzy sets.
A fuzzy set is an extension of a crisp set where an
element can only belong to a set (full membership) or not
belong to at all (no membership). Fuzzy set allow partial
membership which means that an element may partially
belong to more than one set.
A fuzzy set A is characterized by a membership function
p
A
that assigns to each object in a given class a grade of
membership can range from 0 (no membership) to 1 (full
membership), we therefore write
p
A
X - |u, 1]
Which means that the fuzzy set A belongs to a universal set X
(usually called universe of discourse) defined in a specific
problem. A fuzzy set A is called a fuzzy singleton when there
is only one element x
o
with p
A
(x
o
) = 1 , while all other
elements have a membership grade which equal to zero.
This approach allows characterization of the system
behaviour through simple relations (fuzzy rules) between
linguistic variables. Usually, fuzzy rules are expressed in the
form of fuzzy conditional statements Ri of the type

Ri : if x is small THEN y is large

Where x and y are fuzzy variables, and small and large are
labels of fuzzy set. If there are i =1 to n rules, the rule set is
represented by union of these rules

R=R
1
else R
2
else R
n


A fuzzy logic controller is based on a collection of R
control rules. The execution of these rules is governed by the
compositional rule of inference [5], [6].
The general structure of an FLC is represented in
Fig.6 and comprises four principle components: 1) a
fuzzyfication inference converts input data into suitable
linguistic values; 2) a knowledge base consists of a data base
with the necessary linguistic definitions and control rule set;
3) a decision making logic infers the fuzzy control action from
the knowledge of the control rules and the linguistic variable
definitions; 4) a defuzzyfication interence yields a nonfuzzy
control action from an inferred fuzzy controlled action.


Fig. 6 Basic configuration of FLC

In this paper, two fuzzy controllers have been
designed, one for pendulum system and other for cart system.
Each controller uses two inputs variables. Pendulum angle
controller use pendulum angle error e and derivative of e i.e.
edot. Cart position controller use cart position error x and its
753

derivative xdot. The output of these controller are combined to
give net force F =Fp - Fc on the cart.
The proposed fuzzy logic controllers used to control
the inverted pendulum uses conventional triangular
membership functions. Furthermore, the fuzzy inference
engine implements a set of IF-AND-THEN rules on the
angle error e ,edot and output Fp and cart position error x,
xdot and output Fc. All six universe of discourse are divided
into three overlapping fuzzy set values labeled N (Negative),
Z (Zero) and P (Positive). Fig.7 shows three membership
functions of pendulum angle controller. For cart position
controller similar membership functions are defined for the
universe of discourse x: [-0.5 0.5], xdot: [-0.03 0.03] and Fc:
[-12 12]. Design of the rules are based on heuristic
knowledge of the behavior and based on the theoretical
criteria [7], [8]. To generate the rules for this work the basic
criteria is considered as, if the pendulum is falling in one
direction, then push the cart in the same direction to counter
the movement of the pendulum. Nine rules are defined for
each controller. The rule base matrix for pendulum angle
controller is shown in Table I. Same rule base is taken for the
cart system.



Fig. 7 Membership function for e, edot and Fp

TABLE I
PENDULUM ANGLE FUZZY CONTROL RULES
edot
e
N Z P
N

N N Z
Z

N Z P
P

Z P P



IV. SIMULATION STUDIES
In this paper, inverted pendulum-cart system has been
simulated using the twin PID controllers and Fuzzy Logic
controllers. Parameters of inverted pendulum-cart system
given in Table II. The pendulum angle PID controller and
cart position PID controller are tuned by the Ziegler-Nichols
criteria. Gain values of these PID controllers are shown in
Table III.

TABLE II
PARAMETERS OF INVERTED PENDULUM SYSTEM

Symbol

Parameter name Values
M Mass of Cart 0.5 Kg
m Mass of pendulum 0.2 Kg
b Friction coefficient 0.1 N/m/sec.
L Length between axle center and
the center of pendulum
0.3 m
I Inertia of pendulum 0.006 Kg.m
2

g Gravity acceleration 9.8 m/s
2


TABLE III
PID CONTROLLER GAINS

Gain For Pendulum angle
controller
For Cart Position
Controller
K
P

41 2
K
I

38 0.02
K
D

27 0.4


The given system is disturbed by small external signal of
1*10
-6
units. Oscillations in the pendulum angle at upright
position are shown in Fig.8.a and 8.b. Comparing these figure
it is clear that the oscillations are much smaller in case of the
fuzzy controller. Figure 8.c and 8.d shows the cart position
with PID and FLC. Comparing Fig. 8.c and 8.d it is clear that
cart moves more smoothly towards its reference position with
fuzzy logic controller. Figure 9.a and 9.b shows pendulum
angle oscillation, when pendulum-cart system is disturbed by
an larger amplitude signal (0.001 unit). Figure 9.c and 9.d
shows the dynamics of the cart for 0.001 unit disturbance
signal. Comparing Fig.9.a and 9.b for pendulum angle and
Fig. 9.c and 9.d for cart position, it is clear that FLC response
is better than the PID. Figure 10.a to 10.d shows the result
when disturbance is of very large amplitude (1 unit). In all the
cases frequency of the disturbance signal is kept constant at
0.5 rad/sec.
In all the above cases cart reference position is taken as
zero. If reference position of the cart is changed, then cart
moves to its new reference keeping pendulum stabilized in
upright position. This is shown in Fig.11.a to 11.d for both
PID and Fuzzy Logic Controller.

Following figures shown are the graphical results of PID
and Fuzzy Logic controllers respectively.

754


Fig. 8.a PID Response for disturbance 0.000001 unit

Fig. 8.b Fuzzy Response for disturbance 0.000001 unit

Fig. 8.c PID Response for disturbance 0.000001 unit

Fig. 8.d Fuzzy Response for disturbance 0.000001 unit
Fig. 8 (a, b, c, d) Responses for Impulse Signal 1*10
-6
unit for PID controller
and Fuzzy Logic Controller


Fig. 9.a PID Response for disturbance 0.001 unit

Fig. 9.b Fuzzy Response for disturbance 0.001 unit


Fig. 9.c PID Response for disturbance 0.001 unit


Fig. 9.d Fuzzy Response for disturbance 0.001 unit
Fig. 9 (a, b, c, d) Responses for Impulse Signal 1*10
-3
unit for PID
controller and Fuzzy Logic Controller


Fig. 10.a PID Response for disturbance 1 unit

Fig. 10.b Fuzzy Response for disturbance 1 unit


Fig. 10.c PID Response for disturbance 1 unit
755


Fig. 10.d Fuzzy Response for disturbance 1 unit
Fig. 10 (a, b, c, d) Responses for Impulse Signal 1 unit for PID controller and
Fuzzy Logic Controller

After changing the cart reference position (i.e Cart
Ref.= 0.2m and Angle Ref.=0) for the impulse signal of
0.001V, 0.5 rad/sec, the PID and Fuzzy controller responses
are as follows.


Fig. 11.a PID Response for disturbance 0.001 unit ,when Cart Ref. =0.2


Fig. 11.b Fuzzy Response for disturbance 0.001 unit when, Cart Ref. =0.2


Fig. 11.c PID Response for disturbance 0.001 unit, when Cart Ref.=0.2

Fig. 11.d Fuzzy Response for disturbance 0.001 unit, when Cart Ref. =0.2

Fig.11 (a, b, c, d) PID and Fuzzy responses after changing the Cart
Reference position (Cart Ref. =0.2 m)






V. CONCLUSION
A Fuzzy Logic based control scheme for inverted
pendulum-cart system has been proposed in this paper. A
nonlinear model of the inverted pendulum-cart system has
been considered to develop the fuzzy logic controller.
Responses of the system with fuzzy logic controller have been
compared with the responses obtained using the PID
controller. These responses are shown in Fig.8 to Fig.11. It is
clear from the simulation studies that Fuzzy Logic control
scheme works more effectively compared to the PID Control
scheme.



RFERENCES

[1] K. Tanaka and M. Sugeno , Stability analysis and design of
fuzzy Control systems, Fuzzy sets and systems, Vol. 45. pp.
135-156, 1992.
[2] C.W. Tao, et al., Fuzzy hierarchical swing- Up and sliding
position Controller for the inverted pendulumcart system, Fuzzy
Sets and Systems (2008),ScienceDirect
[3] Website http://www.library.cmu.edu
[4] L. A. Zadeh, Outline of a new approach of the analysis of complex
system and decision processes, IEEE Trans. Syst., Man, Cybern.,
vol. SMCJ, no. 1, pp. 28-44, 1963.
[5] Mamdani, E. H. and Assilian, S., An Experiment in Linguistic
Synthesis with a Fuzzy Controller, International Journal of Man-
Machine studies 7,pp. 1-13, 1975.
[6] T. J. ROSS, Fuzzy Logic with Engineering Applications, McGraw-
Hill, Inc., 1991.
[7] F. Smith, A Comparative Study of Inference Methods for Fuzzy
logic Control, Dept. of Artificial Intelligence, University of
dinburgh, 1996.
[8] Chen Wei Ji Fang Lei Lei Kam Kin Fuzzy Logic Controller for An
Inverted Pendulum System, 1997 IEEE International Conference
On Intelligent Processing System
[9] C.M. Lin,Y.J. Mon, Decoupling control by hierarchical fuzzy sliding-
mode controller, IEEE Trans. Control Systems 13 (4) (2005) 593
598.
[10] J.C. Lo,Y.H. Kuo, Decomposed fuzzy sliding-mode control, IEEE
Trans. Fuzzy Systems 6 (3) (1998) 426435.




Mohan Akole (b1973) received B.E. degree in Instrumentation Engineering
from SGGS, COE&T, Nanded (India) in 1997 and presently, he is doing
M. Tech in System Engineering and Operation Research under Electrical
Engineering Department at Indian Institute of Technology, Roorkee (India).

Barjeev Tyagi (b1964) received B. Tech. degree in Electrical Engineering
from University of Roorkee (India) in 1987 and Ph. D. degree from IIT
Kanpur in 2006. Presently, he is a faculty member in Electrical Engineering
Department at Indian Institute of Technology, Roorkee (India). His research
interests include control system, power system deregulation, power system
optimization and control.

S-ar putea să vă placă și