实验二:调节器参数变化对控制过程的影响

选取一阶惯性环节加滞后环节建模,通过实验测试法获取传递函数参数。
tau=35;
T=37;
K=0.64;
s=tf('s');
W=exp(-s*tau)*K/(T*s+1);
Ts=1;
W=c2d(W,Ts);
%use the state-space representation for more efficient modeling of discrete-time delays
W=ss(W);

不同控制器比较

比较纯比例,PI,PD,PID控制器的控制效果
C={'开环','P','PI','PD','PID'};
ess=zeros(1,5);
figure()
hold on;
t=1:600;
stepplot(W,t);
y=step(W,t);
info=stepinfo(y,t);
s=repmat(info,1,5);
ess(1)=1-y(end);
%pid反馈控制
for i=2:5
Gc=pidtune(W,C{i});
Gc=pidstd(Gc);
Phi=feedback(series(Gc,W),1);
stepplot(Phi,t);
y=step(Phi,t);
s(i)=stepinfo(y,t);
ess(i)=1-y(end);
end
legend(C+"控制")
grid;xlabel("时间/s");ylabel("幅度")
title("过程对象控制效果仿真");
T = table( ...
[s.RiseTime]',[s.PeakTime]',[s.SettlingTime]', ...
[s.Overshoot]',ess',...
'VariableNames',{'上升时间','峰值时间','调节时间','超调量','稳态误差'},...
'RowNames',C');
display(T)
T = 5×5 table
 上升时间峰值时间调节时间超调量稳态误差
1 开环81.2981600179.747000.3600
2 P14.072679567.026373.33010.3914
3 PI42.2625115237.685710.13510
4 PD0.713869594.600693.66990.3509
5 PID40.3500107212.80118.49150
Gc1=pidtune(W,"P");
Phi1=feedback(series(Gc1,W),1);
%pid反馈控制
for i=3:4
figure()
hold on
stepplot(Phi1,t,'k-.');
Gc=pidtune(W,C{i});
Gc=pidstd(Gc)
Phi=feedback(series(Gc,W),1);
stepplot(Phi,t,'k-');
legend("纯比例控制",C(i)+"控制")
grid;xlabel("时间");ylabel("幅度");
title("纯比例控制与"+C(i)+"控制效果比较")
end
Gc = 1 Ts Kp * (1 + ---- * ------) Ti z-1 with Kp = 1.3, Ti = 49.9, Ts = 1 Sample time: 1 seconds Discrete-time PI controller in standard form
Gc = z-1 Kp * (1 + Td * ------) Ts with Kp = 2.51, Td = 17, Ts = 1 Sample time: 1 seconds Discrete-time PD controller in standard form
figure()
hold on;
specs="k"+["--","-.","-"];
pids=["P","PI","PID"];
for i=1:3
Gc=pidtune(W,pids(i));
Gc=pidstd(Gc);
Phi=feedback(series(Gc,W),1);
stepplot(Phi,t,specs(i));
end
legend("纯比例控制","PI控制","PID控制")
grid;xlabel("时间");ylabel("幅度");
title("控制效果比较")

不同控制器参数比较

使用自带函数整定PID控制器
Gpid=pidtune(W,"PID");
Gpid=pidstd(Gpid)
Gpid = 1 Ts z-1 Kp * (1 + ---- * ------ + Td * ------) Ti z-1 Ts with Kp = 1.46, Ti = 50.5, Td = 4.18, Ts = 1 Sample time: 1 seconds Discrete-time PID controller in standard form

增大或减小比例度

Pi=1/Gpid.Kp;
Pi_inc=Pi*1.5;
Pi_dec=Pi*0.5;
figure();hold on;
Phi=feedback(series(Gpid,W),1);
Phi1=feedback(series(pidstd(1/Pi_inc,Gpid.Ti,Gpid.Td,Inf,Ts),W),1);
Phi2=feedback(series(pidstd(1/Pi_dec,Gpid.Ti,Gpid.Td,Inf,Ts),W),1);
stepplot(Phi,"k-",t);
stepplot(Phi1,"k-.",t);
stepplot(Phi2,"k:",t);
grid;xlabel("时间");ylabel("幅度");
title("增大或减小比例度");
label=[
sprintf("比例度Pi=%.2f",Pi);
sprintf("增大比例度至Pi=%.2f",Pi_inc);
sprintf("减小比例度至Pi=%.2f",Pi_dec)
];
legend(label)
T=[struct2table(stepinfo(Phi));struct2table(stepinfo(Phi1));struct2table(stepinfo(Phi2))];
T.Properties.RowNames=label;
T
T = 3×9 table
 RiseTimeTransientTimeSettlingTimeSettlingMinSettlingMaxOvershootUndershootPeakPeakTime
1 比例度Pi=0.68412132130.90881.08498.491001.0849107
2 增大比例度至Pi=1.03972582580.90121001709
3 减小比例度至Pi=0.34179529520.39121.758675.857001.758682

增大或减小积分时间常数

Ti=Gpid.Ti;
Ti_inc=Ti*1.5;
Ti_dec=Ti*0.5;
figure();hold on;
Phi=feedback(series(Gpid,W),1);
Phi1=feedback(series(pidstd(Gpid.Kp,Ti_inc,Gpid.Td,Inf,Ts),W),1);
Phi2=feedback(series(pidstd(Gpid.Kp,Ti_dec,Gpid.Td,Inf,Ts),W),1);
stepplot(Phi,"k-",t)
stepplot(Phi1,"k-.",t)
stepplot(Phi2,"k:",t);
grid;xlabel("时间");ylabel("幅度");
title("增大或减小积分时间常数")
label=[
sprintf("积分时间常数Ti=%.2f",Ti);
sprintf("增大积分时间常数至Ti=%.2f",Ti_inc);
sprintf("减小积分时间常数至Ti=%.2f",Ti_dec)];
legend(label)
T=[struct2table(stepinfo(Phi));struct2table(stepinfo(Phi1));struct2table(stepinfo(Phi2))];
T.Properties.RowNames=label;
T
T = 3×9 table
 RiseTimeTransientTimeSettlingTimeSettlingMinSettlingMaxOvershootUndershootPeakPeakTime
1 积分时间常数Ti=50.50412132130.90881.08498.491001.0849107
2 增大积分时间常数至Ti=75.75593623620.84840.9997000.9997849
3 减小积分时间常数至Ti=25.25306096090.65121.630063.002801.6300110

增大或减小微分时间常数

Td=Gpid.Td;
Td_inc=Td*1.5;
Td_dec=Td*0.5;
figure();hold on;
Phi=feedback(series(Gpid,W),1);
Phi1=feedback(series(pidstd(Gpid.Kp,Gpid.Ti,Td_inc,Inf,Ts),W),1);
Phi2=feedback(series(pidstd(Gpid.Kp,Gpid.Ti,Td_dec,Inf,Ts),W),1);
stepplot(Phi,"k-",t)
stepplot(Phi1,"k-.",t)
stepplot(Phi2,"k:",t);
grid;xlabel("时间");ylabel("幅度");
title("增大或减小微分时间常数")
label=[
sprintf("微分时间常数Td=%.2f",Td);
sprintf("增大微分时间常数至Td=%.2f",Td_inc);
sprintf("减小微分时间常数至Td=%.2f",Td_dec)
];
legend(label);
T=[struct2table(stepinfo(Phi));struct2table(stepinfo(Phi1));struct2table(stepinfo(Phi2))];
T.Properties.RowNames=label;
T
T = 3×9 table
 RiseTimeTransientTimeSettlingTimeSettlingMinSettlingMaxOvershootUndershootPeakPeakTime
1 微分时间常数Td=4.18412132130.90881.08498.491001.0849107
2 增大微分时间常数至Td=6.26411861860.90211.04174.174201.0417107
3 减小微分时间常数至Td=2.09382252250.91171.130413.036001.1304108