good approx model
This commit is contained in:
@@ -14,23 +14,21 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
obj.currstep=iddata([zeros(10,1); obj.currstep.data(:,2)],[zeros(10,1); obj.currstep.data(:,3)],50E-6);
|
||||
|
||||
f=load(strcat(path,sprintf('full_bode_mot%d.mat',motid)));
|
||||
obj.frq=f.frq*2*pi; %convert from Hz to rad/s
|
||||
obj.w=f.frq*2*pi; %convert from Hz to rad/s
|
||||
if motid==2
|
||||
f.db_mag(1:224)=f.db_mag(225); % reset bad values at low frequencies
|
||||
end
|
||||
obj.mag=10.^(f.db_mag/20); %mag not in dB
|
||||
obj.phase=f.deg_phase*pi/180; %phase in rad
|
||||
response = obj.mag.*exp(1j*obj.phase);
|
||||
obj.meas= idfrd(response,obj.frq,0);
|
||||
obj.meas= idfrd(response,obj.w,0);
|
||||
end
|
||||
|
||||
function tfc=currstep(obj)
|
||||
opt=tfestOptions;
|
||||
opt.Display='off';
|
||||
tfc = tfest(obj.currstep, 2, 0,opt);
|
||||
den=tfc.Denominator;
|
||||
num=tfc.Numerator;
|
||||
k=num(1);
|
||||
w0=sqrt(num(1));
|
||||
damp=den(2)/2/w0;
|
||||
s=sprintf('k:%g w0:%g damp:%g\n',k,w0,damp);
|
||||
s=str2ndOrd(tfc);
|
||||
%disp(s);
|
||||
%h = stepplot(tf1);
|
||||
%l=obj.currstep.OutputData
|
||||
@@ -45,6 +43,36 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
setoptions(h,'FreqUnits','Hz','Grid','on');
|
||||
end
|
||||
|
||||
function s=str2ndOrd(tf)
|
||||
den=tf.Denominator;
|
||||
num=tf.Numerator;
|
||||
k=num(1)/den(3);
|
||||
w0=sqrt(den(3));
|
||||
damp=den(2)/2/w0;
|
||||
s=sprintf('k:%g w0:%g damp:%g\n',k,w0,damp);
|
||||
end
|
||||
|
||||
function tf=fyModel()
|
||||
num=[ 2.36527033e+11, 1.17108082e+13, 3.62387303e+17];
|
||||
den=[ 1.00000000e+00, 6.64495206e+03, 2.12777376e+07, ...
|
||||
1.23728427e+10, 3.07054470e+13, 1.72592127e+15, ...
|
||||
5.39888656e+17];
|
||||
|
||||
tf=idtf(num,den);
|
||||
end
|
||||
|
||||
function tf=fxModel()
|
||||
num=[ 1.23284092e+11, 4.14791803e+13, 1.18702926e+18, ...
|
||||
2.96296718e+20, 2.67179357e+24, 4.04662786e+26, ...
|
||||
1.59131515e+30, 1.02778572e+32, 1.64551888e+35];
|
||||
den=[ 1.00000000e+00, 6.93892369e+03, 3.17041055e+07, ...
|
||||
7.66104262e+10, 2.36504992e+14, 2.23054854e+17, ...
|
||||
5.12578678e+20, 2.04416512e+23, 3.27771400e+26, ...
|
||||
4.77145416e+28, 3.85452959e+31, 1.28911178e+33, ...
|
||||
9.52157664e+34];
|
||||
tf=idtf(num,den);
|
||||
end
|
||||
|
||||
function mot=fyStage()
|
||||
mot=loadData('/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/MXTuning/18_10_02/',1);
|
||||
mot.tfc=currstep(mot);
|
||||
@@ -52,12 +80,13 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
opt=tfestOptions;
|
||||
opt.Display='off';
|
||||
opt.initializeMethod='iv';
|
||||
opt.WeightingFilter=[1,5;20,670]*(2*pi); % Hz->rad/s conversion
|
||||
opt.WeightingFilter=[1,5;30,670]*(2*pi); % Hz->rad/s conversion
|
||||
|
||||
figure();
|
||||
mot.tf4_2 = tfest(mot.meas, 4, 2, opt);
|
||||
mot.tf6_4 = tfest(mot.meas, 6, 4, opt);
|
||||
h=bodeplot(mot.meas,'r',mot.tf4_2,'b',mot.tf6_4,'g');
|
||||
mot.tf2_0 = tfest(mot.meas, 2, 0, opt);disp(str2ndOrd(mot.tf2_0));
|
||||
mot.tf_mdl= fyModel();
|
||||
%h=bodeplot(mot.meas,'r',mot.tf4_2,'b',mot.tf6_4,'g');
|
||||
h=bodeplot(mot.meas,'r',mot.tf2_0,'b',mot.tf_mdl,'g',mot.w);
|
||||
setoptions(h,'FreqUnits','Hz','Grid','on');
|
||||
|
||||
end
|
||||
@@ -69,16 +98,14 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
opt=tfestOptions;
|
||||
opt.Display='off';
|
||||
opt.initializeMethod='iv';
|
||||
opt.WeightingFilter=[1,5;20,670]*(2*pi); % Hz->rad/s conversion
|
||||
opt.WeightingFilter=[1,4;10,670]*(2*pi); % Hz->rad/s conversion
|
||||
|
||||
figure();
|
||||
mot.tf4_2 = tfest(mot.meas, 4, 2, opt);
|
||||
mot.tf6_4 = tfest(mot.meas, 6, 4, opt);
|
||||
mot.tf2_0 = tfest(mot.meas, 2, 0, opt);disp(str2ndOrd(mot.tf2_0));
|
||||
mot.tf13_9 = tfest(mot.meas, 13, 9, opt);
|
||||
num=[5.42637491e-24 1.45926254e-21 5.20861422e-17 9.92527094e-15 1.16707977e-10 1.31240975e-08 7.03191689e-05 3.08626613e-03 7.32824533e+00];
|
||||
den=[2.01035570e-35,2.33560078e-31,9.14767135e-28,2.52369732e-24,7.42150891e-21,6.89695386e-18,1.65017156e-14,5.77522779e-12,1.08386286e-08,1.13336206e-06,1.27552247e-03,2.19776479e-02,1.00000000e+00];
|
||||
mot.tf_py = idtf(num,den);
|
||||
h=bodeplot(mot.meas,'r',mot.tf4_2,'b',mot.tf6_4,'g',mot.tf13_9,'m',mot.tf_py,'b');
|
||||
mot.tf_mdl = fxModel();
|
||||
%h=bodeplot(mot.meas,'r',mot.tf4_2,'b',mot.tf6_4,'g',mot.tf13_9,'m',mot.tf_py,'b');
|
||||
h=bodeplot(mot.meas,'r',mot.tf2_0,'b',mot.tf_mdl,'g',mot.w);
|
||||
setoptions(h,'FreqUnits','Hz','Grid','on');
|
||||
%controlSystemDesigner('bode',1,mot.tf_py); % <<<<<<<<< This opens a transferfiûnction that can be edited
|
||||
|
||||
@@ -91,10 +118,16 @@ end
|
||||
|
||||
|
||||
function f=SCRATCH()
|
||||
[m1,m2]=identifyFxFyStage();
|
||||
controlSystemDesigner(1,m2.tf_py); % <<<<<<<<< This opens a transferfiûnction that can be edited
|
||||
|
||||
%identification toolbox
|
||||
systemIdentification
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%opt=tfestOptions('Display','off');
|
||||
%opt=tfestOptions('Display','on','initializeMethod','svf');
|
||||
%opt=tfestOptions('Display','on','initializeMethod','iv','WeightingFilter',[]);
|
||||
@@ -183,7 +216,5 @@ function f=SCRATCH()
|
||||
controlSystemDesigner('bode',mot2);
|
||||
|
||||
|
||||
[m1,m2]=identifyFxFyStage();
|
||||
controlSystemDesigner(1,m2.tf_py); % <<<<<<<<< This opens a transferfiûnction that can be edited
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user