📄 find_dtpid.m
字号:
function [Kp, Ki, Kd, Kdu3, Kde, N, Ts] = find_DTPID(gains,N,Ts)
%% Given gains as [Kp Ki Kd] and N, Ts, this program, where
%% N>=100 in general, Ts is the sampling time in seconds, this
%% program will find the equivalent DT PID gains as [Kp Ki Kdu3 Kde]
%% For example:
%% See PID0509A.mdl as a sample model.
% gains=[2 6 0.1]; N=200; Ts=0.001; NUM=1000; DEN=[1 26 50];
% [Kp, Ki, Kd, Kdu3, Kde, N, Ts]=find_DTPID(gains,N,Ts);
%
% gains=[5.8 4.92 1.853]; N=100; Ts=0.001; NUM=10; DEN=[1 3 2];
% [Kp, Ki, Kd, Kdu3, Kde, N, Ts]=find_DTPID(gains,N,Ts);
%
%% Chou, PenChen. 5-9-2002
%% Electrical Engineering Department, DaYeh University
%% See P.567, J. Wilkie, etc, Control Engineering, 2002
if N<100, error('-->>>N must be larger than 100'); end
Kp=gains(1); Ki=gains(2); Kd=gains(3);
tau_d=Kd/Kp; tau_f=1/N;
% Check tau_d/tau_f to be between 5 and 20.
%if tau_d/tau_f<5,
% tau_f=tau_d/5; N=1/tau_f;
%end
%if tau_d/tau_f>20,
% tau_f=tau_d/20; N=1/tau_f;
%end
% Get the final data
Kdu3=tau_f/(tau_f+Ts);
Kde =Kp*tau_d/(tau_f+Ts);
% Print out in smart form
fprintf('\n (**** Welcome to CT PID to DT PID conversion program ****)\n');
fprintf(' See PID0509A.mdl as an example.\n\n');
fprintf(' [Continous-time PID parameters]\n');
fprintf('Kp=%9.6f;Ki=%9.6f;Kd=%9.6f;\n',Kp,Ki,Kd);
fprintf(' [Discrete-time PID parameters]\n');
fprintf('Kp=%9.6f;Ki=%9.6f;Kdu3=%9.6f;Kde=%9.6f;\n',Kp,Ki,Kdu3,Kde);
fprintf('Ts=%9.6f;N =%9.5f;\n',Ts,N);
fprintf('NOW, YOU CAN MANUALLY SIMULATE THE MODEL PID0509A (if available) BY USING <start>.\n');
fprintf('If CT and DT responses are not similar in the SCOPE,\n');
fprintf('you need to reduce the sampling time Ts or incread N!\n\n');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -