wip
This commit is contained in:
@@ -41,6 +41,7 @@ function [ssc]=StateSpaceControlDesign(mot,mode)
|
||||
%use_lqr: use lqr instead of pole placement
|
||||
verb=1;
|
||||
use_lqr=0;
|
||||
MaxDac=2011.968;
|
||||
filt_pos_err=Prefilt(mot,2);
|
||||
%locate poles: 2500rad/s = 397Hz, 6300rad/s = 1027Hz
|
||||
switch mode
|
||||
@@ -214,10 +215,19 @@ function [ssc]=StateSpaceControlDesign(mot,mode)
|
||||
|
||||
%state space controller
|
||||
ssc=struct();
|
||||
for k=["Ts","ss_plt","ss_o","ss_oz","filt_pos_err","filt_pos_err_z","V"]
|
||||
for k=["Ts","ss_plt","ss_o","ss_oz","filt_pos_err","filt_pos_err_z","V","MaxDac"]
|
||||
ssc=setfield(ssc,k,eval(k));
|
||||
end
|
||||
save(sprintf('/tmp/ssc%d.mat',mot.id),'-struct','ssc');
|
||||
|
||||
mat2py=struct();
|
||||
[ozA,ozB,ozC,ozD]=ssdata(ss_oz);
|
||||
[pos_err_num,pos_err_den]=tfdata(filt_pos_err_z);
|
||||
for k=["Ts","V","MaxDac","ozA","ozB","ozC","ozD","pos_err_num","pos_err_den"]
|
||||
mat2py=setfield(mat2py,k,eval(k));
|
||||
end
|
||||
fn=sprintf('/tmp/ssc%d.mat',mot.id);
|
||||
save(fn,'-struct','mat2py');
|
||||
disp(['saved ' fn]);
|
||||
end
|
||||
|
||||
function pf=Prefilt(mot,mode)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
baseDir='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/matlab/figures';
|
||||
|
||||
clear;clear global;
|
||||
close all;disp('löoad identification data...');
|
||||
close all;disp('load identification data...');
|
||||
mot=identifyFxFyStage(7);
|
||||
|
||||
close all;disp('simulate stage closed loop...');
|
||||
@@ -16,21 +16,9 @@ for k =1:2
|
||||
end
|
||||
|
||||
close all;disp('simulate observer...');
|
||||
for k =1:2
|
||||
[ssc]=StateSpaceControlDesign(mot{k});sim('observer');
|
||||
f=figure(); h=plot(desPos_actPos.Time,desPos_actPos.Data,'g');
|
||||
set(h(1),'color','b'); set(h(2),'color',[0 0.5 0]);
|
||||
print(f,sprintf('figures/sim_cl_observer_%d',mot{k}.id),'-depsc');
|
||||
f=bodeSamples(desPos_actPos);
|
||||
print(f,sprintf('figures/sim_cl_observer_bode%d',mot{k}.id),'-depsc');
|
||||
end
|
||||
disp('document figure generation done');close all;
|
||||
|
||||
|
||||
close all;disp('simulate observer with prefilter...');
|
||||
for m =0%0:1
|
||||
for k =1:2
|
||||
[ssc]=StateSpaceControlDesign(mot{k},m);sim('observer');
|
||||
for sscType=0%0:1
|
||||
for k=1:2
|
||||
[ssc]=StateSpaceControlDesign(mot{k},sscType);sim('observer');
|
||||
f=figure(); h=plot(desPos_actPos.Time,desPos_actPos.Data,'g');
|
||||
set(h(1),'color','b'); set(h(2),'color',[0 0.5 0]);
|
||||
print(f,sprintf('figures/sim_cl_obs_%d_%d',m,mot{k}.id),'-depsc');
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user