This commit is contained in:
2019-02-12 16:52:55 +01:00
parent 3412e33595
commit 5a05b7355e
8 changed files with 306 additions and 54 deletions

View File

@@ -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)