% function [Ki,K] = area2PI (A0,A1,A2,A3,Kmax); % % Function araa2PI calculates parameters of the PI controller: % % u = (Ki/s + K) * e % % from the measured areas of the process A0 to A3 (A0 is the process steady-state gain) % The parameter Kmax represents the highest allowed open-loop gain K*A0 function [Ki,K] = area2PI (A0,A1,A2,A3,Kmax); Num = A3; % Numerator Den = 2*(A1*A2-A0*A3); % Denominator if (Num == 0) K = 0; elseif (Den == 0) if (A0 ~= 0) K = Kmax/A0; else K = Kmax; end; else K = Num/Den; end; Tmp = K*A0; % Nominal gain if (Tmp > Kmax) | (Tmp < 0) K = Kmax/A0; end; Ki = (K*A0 + 0.5)/A1;