实例:MATLAB/Simulink实现模糊PID控制

标签:
模糊pidmatlabsimulinkpid控制仿真 |
分类: 控制工程 |
被控对象:
Ts = 0.1;
Plant = c2d(zpk([],[-1 -3
-5],1),Ts);
%零极点模型,并离散化
C0 =
pid(1,1,1,'Ts',Ts,'IF','B','DF','B');
% 定义PID结构
C = pidtune(Plant,C0)
%对PID参数进行优化
[Kp, Ki, Kd] = piddata(C);
% 输出参数
得出PID结构及其参数值:
接下来根据求出的PID参数确定GCE、GE 、 GCU 和 GU的取值:
由模糊PID控制结构可得如下等式:
Kp = GCU * GCE + GU *
GE
Ki = GCU * GE
Kd = GU * GCE
形式转换如下:
GE = 10;
%根据模糊控制的论语直接确定
GCE =
GE*(Kp-sqrt(Kp^2-4*Ki*Kd))/2/Ki=3.4285;
GCU =
Ki/GE=2.8631;
GU = Kd/GCE=2.0138;
模糊PID控制系统结构(连续模糊控制器):图中的离散时间积分和微分块直接调用。
模糊控制器输入输出结构:
模糊控制器输入输出隶属度函数:
模糊控制器规则表:
模糊控制器规则曲面图:
http://s5/mw690/002nTqVZgy71A2tUINmf4&690连续模糊PID控制器,仿真结果:
http://s5/mw690/002nTqVZty71A2Vor4Ma4&690
模糊PID控制系统结构(离散模糊控制器):
http://s1/mw690/002nTqVZty71A1jQSf670&690
离散模糊控制器查询表:
离散模糊PID控制器,仿真结果:
主要代码如下:
(1)、对象模型:
Ts = 0.1;
Plant = c2d(zpk([],[-1 -3
-5],1),Ts);
(2)、PID参数优化:
C0 =
pid(1,1,1,'Ts',Ts,'IF','B','DF','B');
C =
pidtune(Plant,C0)
[Kp, Ki, Kd] =
piddata(C);
(3)、比例因子确定:
GE = 10;
GCE =
GE*(Kp-sqrt(Kp^2-4*Ki*Kd))/2/Ki;
GCU = Ki/GE;
GU = Kd/GCE;
(4)、连续模糊PID控制建立:
FIS =
newfis('FIS','sugeno');
%%
% 定义输入E:
FIS =
addvar(FIS,'input','E',[-10 10]);
FIS =
addmf(FIS,'input',1,'Negative','gaussmf',[7 -10]);
FIS =
addmf(FIS,'input',1,'Positive','gaussmf',[7 10]);
%%
% 定义输入CE:
FIS =
addvar(FIS,'input','CE',[-10 10]);
FIS =
addmf(FIS,'input',2,'Negative','gaussmf',[7 -10]);
FIS =
addmf(FIS,'input',2,'Positive','gaussmf',[7 10]);
%%
% 定义输出u:
FIS =
addvar(FIS,'output','u',[-20 20]);
FIS =
addmf(FIS,'output',1,'Min','constant',-20);
FIS =
addmf(FIS,'output',1,'Zero','constant',0);
FIS =
addmf(FIS,'output',1,'Max','constant',20);
% 定义规则:
%
% # If |E|
is Negative and |CE| is Negative then |u| is -20
% # If |E|
is Negative and |CE| is Positive then |u| is 0
% # If |E|
is Positive and |CE| is Negative then |u| is 0
% # If |E|
is Positive and |CE| is Positive then |u| is 20
ruleList =
[1 1 1 1 1;... % Rule 1
FIS =
addrule(FIS,ruleList);
gensurf(FIS)
%生成模糊控制器
(5)、离散模糊控制器查询表:
Step =
2;
E = -10:Step:10;
CE = -10:Step:10;
N = length(E);
LookUpTableData = zeros(N);
for i=1:N
end