You are on page 1of 16

EE4305 Lab Report:

Design and Implementation of a Fuzzy Logic Controller


Phang Swee King
U066584J
October 9, 2009

1 Objectives
I. To design a fuzzy controller using Matlab, Simulink and Fuzzy Logic Toolbox.
II. Real-time imlementation of the fuzzy controller upon a liquid coupled-tank system.
III. To gain experience in constructing fuzzy membership functions and fuzzy rules.

4 Experiment
4.1 Fuzzy Control Simulation

Figure 1: Initial Closed-loop Response of the System

From Figure 1, the closed-loop response shows that the initial fuzzy controller with basic three rules cannot
satisfy the performance of the controller behaviour. Another input, the water level’s rate of change, is added

1
as shown in Figure 2 below. The range of the water level’s rate of change is modified to [-0.1 0.1] for a
more accurate control. In addition, a derivative block is added in the block diagram of the system as shown
in Figure 3 below.

Figure 2: FIS Editor of the System

Figure 3: Block Diagram of the System

2
First Tuning
1. The membership functions of the water level’s rate are named falling, steady, and rising.
2. Two membership functions close slowly and open slowly are added to the output of the system.
3. Two rules are added:

(a) If Level is okay and rate is falling then valve is open slowly.
(b) If Level is okay and rate is rising then valve is close slowly.
The controller shown a better response with no overshoot (Figure 4).

Figure 4: Closed-loop Response of the Tuned System

Second Tuning
1. Changes made in water level’s input to broaden up the range of high and low.

According to Figure 5, the system’s rise time is slightly improved, however overshoot occurs due to the
changes. The system is further fine tuned in the next section.

3
Figure 5: Closed-loop Response of the Tuned System

Third Tuning

To eliminate the overshoot, the rules are modified.


1. Nine rules are added/modified to cover the entire input space.
(a) If Level is okay and rate is falling then valve is open slowly.
(b) If Level is okay and rate is rising then valve is close slowly.
(c) If Level is okay and rate is steady then valve is no change.
(d) If Level is high and rate is falling then valve is close slowly.
(e) If Level is high and rate is rising then valve is close fast.
(f) If Level is high and rate is steady then valve is close fast.
(g) If Level is low and rate is falling then valve is open fast.
(h) If Level is low and rate is rising then valve is open slowly.
(i) If Level is low and rate is steady then valve is open fast.

4
Figure 6: Closed-loop Response of the Tuned System

Observing Figure 6, the system shows no overshoot, however, the rise time of the system increases.

Final Tuning
1. The rules are generalized as follows:

(a) If Level is high then valve is close fast.


(b) If Level is low then valve is open fast.
In this adjustment, regardless of the rate change of the water level, the valve will open/close faster to re-
duce the time taken to reach steady state. The final system response is relatively improved compare to the
previous tuning with zero steady state error, fast rise time, fast settling time, and no overshoot.

The final system response is plotted in Figure 7, together with the rule viewer (Figure 8), membership
functions (Figure 9 - 11) and the surface viewer (figure 12).

5
Figure 7: Closed-loop Response of the Tuned System

Figure 8: Rule Viewer of the System

6
Figure 9: Membership Function of the Input Level

Figure 10: Membership Function of the Input Rate

7
Figure 11: Membership Function of the Output

Figure 12: Surface Viewer of the System

8
4.2 On-line Implementation
4.2.2 Calibration
A. Level Sensor

Figure 13: Calibration of Level Sensor

B. Discharge Coefficient (alpha)

Figure 14: Calibration of Discharge Coefficient

9
4.2.3 Real-Time Fuzzy Control (Single-Input Single-Output)
The initial system response is shown in Figure 15. It has a large overshoot (≈ 25%), long rise time (≈
60 units), long settling time (≈ 250 units) and large steady state error (≈ 10%).

Figure 15: Initial System Response of the System

First Tuning

