1. Software version
matlab2013b
2. Theoretical knowledge of this algorithm
Here, the distance is explained according to the basic work of the fuzzy controller , It is assumed that this system is a temperature control system .
first : Fuzzification process
surface 1 Membership function of fuzzy set
error e
-50
-30
-15
-5
0
5
15
30
50
Error rate de
-150
-90
-30
-10
0
10
30
90
150
control u
-64
-16
-4
-2
0
2
4
16
64
Quantification level
-4
-3
-2
-1
0
1
2
3
4
state variable
Related membership function
PB
0
0
0
0
0
0
0
0.35
1
PS
0
0
0
0
0
0.4
1
0.4
0
ZE
0
0
0
0.2
1
0.2
0
0
0
NS
0
0.4
1
0.4
0
0
0
0
0
NB
1
0.35
0
0
0
0
0
0
0
Fuzzy rules :
Fuzzy control rules are essentially a set of fuzzy conditional statements obtained by summarizing the control experience of operators . The principle of determining fuzzy control rules is to ensure that the output of the controller can optimize the dynamic and static characteristics of the system output response .
Here is an example , The rules satisfied are :
rule 1: If error e yes NB, And the error changes de yes PB, Then control U by PB;
rule 2: If error e yes NB, And the error changes de yes PS, Then control U by PB;
rule 3: If error e yes NB, And the error changes de yes ZE; Then control U by PB;
rule 4: If error e yes NB, And the error changes de yes NS, Then control U by PB;
rule 5: If error e yes NS, And the error changes de yes ZE, Then control U by PS;
rule 6: If error e yes NS, And the error changes de yes PS, Then control U by ZE;
rule 7: If error e yes NS, And the error changes de yes PB, Then control U by NS;
rule 8: If error e yes ZE, And the error changes de yes ZE, Then control U by ZE;
rule 9: If error e yes ZE, And the error changes de yes PS, Then control U by NS;
rule 10: If error e yes ZE, And the error changes de yes PB, Then control U by NB.
rule 11: If error e yes NS, And the error changes de yes NS, Then control U by PS;
rule 12: If error e yes NS, And the error changes de yes NB, Then control U by PB;
rule 13: If error e yes ZE, And the error changes de yes NS, Then control U by PS;
rule 14: If error e yes ZE, And the error changes de yes NB, Then control U by PB.
Thus, the fuzzy rule table is :
U
NB
NS
ZE
PS
PB
NB
PB
PB
PB
PS
NB
NS
PB
PS
PS
ZE
NB
ZE
PB
PS
ZE
NS
NB
PS
PB
ZE
NS
NS
NB
PB
PB
NS
NB
NB
NB
second : Fuzzy reasoning process
Set systematic error e The quantized value of is l, Error variation de The quantized value of is -2 .
The non-zero membership function can be obtained as :
error e :μZE(1)= 0.2 μps(1)= 0.4;
Error variation de : μNS(-2)= 1
Only the following two rules are valid
If error e yes ZE, And the error changes de yes NS, Then control U by PS;
If error e yes PS, And the error changes de yes NS, Then control U by ZE;
third : Clarity process
The output fuzzy set of the control quantity obtained by the minimax reasoning method is
μps(1,-2)=min(0.2,1)= 0.2
μZE(1,-2)=min(0.4,1)= 0.4
The above is the working process of fuzzy control system .
3. Partial source code
here , According to the input and output requirements in the subject , All definitions NB,NS,Z,PS,PB, The membership function we will use here is trimf Function of type . Membership functions are as follows :
That is, what is selected here is NB,NS,Z,PS,PB These five types of membership functions .
The rule table here is :
NB
NS
Z
PS
PB
NB
NB
NB
NB
NS
Z
NS
NB
NB
NS
Z
PS
Z
NB
NS
Z
PS
PB
PS
NS
Z
PS
PB
PB
PB
Z
PS
PB
PB
PB
According to the basic structure of inverted pendulum :
In actual work , angle 1 It will shake back and forth for adjustment , angle 2 It is relatively stable in one position . So as to achieve balance .
We build the following model :
4. Simulation conclusion
You can see through simulation , The error and error change rate of fuzzy control are :
angle 1 And angle 2 The simulation of is as follows :
Membership functions are as follows :
Surface As shown below :
The simulation results are as follows :
Through simulation , Finally, we can see that the final error of this system is -0.33, The change rate of error is 0.
Through simulation , The output results of the comparison controller can be obtained as follows :
According to the above simulation results , The convergence speed of the signal after passing the fuzzy controller is fast , And there is almost no overshoot .
A28-04
Technology