MATLABで直流モーター速度制御系における時定数とゲインのパラメータ同定

A/D変換がボトルネックになっているのか、RoTHシミュレーションのタイムステップが効いてくるっぽい
Arduino Mega2560で、timestep=1/30[sec]でうまくいった。

同定結果

==result==
Time step = 0.050000
K = 0.665923
T = 3.466667
u_offset = 1.269975
==result== (適正値 as of ts=1/30)
Time step = 0.033333
K = 0.704071
T = 0.166667
u_offset = 1.258763
==result==
Time step = 0.025000
K = 0.430043
T = 0.000000
u_offset = -0.650574

main.m

function main
clear all;close all;
identify(1/20);
clear all;
identify(1/30);
clear all;
identify(1/40);
clear all;
identify(1/50);
end

identify.m

function identify(timestep)
ts=timestep;
simset('SrcWorkspace','current');
u_ini=2.0;
r_const=1.8;
p_const=2.5;
s_time=10;
w_time=4;
% offset_time=1;
open_system('velo');
open_system('velo/Scope');
set_param('velo','SimulationCommand','start');
while(1)
    stat = get_param('velo','SimulationStatus');
    if(strcmp(stat,'stopped'))
        break;
    end
    pause(3);
end
ScopeData = evalin('base','ScopeData');
y=ScopeData.signals.values;
t=ScopeData.time;
y_2=y(:,2);
c1=mean(y_2(w_time/ts:s_time/ts));
c2=mean(y_2((s_time+w_time)/ts:end));
figure();
plot(t,y,t,ones(size(t))*c1,'r--',t,ones(size(t))*c2,'r--');
xlabel('Time [s]');
ylabel('Velocity [V]');
k_id = (c2-c1)/p_const;
u_offset = (k_id*r_const-c1)/k_id;
y2=y_2(s_time/ts:end)-c1;
t2=t(s_time/ts:end);
t2=t2-t2(1);
tc_idx = min(find(y2 > (c2-c1)*0.632));
t_id = t2(tc_idx);
figure();
plot(t2,y2,'.',t_id,(c2-c1)*0.632,'ro',t2,ones(size(t2))*(c2-c1),'r--');
xlim([0 w_time]);
xlabel('Time [s]');
ylabel('Velocity [V]');
fprintf('==result==\n');
fprintf('Time step = %f\n',ts);
fprintf('K = %f\n',k_id);
fprintf('T = %f\n',t_id);
fprintf('u_offset = %f\n',u_offset);
end

velo.slx