⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pid3.m

📁 内模控制器(IMC)工具箱。包括参数整定、PID控制器参数转换等
💻 M
字号:
function [K,TauI,TauD,pid_text,err]=pid(numPs,denPs,numC,denC,numPinvs,denPinvs)

% Calculates PID parameters from IMC design


% PID controller from numC/denC
%----------------------------------------------------------
err=0;

REVnumC = fliplr(numC);			% reverse order of 'numC'
REVdenC = fliplr(denC);			% reverse order of 'denC'
REVnumPinvs = fliplr(numPinvs);		% reverse order of 'numPinvs'
REVdenPinvs = fliplr(denPinvs);		% reverse order of 'denPinvs'

keps=REVnumC(1)/REVdenC(2);
Kp=REVnumPinvs(1)/REVdenPinvs(1);

REVnumC = REVnumC/REVnumC(1);		% division by coeff. of linear term
REVdenC = REVdenC/REVdenC(2);   	% division by coeff. of linear term

if length(REVnumC) >= 3
 a1=REVnumC(2);
 a2=REVnumC(3);
elseif length(REVnumC) == 2
 a1=REVnumC(2);
 a2=0;
elseif length(REVnumC) <= 1
 a1=0;
 a2=0;
end

if length(REVdenC) >= 4
 b1=REVdenC(3);
 b2=REVdenC(4);
elseif length(REVnumC) == 3
 b1=REVdenC(3);
 b2=0;
elseif length(REVnumC) <= 2
 b1=0;
 b2=0;
end

pid_text='';
pid_text1='';


if  a1 ~= b1
 K    = keps*(a1-b1);
 TauI = a1-b1;
 TauD = (a2+b1^2-b2-a1*b1)/(a1-b1);
else
 pid_text='I cannot get a PID controller. Check entries.';
 errordlg(pid_text);
 err=1;
 return
end


% ideal PID controller (TauI, TauD positive)
%----------------------------------------------------------

numPIDi=keps*[TauI*TauD TauI 1];
denPIDi=[1 0];

disp(' ');
disp(' The ideal PID controller for the outter loop is:           ');
disp('                                        ');
disp('                    1                   ');
disp(' PI(s) = K*( 1 +  ------ + TauD*s)      ');
disp('                  TauI*s                ');
disp('				              ');
disp([' K    (controller gain)          = ', num2str(K)]);                        
disp([' TauI (integral time constant)   = ', num2str(TauI)]);
disp([' TauD (derivative time constant) = ', num2str(TauD)]);
disp(' ');

pid_text='';

pid_text=strvcat(pid_text, ' The ideal PID controller for the outter loop is: ');
pid_text=strvcat(pid_text, '                      1 ');
pid_text=strvcat(pid_text, ' PI(s) = K * (1 + ---------- + TauD*s ) ');
pid_text=strvcat(pid_text, '                    TauI*s ');
pid_text=strvcat(pid_text, 'where ');
pid_text0='';
pid_text0=['K                               = ', num2str(K)];
pid_text=strvcat(pid_text, pid_text0 );
pid_text0='';
pid_text0=['TauI                           = ', num2str(TauI)];
pid_text=strvcat(pid_text,pid_text0);
pid_text0='';
pid_text0=['TauD                          = ', num2str(TauD)];
pid_text=strvcat(pid_text, pid_text0);
pid_text=strvcat(pid_text, '');



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -