first result with observer controller
This commit is contained in:
@@ -17,7 +17,8 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
% meas : a MATLAB idfrd model with data w,mag,phase
|
||||
% mdl : a structure with the python numerators and denominators for the transfer functions
|
||||
% tfc,tf_mdl : various transfer functions
|
||||
% ss : the final continous state space model of the plant
|
||||
% ssPlt : the final continous state space model of the plant (not observable, not controlable)
|
||||
% ssMdl : the simplified continous state space model for the observer (observable, controlable)
|
||||
%
|
||||
% The used data files (generated from Python) are:
|
||||
% (located for now in: /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/MXTuning/18_10_02/ )
|
||||
@@ -51,7 +52,6 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
|
||||
fMdl=load(strcat(path,sprintf('model%d.mat',motid)));
|
||||
obj.mdl=fMdl;
|
||||
|
||||
end
|
||||
|
||||
function tfc=currstep(obj)
|
||||
@@ -61,7 +61,7 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
s=str2ndOrd(tfc);
|
||||
t=(0:199)*50E-6;
|
||||
[y,t]=step(tfc,t);
|
||||
f=figure();
|
||||
figure();
|
||||
subplot(1,2,1);
|
||||
plot(t*1000,obj.currstep.OutputData(11:210),'b',t*1000,y*1000,'r');
|
||||
xlabel('ms')
|
||||
@@ -83,6 +83,22 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
s=sprintf('k:%g w0:%g damp:%g',k,w0,damp);
|
||||
end
|
||||
|
||||
function chkCtrlObsv(ss,s)
|
||||
P=ctrb(ss.A,ss.B);
|
||||
if rank(ss.A)==rank(P)
|
||||
ct='';%controlable
|
||||
else
|
||||
ct='not ';%not controlable
|
||||
end
|
||||
|
||||
Q=obsv(ss.A,ss.C);
|
||||
if rank(ss.A)==rank(Q)
|
||||
ob='';%sys observable
|
||||
else
|
||||
ob='not ';%not observable
|
||||
end
|
||||
disp([s,' is ',ct,'controlable and ',ob,'observable.']);
|
||||
end
|
||||
|
||||
function mot=fyStage()
|
||||
mot=loadData('/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/MXTuning/18_10_02/',1);
|
||||
@@ -102,7 +118,7 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
denc=myNorm(mot.mdl.denc);
|
||||
num1=myNorm(mot.mdl.num1);
|
||||
den1=myNorm(mot.mdl.den1);
|
||||
num2=myNorm(mot.mdl.num2);
|
||||
num2=myNorm(mot.mdl.num2); %resonance
|
||||
den2=myNorm(mot.mdl.den2);
|
||||
g1=tf(numc,denc); % iqCmd->iqMeas
|
||||
s1=ss(g1);
|
||||
@@ -114,15 +130,38 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
s2=ss(g2);
|
||||
s3=append(s1,s2);
|
||||
s3.A(3,2)=s3.C(1,2)*s3.B(3,2);
|
||||
mot.ss=ss(s3.A,s3.B(:,1),s3.C,0); % single input, remove input iqMeas
|
||||
mot.ssPlt=ss(s3.A,s3.B(:,1),s3.C,0); % single input, remove input iqMeas
|
||||
mot.ssPlt.InputName{1}='iqCmd';
|
||||
mot.ssPlt.OutputName{1}='iqMeas';
|
||||
mot.ssPlt.OutputName{2}='iqVolts';
|
||||
mot.ssPlt.OutputName{3}='actPos';
|
||||
chkCtrlObsv(mot.ssPlt,'ssPlt fyStage');
|
||||
% u +-----------+ y
|
||||
%iqCmd------->|1 1|-------> iqMeas
|
||||
% | 2|-------> iqVolts
|
||||
% | 3|-------> actPos
|
||||
% +-----------+
|
||||
|
||||
%simplified model without resonance
|
||||
g2=tf(num1,den1); %iqMeas->ActPos without resonance frequencies
|
||||
s2=ss(g2);
|
||||
s3=append(s1,s2);
|
||||
s3.A(3,2)=s3.C(1,2)*s3.B(3,2);
|
||||
mot.ssMdl=ss(s3.A,s3.B(:,1),s3.C,0); % single input, remove input iqMeas
|
||||
mot.ssMdl.InputName{1}='iqCmd';
|
||||
mot.ssMdl.OutputName{1}='iqMeas';
|
||||
mot.ssMdl.OutputName{2}='iqVolts';
|
||||
mot.ssMdl.OutputName{3}='actPos';
|
||||
chkCtrlObsv(mot.ssMdl,'ssMdl fyStage');
|
||||
|
||||
%filter in front of plant to suppress resonances (inverse of reonance)
|
||||
den=num2;%num=1;
|
||||
num=den2;%den=[1 0 0];
|
||||
mot.prefilt=tf(num,den);
|
||||
|
||||
mot.ss.InputName{1}='iqCmd';
|
||||
mot.ss.OutputName{1}='iqMeas';
|
||||
mot.ss.OutputName{2}='iqVolts';
|
||||
mot.ss.OutputName{3}='actPos';
|
||||
%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);
|
||||
tmp=tf(mot.ss);h=bodeplot(mot.meas,'r',tmp(3,1),'g',mot.w);
|
||||
t1=tf(mot.ssPlt);t2=tf(mot.ssMdl);h=bodeplot(mot.meas,'r',t1(3,1),'g',t2(3,1),'b',mot.w);
|
||||
setoptions(h,'FreqUnits','Hz','Grid','on');
|
||||
|
||||
end
|
||||
@@ -149,24 +188,22 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
denc=myNorm(mot.mdl.denc);
|
||||
num1=myNorm(mot.mdl.num1);
|
||||
den1=myNorm(mot.mdl.den1);
|
||||
num2=myNorm(mot.mdl.num2);
|
||||
num2=myNorm(mot.mdl.num2); %resonance
|
||||
den2=myNorm(mot.mdl.den2);
|
||||
num3=myNorm(mot.mdl.num3);
|
||||
num3=myNorm(mot.mdl.num3); %resonance
|
||||
den3=myNorm(mot.mdl.den3);
|
||||
num4=myNorm(mot.mdl.num4);
|
||||
num4=myNorm(mot.mdl.num4); %resonance
|
||||
den4=myNorm(mot.mdl.den4);
|
||||
num5=myNorm(mot.mdl.num5);
|
||||
num5=myNorm(mot.mdl.num5); %resonance
|
||||
den5=myNorm(mot.mdl.den5);
|
||||
num=myNorm(mot.mdl.num);
|
||||
den=myNorm(mot.mdl.den);
|
||||
%num=myNorm(mot.mdl.num);
|
||||
%den=myNorm(mot.mdl.den);
|
||||
g1=tf(numc,denc); % iqCmd->iqMeas
|
||||
s1=ss(g1);
|
||||
s1.C=[s1.C; 1E5* 2.4E-3 1E-3*s1.C(2)*8.8]; % add output iqVolts: iqVolts= i_meas*R+i_meas'*L 2.4mH 8.8Ohm (took random scaling values)
|
||||
%tf(s1) % display all transfer functions
|
||||
num=conv(conv(conv(conv(num1,num2),num3),num4),num5);%num=1;
|
||||
den=conv(conv(conv(conv(den1,den2),den3),den4),den5);%den=[1 0 0];
|
||||
num=conv(num1,num2);%num=1;
|
||||
den=conv(den1,den2);%den=[1 0 0];
|
||||
|
||||
g2=tf(num,den); %iqMeas->ActPos
|
||||
s2=ss(g2);
|
||||
@@ -177,21 +214,37 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
s3.A(3,2)=s3.C(1,2)*s3.B(3,2);
|
||||
|
||||
s3.A(3,2)=s3.C(1,2)*s3.B(3,2);
|
||||
mot.ss=ss(s3.A,s3.B(:,1),s3.C,0); % single input, remove input iqMeas
|
||||
mot.ssPlt=ss(s3.A,s3.B(:,1),s3.C,0); % single input, remove input iqMeas
|
||||
|
||||
mot.ss.InputName{1}='iqCmd';
|
||||
mot.ss.OutputName{1}='iqMeas';
|
||||
mot.ss.OutputName{2}='iqVolts';
|
||||
mot.ss.OutputName{3}='actPos' ;
|
||||
mot.ssPlt.InputName{1}='iqCmd';
|
||||
mot.ssPlt.OutputName{1}='iqMeas';
|
||||
mot.ssPlt.OutputName{2}='iqVolts';
|
||||
mot.ssPlt.OutputName{3}='actPos' ;
|
||||
chkCtrlObsv(mot.ssPlt,'ssPlt fxStage');
|
||||
% u +-----------+ y
|
||||
%iqCmd------->|1 1|-------> iqMeas
|
||||
% | 2|-------> iqVolts
|
||||
% | 3|-------> actPos
|
||||
% +-----------+
|
||||
|
||||
%simplified model without resonance
|
||||
g2=tf(num1,den1); %iqMeas->ActPos without resonance frequencies
|
||||
s2=ss(g2);
|
||||
s3=append(s1,s2);
|
||||
s3.A(3,2)=s3.C(1,2)*s3.B(3,2);
|
||||
mot.ssMdl=ss(s3.A,s3.B(:,1),s3.C,0); % single input, remove input iqMeas
|
||||
mot.ssMdl.InputName=mot.ssPlt.InputName;
|
||||
mot.ssMdl.OutputName=mot.ssPlt.OutputName;
|
||||
chkCtrlObsv(mot.ssMdl,'ssMdl fxStage');
|
||||
|
||||
%filter in front of plant to suppress resonances (inverse of reonance)
|
||||
den=conv(conv(conv(num2,num3),num4),num5);%num=1;
|
||||
num=conv(conv(conv(den2,den3),den4),den5);%den=[1 0 0];
|
||||
mot.prefilt=tf(num,den);
|
||||
|
||||
%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);
|
||||
tmp=tf(mot.ss);h=bodeplot(mot.meas,'r',tmp(3,1),'g',mot.w);
|
||||
t1=tf(mot.ssPlt);t2=tf(mot.ssMdl);h=bodeplot(mot.meas,'r',t1(3,1),'g',t2(3,1),'b',mot.w);
|
||||
setoptions(h,'FreqUnits','Hz','Grid','on');
|
||||
%controlSystemDesigner('bode',1,mot.tf_py); % <<<<<<<<< This opens a transferfiûnction that can be edited
|
||||
|
||||
|
||||
Reference in New Issue
Block a user