As the initial system was running, it can be observed that the overshoot of the system is mainly due to
the dominance of Positively Large function in err (Water Level) input even when the output has almost
reached the desired output. Hence, to reduce the overshoot, membership functions of Positively Large and
Zero in err are shifted to the right as shown in figure 16 to increase the influence of Zero when the output
is near steady state.

The new system response (Figure 17) shows a reduced overshoot (≈ 5%) as predicted.

10
Figure 16: Membership Function of err Input after First Tuning

Figure 17: System Response after First Tuning

11
Final Tuning

In order to reduce the rise time and settling time, the range of Positively Large and Negatively Large input
in Derr (Rate) are increased in order to increase the dominance of Positively Large and Negatively Large in
output. The increase usage of Positively Large output is able to improve the rise time and settling time by
pumping more water into the tank at a longer time.

Figure 18 to 20 shows the final membership function of err and Derr together with the final system re-
sponse. From the system response, it has a lower overshoot(≈ 5%), shorter rise time (≈ 50 units), shorter
settling time (≈ 110 units) and smaller steady state error (≈ 5%). The overall system response is improved.

Figure 18: Membership Function of err Input after Final Tuning

12
Figure 19: Membership Function of Derr Input after Final Tuning

Figure 20: System Response after Final Tuning

13
4.2.4 PID for Real-Time Control (Single-Input Single-Output)
The preset values of the PID controller parameters are as follows:

𝐾𝑝 = 0.5
𝐾𝑑 = 0.025
𝐾𝑖 = 0.1

Step response of the system is plotted in Figure 21. The system has a high overshoot (> 50%), slow rise
time (≈ 60 units), slow settling time (≈ 260 units) and moderate steady state error (≈ 5%)

Figure 21: Initial System Response

First Tuning

It is observed that during the first overshoot period of the initial system, integral output is dominant
with the largest value among the three different controllers. Hence, to reduce the overshoot, the integral
gain is reduced to
𝐾𝑖 = 0.005
Step response of the system is plotted in Figure 22. The system now has a much lower overshoot (≈ 5%).
Not only the changes reduce overshoot, it produce a faster settling time (≈ 70 units).

14
Figure 22: System Response of First Tuning

Final Tuning

In order to improve the rise time, the propotional gain of the controller is raise to
𝐾𝑝 = 2

Figure 23: System Response of Final Tuning

15
Step response of the system is plotted in Figure 23. The final system has a lower overshoot (≈ 5%), faster
rise time (≈ 50 units), faster settling time (≈ 60 units) and moderate steady state error (≈ 5%). The overall
performance of the system is significantly improved.

5 Discussions
I. On Matlab simulation, by observing the dominance of the fuzzy membership functions, the desired
transient response of the system can be tuned easily with some experience. However, in the real
world system, although the system can be tuned with similar way, it is harder to reach the desired
specifications. The system response might even change overtime due to wear and tear of the equipments
and the sensitivity of the sensors. Results of that, a similar system might run differently when it is
executed in different time.
II. The tuning of the fuzzy membership function is straight forward. The changes needed to make for
a better closed-loop transient and steady state performance can be easily predicted by observing the
dominance of membership functions from the inputs and outputs. Take one example from this ex-
periment, to increase the rise time, as observed, can be done by expanding the range of membership
function of Low in water Level such that the system would push the output to open fast at a longer
time and hence increases rise time.
III. Theoritically, both fuzzy and PID controllers can be manually tuned to satisfy transient performances
such as rise time and overshoot. However, implementation wise, fuzzy controller allow a more user-
friendly tuning, whereas the tuning of PID controller need certain experience in order to obtain the
desired results effectively. Users can easily tune a fuzzy controller based on some observation and
logical thinking.

6 Conclusions
I. Designing a fuzzy controller in real-time implementation is relatively more difficult than using Matlab
simulation due to uncertainties such as wear and tear.
II. Fuzzy controller can be tuned intuitively and easily. It is relatively easier to fine tune compare to PID
controller.

16

You might also like