% function [Ki,K,Kd] = area2PID_dist (A0,A1,A2,A3,A4,A5,Kmax); % % Function araa2PID_dist calculates parameters of the PID controller: % % u = (Ki/s + K + Kd*s) * e % % from the measured areas of the process A0 to A5 (A0 is the process steady-state gain) % for "optimal" disturbance rejection. % The parameter Kmax represents the highest allowed open-loop gain K*A0 function [Ki,K,Kd] = area2PID_dist (A0,A1,A2,A3,A4,A5,Kmax); [Ki,K,Kd] = area2PID (A0,A1,A2,A3,A4,A5,Kmax); D = (2*A0*A1*A2*Kd + A2^2 - A1*A3 - A0^2*A3*Kd-Kd*A1^3)*(A1+A0^2*Kd)^2; if (D < 0) D = 0; end; K = (A0*A3 - A0*A1^2*Kd - A1*A2 + A0^2*A2*Kd + sqrt(D))/(2*A0*A1*A2 - A1^3 - A0^2*A3); Tmp = K*A0; % Nominal gain if (Tmp > Kmax) K = Kmax/A0; end; if (Tmp < 0) K = 0; end; Ki = 0.5*(1 + 2*A0*K + A0^2*K^2)/(A1 + A0^2*Kd); if (Ki*A0 < 0) Ki = 0; end;