Several commonly used PID control algorithms

Positional PID

  • It is applicable to the accused object without the integral link.
  • The realization of this algorithm also needs to use the idea of ​​incremental PID, otherwise the sum term will increase greatly with the increase of control time, resulting in excessive memory usage.
  • matlab simulation;
%-----------------位置式PID------------------%
e = [];
e(1) = 0; e(2) = 0; e(3) = 0;
u = []; u(1) = 0; u(2) = 0;
r = 1; y = []; y(1) = 0;
for i  = 0:0.01:10
    e(3) = r - y(end);
    deltau = 0.5*(e(3)-e(2))+0.5*e(3)+0.05*(e(3)-2*e(2)+e(1));
    u(2) = u(1) + deltau;
    y = [y,u(2)];
    e = [e(2:3),0];
    u = [u(2),0];
end
figure(1)
stairs(0:0.01:10,y(1:1001),'r-','LineWidth',1)
xlim([0,1])
ylim([0,1.5])
xlabel('t')
title('位置式PID')

Insert picture description here

Incremental PID

  • This is suitable for the controlled object that contains an integral link, like a stepper motor.
  • Matlab simulation:
%-----------------增量式PID------------------%
e = [];
e(1) = 0; e(2) = 0; e(3) = 0;
u = []; u(1) = 0; u(2) = 0;
r = 1; y = []; y(1) = 0;
for i  = 0:0.01:10
    e(3) = r - y(end);
    deltau = 0.4*(e(3)-e(2))+0.05*e(3)+0*(e(3)-2*e(2)+e(1));
    u(2) = deltau;
    y = [y,u(2)];
    e = [e(2:3),0];
    u = [u(2),0];
end
figure(2)
stairs(0:0.01:10,y(1:1001),'r-','LineWidth',1)
xlim([0,1])
ylim([0,1.5])
xlabel('t')
title('增量式PID')

Insert picture description here

PID control algorithm with integral separation

  • This kind of algorithm appears because many times the integral term reaches a large value when the controlled object does not reach the steady state, so that the controller saturates. Therefore, it is necessary to suppress the integral link when the deviation is large.
  • Schematic diagram
    Insert picture description here
  • Matlab simulation:
%-----------------积分分离PID------------------%
e = []; key = 0;                 
e(1) = 0; e(2) = 0; e(3) = 0;
u = []; u(1) = 0; u(2) = 0;
r = 1; y = []; y(1) = 0;
for i  = 0:0.01:10
    e(3) = r - y(end);            
    if abs(e(3)) < 0.7 key = 1; else key = 0; end         %赋值限制小了会有稳态误差
    deltau = 0.5*(e(3)-e(2))+0.5*key*e(3)+0.05*(e(3)-2*e(2)+e(1));
    u(2) = u(1) + deltau;
    y = [y,u(2)];
    e = [e(2:3),0];
    u = [u(2),0];
end
figure(4)
stairs(0:0.01:10,y(1:1001),'r-','LineWidth',1)
xlim([0,1])
ylim([0,1.5])
xlabel('t')
title('积分分离PID')

Insert picture description here

PID control algorithm with dead zone

  • Schematic diagram:
    Insert picture description here
  • Matlab simulation:
%-----------------死区PID------------------%
e = [];
e(1) = 0; e(2) = 0; e(3) = 0;
u = []; u(1) = 0; u(2) = 0;
r = 1; y = []; y(1) = 0;
for i  = 0:0.01:10 
    e(3) = r - y(end);
    if abs(e(3))<0.1       %死区增大稳态误差增大
        e(3) = 0;
    end
    deltau = 0.5*(e(3)-e(2))+0.5*e(3)+0.05*(e(3)-2*e(2)+e(1));
    u(2) = u(1) + deltau;
    y = [y,u(2)];
    e = [e(2:3),0];
    u = [u(2),0];
end
figure(5)
stairs(0:0.01:10,y(1:1001),'r-','LineWidth',1)
xlim([0,1])
ylim([0,1.5])
xlabel('t')
title('死区PID')

Insert picture description here

Incomplete derivative PID control algorithm

  • Schematic diagram:
    Insert picture description here
    Insert picture description here
    Anti-interference
  • Matlab simulation:
%-----------------不完全微分PID------------------%
e = []; alpha = 0.5;
e(1) = 0; e(2) = 0; e(3) = 0;
u = []; u(1) = 0; u(2) = 0;  u1=[]; u1(1) = 0; u1(2) = 0;
r = 1; y = []; y(1) = 0;
for i  = 0:0.01:10
    e(3) = r - y(end);
    deltau = 0.5*(e(3)-e(2))+0.5*e(3)+0.05*(e(3)-2*e(2)+e(1));
    u(2) = u(1) + deltau;
    u1(2) = alpha*u1(1) + (1-alpha)*u(2);
    y = [y,u1(2)];
    e = [e(2:3),0];
    u = [u(2),0];
    u1 = [u1(2),0];
end
figure(3)
stairs(0:0.01:10,y(1:1001),'r-','LineWidth',1)
xlim([0,1])
ylim([0,1.5])
xlabel('t')
title('不完全微分PID')

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43145941/article/details/105614360