增量式PID算法,每次输出控制量的增量,公式是:Δu(k)=P*e(k)+I*e(k-1)+D*e(k-2),推导过程可以翻翻论坛里的帖子。
本文对控制量进行了累加,所以输出的是总的控制量(和位置式的PID输出是一样的),对控制量输出一定要进行限幅处理。
[pre lang="pascal" line="1"](*Algorithm of incremental PID is u(k)=P*e(k)+I*e(k-1)+D*e(k-2)*)
ek2:=ek1;
ek1:=ek;
(*get current e*)
ek:=rSetValue-rProcessValue;
(*get incremental control value*)
uk:=rPGain*ek+rIGain*ek1+rDGain*ek2;
(*save last control value*)
rControlValue:=rControlValue+uk;
(*limit the control value*)
if rControlValue<rControlValueMin then
rControlValue:=rControlValueMin;
end_if;
if rControlValue>rControlValueMax then
rControlValue:=rControlValueMax;
end_if;[/code]
仿真曲线是在Logix5000的仿真器+matlab上获取的