fuzzy, neural and neuro-fuzzy controllers for an inverted pendulum
TRANSCRIPT
![Page 1: Fuzzy, Neural and Neuro-Fuzzy Controllers for an Inverted Pendulum](https://reader037.vdocuments.site/reader037/viewer/2022100208/553b289c5503463a458b469e/html5/thumbnails/1.jpg)
Intituto Tecnológico y de Estudios Superiores de Monterrey, Intelligent Controll, Fall 2011, Monterrey, N.L. Mexico
1
Abstract—This paper presents the design of a fuzzy logic,
artificial neural network (ANN) and neural-fuzzy (ANFIS)
controllers for the inverted pendulum-cart system. The dynamic
nonlinear equations are used to model the system. Fuzzy logic
controller is one of the most important applications using the
expert knowledge to control the system. Artificial Neural
Networks has similar properties to Fuzzy systems but it includes a
learning stage that allows to combine both strategies to implement
a Neuro-Fuzzy controller which results in the optimization of
fuzzy logic and ANN behavior. The simulation results of each
controller are compared.
Index Terms—Fuzzy Control; Artificial Neural Control;
ANFIS Control; Inverted Pendulum.
I. INTRODUCTION
HE inverted pendulum is a multivariable and nonlinear
system that is commonly used to test control strategies.
The inverted pendulum may simulate natural phenomena such
as the walking motion, missile guidance, biomechanical
devices, etc.
This paper contains the comparison of Fuzzy logic, artificial
neural network and a synergy of both strategies responses in
the control of the inverted pendulum using the non-linear
equations. The approach of Passino [1] is used for the fuzzy
rule database and then an ANN is trained with the Fuzzy
Controller dynamics to emulate it and control the pendulum
system. Finally a neuro-fuzzy controller is implemented.
II. MODELING THE SYSTEM
A. Non-Linear Dynamics.
The diagram of the inverted pendulum is shown in Fig. 1.
The dynamic non-linear equations of the inverted pendulum
system are as follows:
umLmLxbxmM sincos 2 (1)
cossin2 xmLmgLImL (2)
Where M is the mass of cart, m is the mass of the pendulum,
b is the friction of the cart resisting motion, L is the length of
the pendulum to its center of mass, I is the inertia of the
pendulum, u(t) is the force applied to the cart, x represents the
cart position coordinate and
is the angle of the pendulum
measured from the vertical.
Fig.1. Diagram of the inverted pendulum-cart system.
Using the non-linear equations the system uses the
parameters of Table I.
TABLE I
INVERTED PENDULUM PARAMETERS.
Parameters Value
M 0.5 kg
m 0.2 kg
b 0.1 N/(m/s)
L 0.3 m
I 0.006 kg
m 2
g 9.8 m/
s2
The simulation of the controller was performed in Simulink
MATLAB, this software allows to implement the model of the
system using the non-linear dynamics equations in the form of
block diagrams using a subsystem function. After substituting
the parameters of the Table I into the equations, the resulting
system is shown in Fig. 2.
Fuzzy, Neural and Neuro-Fuzzy Controllers for
an Inverted Pendulum
Esteban Salazar (353869), Ernesto León (808770)
T
![Page 2: Fuzzy, Neural and Neuro-Fuzzy Controllers for an Inverted Pendulum](https://reader037.vdocuments.site/reader037/viewer/2022100208/553b289c5503463a458b469e/html5/thumbnails/2.jpg)
Intituto Tecnológico y de Estudios Superiores de Monterrey, Intelligent Controll, Fall 2011, Monterrey, N.L. Mexico
2
Fig.2. Inverted pendulum non-linear system.
This block represents the plant that the control system will
perform the manipulation.
B. Control Strategies
The strategies used in this paper to control the inverted
pendulum-cart system are Fuzzy logic, ANN and ANFIS.
The Fuzzy controller is designed to automate how a human
expert who is successful at this task would control the system.
First, the information of the expert is collected in linguistic
descriptions at the form of if… then rules. The statements that
quantifies the configuration of the inverted pendulum proposed
by Passino [1] are: (i) the statement “error is positive large”
can represent the situation where the pendulum is at a
significant angle to the left of the vertical, (ii) the statement
“error is negative small” can represent the situation where the
pendulum is just slightly to the right of the vertical but not
close to the vertical to justify quantifying it as zero and far
from negative large and (iii) the statement “error is zero”
represents the situation where the pendulum is near the vertical
position. For the change in the error the negative sentence
means that the pendulum direction is closing to the vertical
position and for a positive change in error represents that the
pendulum is moving away the vertical position.
Once the fuzzy controller is properly tuned, an artificial
neural network is trained to simulate the fuzzy controller
behavior using the back-propagation algorithm in MATLAB.
III. FUZZY LOGIC CONTROLLER
The fuzzy logic controller is known as knowledge based
system [2], where the knowledge of an expert about a system
behavior is pass on the form of if… then rules to a data base of
fuzzy rules that determines the manipulation of the fuzzy
controller to the plant.
The inverted pendulum system has two variables for
controlling: (i) the angle of the pendulum with respect of the
vertical position and (ii) the position of the cart. The cart
where the pendulum is mounting, it moves in straight direction
to compensate the changes in the angle variations. From [1],
the fuzzy rules for the error and the change of the error are in
the form of fuzzy sets that describes the relation of the actual
position with the desired. The fuzzy sets that describes the
membership functions of the error and the change in error for
the theta angle of the pendulum are the same form for both and
is shown in Fig. 3, where the manipulation fuzzy sets of the
controller is shown in Fig. 4.
Fig.3. Fuzzy sets for error and change in error
for theta.
Fig.4. Fuzzy sets for controller manipulation.
From Fig. 3 it is possible to observe that fuzzy sets for error
and chance in error is the range [-3 3] and from Fig. 4 the
range is [-5 5].
For the cart position controller the manipulation fuzzy sets
are the same from Fig. 4 meanwhile the error and the change in
error is shown in Fig. 5, where the range of values is [-10 10].
Fig.5. Fuzzy sets for error and change in error for
cart position.
![Page 3: Fuzzy, Neural and Neuro-Fuzzy Controllers for an Inverted Pendulum](https://reader037.vdocuments.site/reader037/viewer/2022100208/553b289c5503463a458b469e/html5/thumbnails/3.jpg)
Intituto Tecnológico y de Estudios Superiores de Monterrey, Intelligent Controll, Fall 2011, Monterrey, N.L. Mexico
3
Using the approach from section II.B and the fuzzy sets
from above the rule bases can be defined. For the pendulum
problem there are two inputs (Error, change in error) and
five linguistic values (Negative Large, Negative Small,
Zero, Positive Small, Positive Large) for each case of these,
there are at most 52
= 25 possible rules. The rule table for
the inverted pendulum for controlling the angle and the cart-
position is shown in Table II.
TABLE II
THETA AND CART POSITION RULE DATABASE
de
e NL NS Z PS PL
NL PL PL PL PS Z
NS PL PL PS Z NS
Z PL PS Z NS NL
PS PS Z NS NL NL
PL Z NS NL NL NL
The fuzzy controller for the angle of the pendulum and the
cart position are implemented using a Simulink block, where
the designed controllers are embedded. The simulation process
is shown in Fig. 6, the block diagram consist in a desired
position using a constant, then calculation of the error and
change in error that are the inputs for the fuzzy controller, next
the manipulation for the plant or the subsystem and finally the
actual position is provided for the feedback.
Fig.6. Block diagram of the controller simulation.
To test the performance of the system two disturbances are
added to the system, a change in the desired position from 0 to
3 meters of the cart (see Fig. 14) and a disturbance of 10
degrees in the angle of the pendulum (see Fig 17).
IV. NEURAL NETWORK CONTROLLER
Controlling a dynamical system means forcing it to behave
in some desired way. Once the desired goal is specified, the
design of the controller is dictated by the knowledge about the
plant and the data available [3]. A neural network can learn
from the dynamics of other controllers by adding a training
process to ANN architecture.
The training process of the ANN in this paper used the data
of the manipulation or output of the Fuzzy Controller and the
two input vectors that correspond to the error and change in
error, to the train the ANN. The objective of the training is that
the ANN has to adjust the bias and its weights using the back-
propagation algorithm and the MSE (Mean Square Error)
method to calculate the error each iteration of the regression
process. It can be observed that the ANN is able to
approximate the behavior of the manipulation signal of the
Fuzzy Controller successfully (see Fig. 7).
Fig.7. Output data of the Fuzzy Controller versus the
learning ANN response.
The ANN controller is then incorporated to the block
diagram of the Fig. 6 to simulate the system response. Then
the response of the system to a change in the desired position
and angle disturbances is shown in Fig. 15 and Fig. 18
respectively.
V. ANFIS CONTROLLER
A. Basic Principles of ANFIS
An alternative of controlling is the ANFIS (Adaptive
Network Fuzzy Inference System) Controller that uses a
routine for Sugeno-type fuzzy inference systems with a hybrid
learning algorithm to identify parameters of the Sugeno-type
fuzzy inferences. The hybrid method is a combination of the
least-square method and the back-propagation gradient descent
method for training the FIS membership function parameters
to emulate a given training data set [4].
B. Training the ANFIS Controller
The training process of the ANFIS controller was performed
in the ANFIS MATLAB Toolbox. The training data (see Fig
8) is a matrix that consists in the Error, change in error and the
output of the fuzzy controller, using this data the toolbox
generates a Sugeno-type fuzzy inference system that fixes the
parameters of the fuzzy sets with an hybrid optimization
algorithm. A value of desired minimum error of 0.01 is set
before the training process.
The learning process finishes if the number of epochs
![Page 4: Fuzzy, Neural and Neuro-Fuzzy Controllers for an Inverted Pendulum](https://reader037.vdocuments.site/reader037/viewer/2022100208/553b289c5503463a458b469e/html5/thumbnails/4.jpg)
Intituto Tecnológico y de Estudios Superiores de Monterrey, Intelligent Controll, Fall 2011, Monterrey, N.L. Mexico
4
selected for trained or while the desired error are reached (Fig.
9) the toolbox adjusts the Sugeno-type fuzzy inference system
with two inputs for the error and change in error and the
manipulation that consist in Sugeno functions. The ANFIS
controller training for the angle of the pendulum inputs are
shown in Fig.10 and Fig. 11 respectively.
Fig.8. ANFIS controller training data.
Fig. 9. ANFIS controller successfully training.
In Fig. 9 it is possible to see that the ANFIS training reaches
the desired error in a less number of epochs than ANN
learning.
Fig.10. Sugeno fuzzy sets resulting from ANFIS
Theta controller training for Error.
Fig.11. Sugeno fuzzy sets resulting from ANFIS training
for the change in Error.
Then for the cart position controller the process is the same
and the resulting fuzzy sets for Error and change in error is
shown in Fig. 12 and Fig. 13 respectively.
Fig.12. Sugeno fuzzy sets resulting from ANFIS cart position
controller training for the Error.
Fig.13. Sugeno fuzzy sets resulting from ANFIS cart position
controller training for the change in Error.
The ANFIS controller is then incorporated to the block
diagram of the Fig. 6 to simulate the system response. Then
the response of the system to a change in the desired position
and angle disturbances is shown in Fig. 16 and Fig. 19
respectively.
VI. SIMULATION RESULTS
The structure of the inverted pendulum system by Simulink
is shown in Fig.6, applying the dynamic model of the inverted
pendulum using the non-linear equation shown in Fig.2 and the
parameters given in Table I.
The simulations consist in two tests: (i) first a change in
reference is added to the desired of the cart position and the
(ii) second is a disturbance in the angle of the pendulum and
the cart reference position remains in a value of zero.
![Page 5: Fuzzy, Neural and Neuro-Fuzzy Controllers for an Inverted Pendulum](https://reader037.vdocuments.site/reader037/viewer/2022100208/553b289c5503463a458b469e/html5/thumbnails/5.jpg)
Intituto Tecnológico y de Estudios Superiores de Monterrey, Intelligent Controll, Fall 2011, Monterrey, N.L. Mexico
5
Fig.14. Fuzzy controller response to a change in the desired
reference where the solid line represents the theta position and
the dotted represents the cart position.
Fig.15. ANN controller response to a change in the desired
reference where the solid line represents the theta position and
the dotted represents the cart position.
Fig.16. ANFIS controller response to a change in the desired
reference where the solid line represents the theta position and
the dotted represents the cart position.
The test of changes in reference of Fig.14,15,16 shows that
the ANN and Fuzzy controllers has similar responses, but the
Fuzzy has lower oscillation levels in the manipulation of the
cart position than the Fuzzy controller, meanwhile the ANFIS
manipulation of the cart position has no overshooting.
Furthermore, Fuzzy and ANN controlled cart position in
similar time, which is around 15 to 16, meanwhile the ANFIS
controlled in lower time, which is a value around 4 to 5.
Fig.17. Fuzzy controller response to a disturbance in the
pendulum where the solid line represents the theta position
and the dotted represents the cart position.
Fig.18. ANN controller response to a disturbance in the
pendulum where the solid line represents the theta position
and the dotted represents the cart position.
Fig.19. Fuzzy controller response to a disturbance in the
pendulum where the solid line represents the theta position
and the dotted represents the cart position.
![Page 6: Fuzzy, Neural and Neuro-Fuzzy Controllers for an Inverted Pendulum](https://reader037.vdocuments.site/reader037/viewer/2022100208/553b289c5503463a458b469e/html5/thumbnails/6.jpg)
Intituto Tecnológico y de Estudios Superiores de Monterrey, Intelligent Controll, Fall 2011, Monterrey, N.L. Mexico
6
The test of disturbances in the angle of the inverted
pendulum of Fig.17,18,19 shows that the ANN and Fuzzy
controller has similar responses in the angle theta overshoot
value, which are certain of 2 and -2, meanwhile the ANFIS
controller has higher overshooting in the range of 10 and -10,
but this changes in the angle allows the ANFIS to control in
lower time than Fuzzy and ANN. The ANN and Fuzzy
controlled in time equal to 30 and the ANFIS controlled
approximately at time 15.
VII. CONCLUSION
This work presents the design of a Fuzzy, Neural and
ANFIS controllers for an inverted pendulum-cart system. A
non-linear model of the system has been considered to develop
the controllers. The response of the system with each
controller has been compared. These responses are shown in
section VI. From the simulation results, it is possible to
conclude that the three controllers can successfully stabilize
the inverted pendulum and also controls the cart at the desired
positions.
From the experimentation it is possible to conclude that the
ANFIS has the best performance due to the lower rate of
changes in the angle of the pendulum and the time that the
controller requires to stabilize both systems is smaller than the
Fuzzy and the ANN controllers.
Then it is possible to conclude that the ANFIS training
methodology obtain the best characteristics of both controllers
(Fuzzy and ANN) to optimize the system performance.
REFERENCES
[1] Passino K. M, “Fuzzy Control,” Menlo Park, Calif.:Addison-Wesley, pp
26-33, c1998.
[2] Driankov D.,”An introduction to fuzzy control,” Berlin: New York:
Springer, pp. 23-40, c1996.
[3] Hung T. Nguyen, “A first course in fuzzy and neural control,” Boca
Raton, FL: Chapman & Hall/CRC Press, c2003.
[4] Mathworks, “Advanced Fuzzy Inference Techniques: ANFIS,” [Online]
Matlab Documents [Access on date Dec 1, 2011].
http://www.mathworks.com/help/toolbox/fuzzy/anfis.html