Lecture 11
Introduction to Neural Networksand Fuzzy Logic
President University Erwin Sitompul NNFL 11/1
Dr.-Ing. Erwin SitompulPresident University
http://zitompul.wordpress.com2 0 1 4
President University Erwin Sitompul NNFL 11/2
outq
inq
h
Single Tank System2
2
,max
0.4 m0.012 m20 si
Aa
q l
A : cross-sectional area of the tanka : cross-sectional area of the pipe
Desired liquid level:5 cm (0.05 m)
LI
FV
Required inflow rate: ?0.0119 m3/s (11.9 l/s)
Fuzzy ControlFuzzy Logic
in1 2ah q ghA A
President University Erwin Sitompul NNFL 11/3
Single Tank System: 3 Rules
Liquid level [cm]0 1 5 9 14
okay highlow1
Valve control signal [%/s]
no change open fastclose fast
–30 –10 0 10 30
1
FC with 3 Rules
Desired liquid level
Fuzzy ControlFuzzy Logic
Rule 1: IF level is okay, THEN valve is no change.Rule 2: IF level is low, THEN valve is open fast.Rule 3: IF level is high, THEN valve is close fast.
President University Erwin Sitompul NNFL 11/4
Single Tank System: 3 Rules
Liquidlevel
Valvecontrolsignal
Valveopening
Simulation in Simulink
Fuzzy ControlFuzzy Logic
President University Erwin Sitompul NNFL 11/5
Single Tank System: 3 Rules
Subsystem Valve Subsystem Single-Tank
• Double-click a subsystem block to see the elements inside
Fuzzy ControlFuzzy Logic
President University Erwin Sitompul NNFL 11/6
Fuzzy Logic Controller in SimulinkFuzzy ControlFuzzy Logic
In Matlab workspace, design the fuzzy controller using fuzzy inference system (FIS) editor.
Export the fuzzy logic controller to workspace, give name.File > Export > To Workspace, (i.e. : STFC_3)
In Simulink, create a new model. Open the Fuzzy Logic Toolbox and
drag “Fuzzy Logic Controller” to the new model.
Double-click the “FLC” and insert the name given to the controller above.
President University Erwin Sitompul NNFL 11/7
Single Tank System: 3 Rules
“overshoot” too large
slow response
Evaluation
Fuzzy ControlFuzzy Logic
President University Erwin Sitompul NNFL 11/8
Valve control signal [%/s]
no c
hang
e
open
fast
close
fast
–30 –20 –10 0 10 20 30
1 open
slow
close
slow
Rate of liquid level [cm/s]
zero positivenegative
–4 –0.5 0 0.5 4
1
Single Tank System: 5 Rules
Liquid level [cm]0 1 5 9 14
okay highlow1
Fuzzy ControlFuzzy Logic
President University Erwin Sitompul NNFL 11/9
Single Tank System: 5 Rules
FC with 5 Rules
no c
hang
e
0 1 5 9 14 –4 –0.5 0 0.5 4Valve control signal [%/s]
–30–20 –10 0 10 20 30Liquid level [cm] Rate of liquid level [cm/s]
okay highlow1
zero positivenegative1 op
en fa
st
close
fast
open
slow
close
slow
1
Fuzzy ControlFuzzy Logic
Rule 1: IF level is okay, THEN valve is no change.Rule 2: IF level is low, THEN valve is open fast.Rule 3: IF level is high, THEN valve is close fast.Rule 4: IF level is okay AND rate is negative,
THEN valve is open slow.Rule 5: IF level is okay AND rate is positive,
THEN valve is close slow.
President University Erwin Sitompul NNFL 11/10
FIS Editor SimulinkSingle Tank System: 5 Rules
Fuzzy ControlFuzzy Logic
President University Erwin Sitompul NNFL 11/11
With all other factors stay the same, a better fuzzy control behavior and performance can be achieved by the combination of:Redefining existing
membership functions.Refining existing rule.Adding new membership
functions and new rules.
Single Tank System: 5 Rulesacceptable “overshoot”
faster response
Fuzzy ControlFuzzy Logic
Liquidlevel
Valvecontrolsignal
Valveopening
President University Erwin Sitompul NNFL 11/12
outq
inq
h
Single Tank System: Feedback Control
LI
FVSet point
r +–Error
e
Fuzzy ControlFuzzy Logic
How if the desired liquid level should be changed to 10 cm? 7 cm? 12 cm?
Practical solution: Error signal as the input to the fuzzy controller.
Measured variabley
President University Erwin Sitompul NNFL 11/13
Valve control signal [%/s]
no c
hang
e
open
fast
close
fast
–30 –20 –10 0 10 20 30
1 open
slow
close
slow
Rate of error [cm/s]
zero positivenegative
–4 –0.5 0 0.5 4
1
Single Tank System: Feedback Control
Error of liquid level [cm]–10 –2 0 2 10
zero positivenegative1
e > 0e < 0
Fuzzy ControlFuzzy Logic
e < 0. e > 0.
President University Erwin Sitompul NNFL 11/14Method SettingsReference trajectory
0 40 80 120
r [cm]
654
t [s]
Fuzzy ControlFuzzy Logic
Homework 10 Implement the fuzzy logic
controller as a feedback control for the single tank system in Matlab-Simulink.
Apply the 5 rule version with the corresponding membership functions.
Test the control loop to follow the reference trajectory as shown below.
President University Erwin Sitompul NNFL 11/15
Fuzzy ControlFuzzy Logic
Homework 10A A DC motor is a common actuator in control system. The
input to this device is a voltage given in Volt and the output is the rotation speed given in rad/s.
The electric circuit of a DC motor and its rotor is shown on the lower left figure.
A model of the DC motor in Matlab Simulink is also provided, as shown through the lower right figure.
President University Erwin Sitompul NNFL 11/16
In case there is no load change, the DC motor will rotate with a constant speed.
If the load is changed, the supplied voltage must be adjusted so that adequate current may flow and the desired rotation speed can be achieved.
Design a fuzzy logic control that will maintain the motor to rotate with the velocity of Student-ID/10 rad/s.
Embed the controller in the Matlab-Simulink file.
Submit the softcopy (*.fis, *.mdl) and the hardcopy (screenshots of *.fis, *.mdl and scope)
Homework 10AFuzzy ControlFuzzy Logic