fuzzy lab#1 udara ver 2
TRANSCRIPT
School Of Electrical Engineering
Victoria University of Technology
VEA 4200- FUZZY CONTROL AND APPLICATIONS
LAB 1: Fuzzy Controller Design Using MATLAB Fuzzy Logic Toolbox
Name: Udara Sampath
Almeida
Student ID: 3771873
Fuzzy Control and Applications
Laboratory Report 1
Contents
1. Preliminary..........................................................................................................3
2. Simulink construction of the uncompensated system.......................4
3. Controller design..............................................................................................6
4. Compensated system using a PID controller.........................................8
5. Fuzzy logic controller design.....................................................................10
6. Conclusion.........................................................................................................13
2 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
1. Preliminary
For the unity feedback system shown in the following figure, the plant transfer function is
given as Gp (s )=
40(s+2)( s+4 ) , the controller Gc(s) is to be designed.
1. For the above system, with Gc(s) =1, calculate the maximum percentage overshoot, settling time, and the steady-state error for a unit step input.
2. For a unit step input, design a conventional controller Gc(s) such that the compensated system is to have
A maximum percentage overshoot of less than 5%,
The settling time of no more than half of that of the system with Gc(s) =1.
Steady-state error is zero.
The closed loop transfer function for the system shown above is:
CLTF=G c(s ) .G p( s )
1+Gc( s ).Gp (s )=
40( s+2 )(s+4 )
1+40(s+2)( s+4 )
=40s2+6 s+48
Damping ratio ( ζ ) and Natural frequency ( ωn )can be find out using the following equations:
3 | P a g e
GC(s) GP(s)
Fuzzy Control and Applications
Laboratory Report 1
CLTF=K .ωn
2
s2+2 ζωns+ωn2=
40
s2+6 s+48
ωn=6 . 92rad /s
ζ=0 .433
Settling time:
T s=4ζ .ωn
= 40 . 433×6 .92
=1 . 335 s
Maximum percentage overshoot:
%OS=100×e−ζπ
√1−ζ 2
=100×e−0 . 433π
√1−0 .4332
%OS=22 %
Steady state error:
ess=estep (∞)=11+k p
k p=lims→0G(s )= lim
s→0
40(s+2)( s+4 )
=5
ess=11+k p
=0 .166
2. Simulink construction of the uncompensated system
Figure 1 shows the Simulink model of the uncompensated system. Then this system is further analysed by using MATLAB’s “rltool” toolbox and the simulated results confirms the above calculated results.
4 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
According to the Figure 2, Maximum percentage overshoot of the system was 22.1%, settling time was 1.21ms and the steady state error was 0.166. (1-0.833=0.166)
Fig 1. Uncompensated system
5 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
Fig 2. Step response for the uncompensated system
3. Controller design
There are three requirements in the design from the preliminary:
a maximum percentage overshoot of less than 5%,
the settling time of no more than half of that of the system with Gc(s) =1.
steady-state error is zero
A Proportional Integral Controller (PID) can be used for the design since it is the most effective.The PID controller is employed in control systems in which improvements in both the transient response and the steady-state response are required. The transfer function of the PID controller is given by:
Gc( s )=K P+K Is
+K D s=K D s
2+K P s+K Is
Calculate the damping ratio for maximum percentage overshoot of 5%:
%OS=5=100×e−ζπ
√1−ζ2
=100×e−ζπ
√1−ζ2
log e0 . 05=−ζπ
√1−ζ2
ζ=0 .69
θ=cos−1ζ=cos−1 0 . 69=46 .36∘
Settling time:
T s 1=4ζωn
T s 1→12T s
T s 1=1 .3352
=40 . 69×ωn
ωn=8 .68 rad /s
6 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
New Closed loop poles:
s1,2=−ζωn± jωn(√1−ζ 2)
s1,2=−0 .69×8 . 68± j 8. 68√1−0 . 692
s1,2=−5 .98± j6 . 28s1=−5 . 98+ j 6 .28=8 . 671∠133 . 59∘
β=133 . 59
s1=|s1|.ejβ=8 .671e j 133.59
Gp (s1 )H ( s1 )=|Gp (s1)H ( s1 )|ejϕ
Gp (s1 )H ( s1 )=40(−5. 98+ j6 . 28+2 )(−5 . 98+ j6 . 28+4 )
=0 . 818∠−229 . 86
Gp (s1 )H ( s1 )=0. 818e− j229.86
ϕ=−229.86
Calculate KP and KD in terms of KI:
K P=−sin( β+ϕ )|Gp (s1 )H ( s1)|sin( β )
−2K I cos( β )|s1|
=1 .679+0. 159K I
K D=sin (ϕ )|s1||Gp (s1 )H ( s1 )|sin( β )
+K I|s1|
2=0.148+0 .0133K I
7 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
4. Compensated system using a PID controller
Fig 3. Conventional compensation using a PID controller
In the previous chapter we have found out the KP and KD values in terms of KI.
KD = 0 .148+0 . 0133K I
KP = 1 .679+0.159K I
Let us assume values for KI and find the corresponding KP and KD values;
KI KP KD
0.1 1.694 0.149
1 1.838 0.161
1.5 1.91 0.168
Table 1. KP, KD AND KI values
8 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
Fig 4. Step response after the compensation
Fig 5. Percentage overshoot value
9 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
Fig 6. ±5% Settling time
Fig 4, Fig 5 and Fig 6 graphs clearly shows that when KI = 1 the system meets the following requirements;
Steady state error is zero. Maximum percentage overshoot is well below 5%. Settling time is much faster and within the required range. (0.3191s)
5. Fuzzy logic controller design
There are four main components the fuzzy controller is made up of;
1. The “rule-base”, which holds the knowledge which suits the best to control the system, in the form of a set of rules.
2. The inference mechanism, which evaluates which control rules are suitable for the current time and then decides the input for the plant.
3. The fuzzification interface, which simply modifies the inputs so that they can be interpreted and compared to the rules in the rule-base.
4. The defuzzification interface, which converts the conclusions reached by the inference mechanism into the inputs to the plant.
10 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
Fig 7. Fuzzy controller architecture
Fuzzy logic toolbox of the MATLAB/Simulink has used to create a fuzzy logic controller for the given system.A PD fuzzy controller and a PI fuzzy controller was linked together by a summing junction to design the PID fuzzy controller.
Fig 8. PID fuzzy controller block diagram
11 | P a g e
Fuzzy Control and Applications
Laboratory Report 1
A block of unit delay was used to create the change of error input for the fuzzy controller. The value of the unit delay was set to 0.1s since the settling time of the system was approximately 0.6s. (for a better sampling rate)
Setting up the Rules:
We can now construct the rule table for the Fuzzy Logic Controller by use of linguistic variables. The following shows an example how a human can analyze the system and come up with a list of rules.
For example if the “error is Negative Big” (NB) and “change in error is Negative Big” (NB) then we know that the error is big and is increasing very quickly. This means we need to bring the error back to zero as quick as possible. This is done by apply a “Negative Big “force (NB) from the Fuzzy Logic Controller.
Once again if the “error is Negative Big” (NB) but this time the “change in error is Positive Small” (PS) this means that the error is still large but the error is decreasing very slowly. The force needed is “Negative Small” (NS) because the error is already decreasing.
Table 2, shows the rule table used for the fuzzy controller;
Table 2. Rule table
12 | P a g e
CHANGE IN ERROR
NB NS Z0 PS PB
NB NB NB NB NS Z0
NS NB NB NS Z0 PS
ERROR Z0 NB NS Z0 PS PB
PS NS Z0 PS PB PB
PB Z0 PS PB PB PB
Fuzzy Control and Applications
Laboratory Report 1
Fig 9. PD & PID fuzzy controller step response
The conventional controller was designed to meet the specifications using PID controller method. On the other hand, fuzzy controller was also designed to approach the same specifications. The role of modeling in fuzzy control design is quite similar to its role in conventional control system design. In fuzzy control more significance is given to the use of linguistic variables but in many control approaches (e.g., PID control for process control) there is a different emphasis because in fuzzy control we use rules to represent how to control the plant instead of ordinary differential equations.
6. Conclusion
This laboratory helped understand the differences between a conventional controller and fuzzy controller.The different controllers meet the required specifications showing similar performance since both remained within 5% overshoot, they both had a steady state error is zero. Similarly the (±5%) setting time for the conventional controller is about 0.3191 seconds and with the fuzzy controller is about 0.62 second.
13 | P a g e