You are on page 1of 7

Simple Inverted Pendulum

Assignment 4

Jean Mouawad

A report submitted Dr.Issam Dagher, in partial fulfillment to the requirement of the


Fuzzy Logic course for fall 2018

Faculty of Engineering
University of Balamand

October 2018
_____________________________________________________________________________________

Copyright 2018
All Right Reserved, Jean Mouawad
Matlab Simulation

Figure 1: Input 1

A range is set between -2 and 2; with 3 membership functions ‘N’, ‘Z’ & ‘P’.

1. The same is done for input 2 ‘X2’

Figure 1: Input 2
2. As for the output ’U’, we set a range of -8 to 8 with 5 membership functions shown in figure

4.

Figure 2: output "U"

3. The figure below represents the rules set:

Figure 3: Rules set

4. We set the rules according to the table below, to relate the inputs to the outputs.
Table 1: Table rules

X X2 N Z P
1
N NB N Z
Z N Z P
P Z P PB
5. Simulink configuration (Method #1)

Figure 4: Simulink configuation

6. After we get save the fuzzy system then calling it back with a variable, we open Simulink with

a new model and build the following block diagram.

Two discrete space models both with input ‘U’ from the fuzzy system.

7. Result:

We set and abs value in Fcn to stop the simulation and we can save our data in the workspace.

Here are the results if we set

 X (1) = [1 1], X (2) = [0 0]

 Stop time = 2s
Time Series Plot:
8

d a ta
2

-2

-4
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (seconds)

Figure 5: Output

6.2 Method#2: Simulink configuration using differential equation


(Note: the system took 10 iterations before the inverted pendulum reached the equilibrium
position, here x1=0 and x2=0, as well as u.)

Figure 6: create a subsystem


Figure 7: simulink configuration using differential equation

Output:

1 -2.5257 -1 -1
2 0.0451 -0.0178 0.0335
3 -0.0150 0.0055 -0.0106
4 0.0141 -0.0051 0.0099
5 -0.0132 0.0048 -0.0093
6 0.0025 -9.000e-04 0.0017
7 -7.000e-04 2.000e-04 -5.000e-04
8 2.000e-04 -1.000e-04 2.000e-04
9 -2.000e-04 1.000e-04 -2.000e-04
10 1.000e-04 0 1.000e-04
I. Conclusion
The power of Matlab and Simulink becomes nowadays more evident to one as all these

designing would not have been possible without these tools.

The practical implementation of the controller familiarizes on with the use of analog computers

and their importance in the field of Control Engineering.

You might also like