towards matlab
This commit is contained in:
@@ -73,18 +73,39 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
figure();
|
||||
mot.tf2_0 = tfest(mot.meas, 2, 0, opt);disp(str2ndOrd(mot.tf2_0));
|
||||
mot.tf_mdl=idtf(mot.mdl.num,mot.mdl.den);
|
||||
%ss([g1 mot.tf_mdl],'minimal') this doesn't work as expected
|
||||
|
||||
g11=tf(mot.mdl.numc,mot.mdl.denc); % iqCmd->iqMeas
|
||||
g12=tf([1 0],mot.mdl.denc*12); % iqCmd->iqVolts : iqVolts= i_meas*R+i_meas'*L
|
||||
num=conv(conv(mot.mdl.num1,mot.mdl.num2),mot.mdl.numc);
|
||||
den=conv(conv(mot.mdl.den1,mot.mdl.den2),mot.mdl.denc);
|
||||
g13=tf(num,den); %iqCmd->ActPos
|
||||
%sys=ss([g11;g12])
|
||||
sys=ss([g11;g12;g13])
|
||||
numc=myNorm(mot.mdl.numc);
|
||||
denc=myNorm(mot.mdl.denc);
|
||||
num1=myNorm(mot.mdl.num1);
|
||||
den1=myNorm(mot.mdl.den1);
|
||||
num2=myNorm(mot.mdl.num2);
|
||||
den2=myNorm(mot.mdl.den2);
|
||||
g1=tf(numc,denc); % iqCmd->iqMeas
|
||||
s1=ss(g1);
|
||||
s1.C=[s1.C; 1/s1.B(1) 0]; % add output iqVolts: iqVolts= i_meas*R+i_meas'*L
|
||||
%tf(s1) % display all transfer functions
|
||||
num=conv(num1,num2);%num=1;
|
||||
den=conv(den1,den2);%den=[1 0 0];
|
||||
g2=tf(num,den); %iqMeas->ActPos
|
||||
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.ss.InputName{1}='iqCmd';
|
||||
mot.ss.OutputName{1}='iqMeas';
|
||||
mot.ss.OutputName{2}='iqVolts';
|
||||
mot.ss.OutputName{3}='actPos';
|
||||
% u +-----------+ y
|
||||
%iqCmd------->|1 1|-------> iqMeas
|
||||
% | 2|-------> iqVolts
|
||||
% | 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);
|
||||
%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);
|
||||
setoptions(h,'FreqUnits','Hz','Grid','on');
|
||||
|
||||
end
|
||||
@@ -109,10 +130,8 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
|
||||
%create ss from tf MIMO:
|
||||
%https://ch.mathworks.com/matlabcentral/answers/37152-how-to-convert-tf2ss-for-mimo-system
|
||||
%Gspm=[tf_iqCmd_actVolts;tf_iqCmd_iqMeas;tf_iqCmd_actPos];
|
||||
%sys=ss(Gspm);
|
||||
|
||||
%normalize: [1E6 1E3 1].*mot.mdl.denc
|
||||
%http://ch.mathworks.com/help/control/ug/conversion-between-model-types.html#f3-1039600
|
||||
%https://ch.mathworks.com/help/control/ref/append.html
|
||||
numc=myNorm(mot.mdl.numc);
|
||||
denc=myNorm(mot.mdl.denc);
|
||||
num1=myNorm(mot.mdl.num1);
|
||||
@@ -127,45 +146,36 @@ function [mot1,mot2]=identifyFxFyStage()
|
||||
den5=myNorm(mot.mdl.den5);
|
||||
num=myNorm(mot.mdl.num);
|
||||
den=myNorm(mot.mdl.den);
|
||||
|
||||
%http://ch.mathworks.com/help/control/ug/conversion-between-model-types.html#f3-1039600
|
||||
%tf2ss MIMO
|
||||
%https://ch.mathworks.com/help/control/ref/append.html
|
||||
g1=tf(numc,denc); % iqCmd->iqMeas
|
||||
s1=ss(g1);
|
||||
s1.C=[s1.C; 1/s1.B(1) 0]; % add output iqVolts: iqVolts= i_meas*R+i_meas'*L
|
||||
tf(s1) % display all transfer functions
|
||||
|
||||
num=conv(conv(conv(conv(num1,num2),num3),num4),num5);
|
||||
den=conv(conv(conv(conv(den1,den2),den3),den4),den5);
|
||||
%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];
|
||||
g2=tf(num,den); %iqMeas->ActPos
|
||||
s2=ss(g2);
|
||||
|
||||
s3=append(s1,s2);
|
||||
tf(s3)
|
||||
%t_=tf(s3);
|
||||
%bode(g2);figure;bode(t_(3,2));
|
||||
%connect iqMeas from s1 to iqMeas of s2
|
||||
s3.A(3,1)=1 %WHAT NUMBER ??? s3.B(3,2), s3.C2,:)?
|
||||
%remove the direct iqMeas input
|
||||
%s3.B(3,2)=0
|
||||
|
||||
t_=tf(s3)
|
||||
t_(3,1)
|
||||
figure;
|
||||
bode(t_(3,1))
|
||||
%compare with tf iqCmd->ActPos
|
||||
num=conv(conv(conv(conv(conv(mot.mdl.num1,mot.mdl.num2),mot.mdl.num3),mot.mdl.num4),mot.mdl.num5),mot.mdl.numc);
|
||||
den=conv(conv(conv(conv(conv(mot.mdl.den1,mot.mdl.den2),mot.mdl.den3),mot.mdl.den4),mot.mdl.den5),mot.mdl.denc);
|
||||
g4=tf(num,den); %iqCmd->ActPos
|
||||
figure;
|
||||
bode(g4)
|
||||
|
||||
%sys=ss([g11;g12])
|
||||
sys=ss([g11;g12;g13])
|
||||
sys=ss(g13)
|
||||
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.ss.InputName{1}='iqCmd';
|
||||
mot.ss.OutputName{1}='iqMeas';
|
||||
mot.ss.OutputName{2}='iqVolts';
|
||||
mot.ss.OutputName{3}='actPos' ;
|
||||
% u +-----------+ y
|
||||
%iqCmd------->|1 1|-------> iqMeas
|
||||
% | 2|-------> iqVolts
|
||||
% | 3|-------> actPos
|
||||
% +-----------+
|
||||
|
||||
%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);
|
||||
%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);
|
||||
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