Inverted Pendulum Design With Hardware Fuzzy Logic Controller. Eric Minnaert ...... Timer 1: Turn on, internal clock source, prescale 64, period set well.
DESIGNING FUZZY LOGIC CONTROLLER FOR INVERTED PENDULUM Haresh A. Suthar and Kaushal B. Pandya Sardar Vallabhbhai Patel Institute of Technology, VASAD. Dist. Anand, Gujarat, India.
Abstract:
1.
In control system, if all the states of the system are measured, then by using state feedback control law we can control the system. As we know that value of feedback gain cannot be found easily, it requires trial and error method for suitable pole locations. In certain applications state variables cannot be measured because of cost considerations or lack of suitable transducers. In such cases, state variables that cannot be measured must be estimated from the ones that are measurable. A device, which estimates states, is known as 'observer' or 'state observer'. To design observer, person has to face mathematical complexities. Here without facing mathematical complexities control system can be controlled using Fuzzy Logic Approach.
INTRODUCTION
We have considered the problem of Inverted Pendulum, which is hinged to a moving cart; the main objective is to keep pendulum vertical and cart in its initial position irrespective of disturbances. Considering all the parameters involved in the problem the differential equations describing dynamics of the inverted pendulum and the cart are derived. System is simulated in MATLAB SIMULINK. Using Fuzzy Logic Toolbox in MATLAB system is controlled and satisfactory results are obtained.
2.
PROBLEM OF INVERTED PENDULUM
The problem of stabilization of an inverted pendulum on a cart is considered.. The following Figure-1 Shows an Inverted pendulum with its pivot mounted on a cart. An external force drives the cart. The external force drives a pair of wheels of the cart. The force at a time t exerts a Torque T (t) on the wheels. The linear force applied to the cart is u (t); T (t)= R u (t)
62
DESIGNING FUZZY LOGIC CONTROLLER FOR INVERTED PENDULUM
where, R is radius of the wheels. The pendulum is unstable, but be kept upright by applying a proper control force u (t). The dynamics of the inverted pendulum and the cart are described by the equations 1 & 2.
6{t) = - ^ — A
^ 6(0 —-u{t) A
z(/)—-^^(0+-^
...1 ...2
-t^(0
A A Where, Horizontal displacement of the pivot on the cart is z (t). Rotational angle of the pendulum is 6(t). The parameters of the system are as follows. M= the mass of the cart, L= length of the pendulum =2 x 1, m= the mass of pendulum and J=the moment of inertia of pendulum with respect to center of gravity I
!
Figure-1: Inverted Peodulum System Suppose that system parameters are M==l kg, m = 0.15 kg , 1 = 1 m. Recall that g=9.81 m/secl
J = —m^ -—ml
=0.2kg-m^
Haresh A. Suthar and Kaushal B. Pandya
63
0{t) =4.4537 ^ (t)-0.3947 u(t) z{t) = -0.5809 e(S) + 0.9211 u (t)
...3 ...4
Choosing the states x, = 9{t),X2 =9{t),x^ =z{t),x^ = z{t) . We obtain the following state model for the inverted pendulum on moving cart. X = AX + Bu
...5
0 1 0 0 4.4537 0 0 0 A= 0 0 0 1 -0.5809 0 0 0
0 -0.3947 B= 0 0.9211
The corresponding discrete state model of the above system is as under: X{k + l) = AXik) + Bu(k) where, •7.8952e-005 1.0009 0.020006 0 0 A=
0.0891
1.0009
0
0
-0.0001162
-7.746e-07
1 0.02
-0.011621
-0.0001162
0
1
B=
-0.0078963 0.00018422 0.018422
Move the cart from one location to another without causing pendulum to fall.
3.
PROBLEM SOLUTION
As shown in Figure-2, when we apply disturbance signal to the system four state variables i.e. angle, rate of change of angle, distance traversed by the cart and velocity of the cart will be generated. At any instant k, the input to the system is u(k); and generated four state variables are • • • 6{k),6{k),z{k)and z{k) . Two state variables 6^(Ä:)a/7(i6^(Ä:) are given to the fuzzy controller. Fuzzy controller generates next required velocity of the cart i.e. z(^ + l)
64
DESIGNING FUZZY LOGIC CONTROLLER FOR INVERTED PENDULUM
Figure X; Block Diagmm
z{k + \) can be obtained by applying proper force to the system i.e. u{k +1). Where, u{k-\-\) =
•• Mxz{k-\-\)
^^ , l{k + \)-z{k)
t = time in which z{k +1) is to be obtained. Now it is required to design a Fuzzy Controller that can be done using FIS Editor in MATLAB.
4.
DESIGN OF FUZZY CONTROLLER USING FIS EDITOR
As discussed in above block diagram, angle and rate of change of angle are the selected inputs of the Mamdani type of fuzzy controller • and next required velocity of the cart (z{k + 1) ) is the output. Two input variables and one output variable along with their fuzzy levels and membership functions are as shown in the following Figure-3. {6{k)and6{k))
HareshA. Suthar and Kaushal B. Pandya
iCG
.rü
m
^
n^ish
:i
n^3^'
0
65
a
ZS1S
^0
50
i»süi^
posls^
liX
:
K\hN\,/N A, K\ A.
A.
H •:ce
~~ 4: -e;
-i]
-20....„.„ 0i
:^!
4i
8:
S:
a
1^:
^-
^
(b)
-KO
^f
-B
-40
-20
§
m
(c) FIGURE-3: C O M P L E T E S E T O F M E M B E R S H I P F U N C T I O N S THEIR FUZZY L E V E L S .
WITH
66
DESIGNING FUZZY LOGIC CONTROLLER FOR INVERTED PENDULUM
Depending upon the Fuzzy Levels selected for the inputs and output appropriate rules can be generated. Some of which are, 1) If angle is zero and rate of change of angle is negative high then next required velocity is positive high. 2) If angle is positive and rate of change of angle is positive high then next required velocity is negative high. The Mamdani type Fuzzy Controller is designed in FIS Editor and then exported to workspace for simulation purpose. The system of inverted pendulum is simulated in MATLAB SIMULINK as shown in Figure-4. The Fuzzy Logic Controller of simulink uses the '.fis' file from the workspace.
JnliEl
H^ic^ricontrol * n b EJdt "^xi SmMv^T\
Fonfnat Tocfe Help
D Ö y # ' ^ ^ @ | l Q Q U
8 iNoimal
XnÄau;n) Dis3reiB S^slem
•
W'\
m
li
^ DisplscEmerft
•?1jnL)=C}=range[1] && X=range[0] && Xrange[2] && X 0, there exists r > 0, such that if kx(0)k < r , then kx(t)k < R for all t ≥ 0. Otherwise, the equilibrium point is unstable. More formally, the definition states that the origin is stable, if, given that we do not want the state trajectory x(t) to get out of a ball of arbitrarily specified radius A R , a value r (R) can found such that starting the state from within the ball Ar at time 0 guarantees that state will stay within the ball A R thereafter. Conversely, an equilibrium point is unstable if there exists at least one ball A R such that for every r > 0, no matter how small, it is always possible for the system trajectory to start somewhere within the ball A R and eventually leave the ball A R . As shown in Fig. 21 the implementation of the curves are asymptotically stable, marginally stable, and unstable, respectively. All trajectories close to the origin moving further and further away to infinity are denoted “blow up”. There are differences between instability and the notion of “blowing up”. In linear systems, instability is equivalent to blowing up, because unstable poles always lead exponential growth of system states. However, for nonlinear systems, blowing up is only one form of instability. This subject has a very large scale for control systems. References [1] B.K. C ¸ elik, Fuzzy Control Systems and Fuzzy Logic Based Inverted Pendulum Control System, Term Project, Computer Engineering Department, Kocaeli University, January 2004. [2] L. Wang, A Course in Fuzzy Systems and Control, Prentice-Hall Inc., 1997. [3] J.T. Ross, Fuzzy Logic with Engineering Applications, McGraw-Hill, Inc., 1995. [4] G.J. Klir, B. Youan, Fuzzy Sets and Fuzzy Logic Theory and Applications, Prentice Hall Inc., 1995. [5] Z. Yeh, K. Li, A systematic approach for designing multistage fuzzy control systems, Fuzzy Sets and Systems (2003).
Y. Becerikli, B.K. Celik / Mathematical and Computer Modelling 46 (2007) 24–37
37
[6] M. Margaliot, G. Langholz, Adaptive fuzzy controller design via fuzzy lyapunov synthesis, in: Proceedings of FUZZ-IEEE’98, 1998, pp. 354–359. [7] T. Yamakawa, Stabilization of an inverted pendulum by a high-speed fuzzy logic controller hardware system, Fuzzy Sets and Systems 32 (1989) 161–180. [8] S. Kawaji, T. Maeda, Fuzzy servo control system for an inverted pendulum, in: Proceedings of IFES’91, vol. 2, 1991, pp. 812–823. [9] N. Yubazaki, J. Yi, M. Otani, K. Hirota, SIRMs dynamically connected fuzzy inference model and its applications, in: Proceedings of IFSA’97, vol. 3, 1997, pp. 410–415. [10] J. Yi, N. Yubazaki, K. Hirota, Upswing and stabilization control of inverted pendulum system based on the SIRMs dynamically connected fuzzy inference model, Fuzzy Sets and Systems (2000). [11] M. Margaliot, G. Langholz, A new approach to fuzzy modeling and control of discrete-time systems, IEEE Transactions on Fuzzy Systems 11 (2003). [12] J. Yi, N. Yubazaki, Stabilization fuzzy control of inverted pendulum systems, Artificial Intelligence in Engineering 14 (2) (2000) 153–163. [13] L.A. Zadeh, From circuit theory to systems theory, Proceedings of Institution of Radio Engineers 50 (1962) 856–865. [14] L.A. Zadeh, Fuzzy algorithms, Information and Control 12 (2) (1968) 94–102. [15] L.A. Zadeh, Outline of a new approach to the analysis of complex systems and decision processes, IEEE Transactions on Systems, Man and Cybernetics 3 (1973). [16] J.-J.E. Slotine, W. Li, Applied Nonlinear Control, Prentice-Hall, Inc., 1991. [17] V.B. Rao, C++ Neural Networks and Fuzzy Logic, IDG Boks Worldwide, Inc., 1995. [18] J. Jaworski, Java Developer’s Guide, Sams.net Publishing, 1996. [19] K.C. Hopson, S.E. Ingram, Developing Professional Java Applets, Sams.net Publishing, 1996. [20] S.C. Chapra, R.P. Canale, Numerical Methods for Engineers, McGraw-Hill, Inc., 1989.
Robust Control of Inverted Pendulum using Fuzzy Logic Controller Sandeep Kr. TripathiHimanshu Pandayand Prerna Gaur
Abstract-Robust Control has been used in various applications to
improve
the
performance
of
the
system. The
Inverted
pendulum (also called "Cart-Pole system) is a classical example of nonlinear and unstable control system. In This paper we present different design techniques of controller for stabilizing the
inverted
pendulum
(cart
system)
problem
and
there
comparative analysis of performance and reliability which is done through simulation on MATLab-Simulink. Robust control (Hco) in
association
with fuzzy produce better response as
compared to fuzzy controller.
Index Terms-Inverted Pendulum, Hco, Fuzzy Logic, Robust
In our design, Matlab/Simulink platform used for observing such compensating controller. The inverted pendulum problem is the classical problem of the control system. It is a highly non linear system. Such type of control problem needs very precise and robust control. The overshoot and the error, both play crucial role in the stability of Inverted Pendulum (lP). The objective of the present work is to get the optimized and robust performance of a nonlinear system with the help of Robust (Hoo) controller using Fuzzy Logic Algorithm.
Control
II. I.
INTRODUCTION
A two dimensional Inverted Pendulum consists of a freely
hinged rod over a dynamic platform that can be driven by either belt-motor system or by cart system. It has inherently two states i.e. stable and the unstable. The stable state is undesirable state and the pendulum is downward oriented. In unstable state pendulum orient strictly upward and hence, requires a counter force to stay align to this position because disturbance will shifts the rod away from equilibrium. This problem has been addressed by testing and implementation of under-actuated mechatronical system and controlling of inherently open loop unstable with highly non-linear dynamics like robotics [1-3] and space rocket guidance systems. Process model is that component of control system which manipulates the inputs to get the desired output, however due to unexpected disturbances, its output deviates. So, in order to sense and rectify these random deviations dynamically feedback with controller to make it a close-loop system has been proposed. Initially upright position of the pendulum has been assumed due to disturbance uncompensated model of the system has tendency to move downward towards the stability. Our proposed Controller will try to compensate this disturbance and maintain its upward state. Numerous controlling techniques are available, ranging from conventional controller, artificial intelligence controllers [4]-[6] to recent robust controllers [7]-[13] . Sandeep
Kr. Tripathi is with Netaji Subhas Institute Of Technology, New
Delhi INDIA
Himanshu Panday is with 'Galgotia College of Engineering &Techno]ogy, Gr. Noida INDIA
978-1-4673-5630-5//13/$3l.0 0 ©20 13 IEEE
MATHEMATICAL ANALYSIS
In order to analyses the control system, mathematical model is established to predict the behavior before utilizing it into a real system. In this process, we rationalize differential and algebraic equations obtained from conservational laws and its characteristics to obtain transfer function of the process. We have taken mathematical model of [1] for our work. The separate Free Body Diagram of the cart and pendulum as shown in figure 2.1 is used to obtain its mathematical model.
Figure 2.1 Free Body Diagram of the System
By applying Newton's 2nd law of motion to the cart system and assuming the (nonlinear) coulomb friction applied to the linear cart is assumed to be neglected. The force on the linear cart due to the pendulum's action has also been neglected in the presently developed model, the following dynamic equation in horizontal and vertical direction are:
a) Horizontal direction:
Summing the forces in the Free Body Diagram of the cart in the horizontal direction, we get the following equation of motion:
MX=F-bx-N ................................... (2.1) The force exerted in the horizontal direction due to the moment on the pendulum is determined as follows: d2 N =m-2 dt
(x+lsinB)
................................... (2.2)
Summing the forces in the Free Body Diagram of the pendulum in the horizontal direction, we can get an equation for N:
N= mX+mIBcosB-mlii sinB ..................... (2.3)
If we substitute this equation (2.2) into the first equation (2.1), we get the first equation of motion for this system:
(M +m)x+bx +mIBcosB-mU!i sinB =F
.... (2.4)
b) Vertical direction: To get the second equation of motion, sum the forces perpendicular to the pendulum. This axis is chosen to simplifY mathematical complexity. Solving the system along this axis ends up saving you a lot of algebra. Just as the previous equation is obtained, the vertical components of those forces are considered here to get the following equation:
d2 P-mg= m- (lcosB) dt2 ...................................(2.5) Also
2 P-mg=-ml BsinB-ml B cosB
c) Rationalisation: To get rid of the P and N terms in the
equation above, sum the moments around the centroid of the pendulum to get the following equation:
-PlsinB-Nl cosB= lB ................................ (2.6) B=:r+¢,cos¢= -cosB,sin¢= -sinB I=!mP 4
3
..
Where Xes) and
and¢(t) .
Substituting the value of XeS) in the above equation and we get
ml
B=
¢,
dB cosB=-l,sinB=_¢, ( )2=O,u=F dt
¢
Therefore, The linearized model can be obtained by considering the small variations about the equilibrium point when the pendulum is at upright position and neglecting higher order term. After linearization, the dynamic equations are: 4 .. ..
-l ¢-g¢=x 3
(s) U(s) s4
ibml2
+3
To obtain the transfer function of the linearized system equations analytically, we must first take the Laplace transform of the system equations. The Laplace transforms are:
(I +mP)¢(s)s2 - mgl¢(s) =mIX(s)s2 ............. (2.8)
(M +m)X(s)s2 +bX(s)s-ml¢(s)s2 = U(s)
.....(2.9)
q
q
3
s -
mgl(M +m) s2 - -bmgl s q
q
q = [(M +m)(I +mI2)_ (ml)2]
= Input
Where U From the above transfer function it is found that there is both pole and zero at the same origin. Therefore these can be canceled and transfer function of the angle will be as equation (2.9).
ml -s
U
written as:
PB
NB
NB
NB
NB
NB
NB
NM
ZE
NB
NB
NB
NB
NM
ZE
PM
NS
NB
NB
NB
NM
ZE
PM
PB
ZE
NB
NB
NM
ZE
PM
PB
PB
PS
NB
NM
ZE
PM
PB
PB
PB
PM
NM
ZE
PM
PB
PB
PB
PB
PB
ZE
PM
PB
PB
PB
PB
PB
IV. ROBUST CONTROL Open-loop interconnection can be shown as (Fig.4.l) z
-------'I:
w
p
'--
(;J {:J (� : �:J(:J =
"
(condition E implies condition U) which may be IF E THEN U.
The fuzzy knowledge-base also has a database defining the variables. A fuzzy variable is defined by a fuzzy set, which in turn is defined by a membership function. Fuzzy reasoning is
=
2
..................... (4.1)
For closed-loop interconnection structure Fig (4.2), let w denotes the signal that affects the system and which cannot be influenced by the controller. It is called generalized disturbance .In our example
W�[;l
the signal that tells us that whether a given controller has certain desired properties. z is called controlled variable (In our example , z=e=Vref-Vo). u denotes the output signal of the controller, called control input. y is the signal entering the controller, called the measurement output. Z
Output
FIS Type:
� II
I System "CTM": 2 inputs, 1 output, and 49 rules
�
PM
and generalized equation of this open loop system is
View
(mamdani)
PS
Fig.4.1.General Open-loop interconnection
------ r;]g]� Error
ZE
11
.) FIS Editor: CTM
IX>
=
Where,
liz