Code covered by the BSD License  

Highlights from
MIMOtool

image thumbnail

MIMOtool

by

 

12 Nov 2001 (Updated )

Multi Input Multi Output Systems Toolbox

ltr_syn;
function ltr_syn;
%LTR_SYN : finestra per la sintesi nel controllo LQG\LTR
%
% In base alla posizione dell'incertezza (ingresso o uscita)
% viene creata la finestra relativa alla sintesi LQ o KFB
%
% Massimo Davini 20/10/99

global stack;
watchon;

set(stack.temp.handles,'visible','off');drawnow;

% enlarge text if java machine is running
jsz=stack.general.javasize;

szt=jsz+.65;szt1=jsz/2+.6;

posiz_incertezza=stack.temp.incer;  %'in' o 'out'
bul=stack.temp.param(1);            %bandwidth upper limit
sg=stack.temp.param(2);             %static gain
freq=stack.temp.param(3);           %pole frequency with integral behaviour
cf=stack.temp.param(4);             %crossover fr of the uncertainty
ro=stack.temp.param(5);             %rool_off fr of the uncertainty
[A,B,C,D]=unpck(stack.temp.plant);  %sistema ORIGINALE o AUMENTATO

[ns,ns]=size(A);
[no,ni]=size(D);

RO=1;H=C;   %valori iniziali per lq synthesis
MU=1;W=B;   %valori iniziali per kfb synthesis
if strcmp(stack.temp.incer,'in') tipo=1;else tipo=2;end;
%-------------------------------------------------
%------------------interfaccia--------------------
%--------
if tipo==1 str=' H = C| H = -inv(B''B)B''A';
           cb=['[A,B,C,D]=unpck(stack.temp.plant);x=get(gco,''value'');',...
               'if x==1 stack.temp.H=C;',...
               'elseif x==2 stack.temp.H=-pinv(B)*A;end;',...
               'clear A B C D x;ltr_syn1;'];
else       str=' W = B| W = -AC''inv(CC'')';
           cb=['[A,B,C,D]=unpck(stack.temp.plant);x=get(gco,''value'');',...
               'if x==1 stack.temp.W=B;',...
               'elseif x==2 stack.temp.W=-A*pinv(C);end;',...
               'clear A B C D x;ltr_syn1;'];
end;
ltr_1(1)=uicontrol('style','popupmenu','unit','normalized','position',[0.12 0.32-jsz/10 0.25 0.05+jsz/8],...
   'fontunits','normalized','fontsize',jsz+.35,'fontweight','bold',...
   'tag','ltr_1','callback',cb,'string',str,'visible','off'); 

ltr_1(2)=uicontrol('style','slider','unit','normalized','position',[0.12 0.21-jsz/11 0.55 0.05+jsz/8],...
   'tag','barra_syn','callback','ltr_syn1;','value',0,'max',0,'min',-3,'visible','off',...
   'sliderstep',[0.01 0.10]); 
%--------
ltr_1(3)=uicontrol('style','text','units','normalized','position',[0.67 0.31 0.07 0.05],...
   'fontunits','normalized','fontsize',szt,'fontweight','bold',...
   'backgroundcolor',[.6 .7 .9],'HorizontalAlignment','right',...
   'visible','off','string','10^: ','tag','ltr_1');

ltr_1(4)=uicontrol('style','edit','units','normalized','position',[0.74 0.32-jsz/10 0.07 0.05+jsz/8],...
   'fontunits','normalized','fontsize',jsz*0.8+.4,'fontweight','bold',...
   'backgroundcolor','yellow','HorizontalAlignment','left',...
   'visible','off','string','-3','tag','rangemin');
 
ltr_1(5)=uicontrol('style','edit','units','normalized','position',[0.83 0.32-jsz/11 0.07 0.05+jsz/8],...
   'fontunits','normalized','fontsize',jsz*0.8+.4,'fontweight','bold',...
   'backgroundcolor','yellow','HorizontalAlignment','left',...
   'visible','off','string','0','enable','on','tag','rangemax');
%--------
if tipo==1 str1='ro min';str2='ro max';str3='ro = ';
else       str1='mu min';str2='mu max';str3='mu = ';end;
ltr_1(6)=uicontrol('style','text','units','normalized','position',[0.73 0.27 0.1 0.05],...
   'fontunits','normalized','fontsize',szt1,'fontweight','bold',...
   'backgroundcolor',[.6 .7 .9],'HorizontalAlignment','center',...
   'visible','off','string',str1,'tag','ltr_1');

ltr_1(7)=uicontrol('style','text','units','normalized','position',[0.82 0.27 0.1 0.05],...
   'fontunits','normalized','fontsize',szt1,'fontweight','bold',...
   'backgroundcolor',[.6 .7 .9],'HorizontalAlignment','center',...
   'visible','off','string',str2,'tag','ltr_1');

ltr_1(8)=uicontrol('style','text','units','normalized','position',[0.67 0.21-jsz/15 0.07 0.05],...
   'fontunits','normalized','fontsize',szt,'fontweight','bold',...
   'backgroundcolor',[.6 .7 .9],'HorizontalAlignment','right',...
   'visible','off','string',str3,'tag','ltr_1');
%--------
ltr_1(9)=uicontrol('style','edit','units','normalized','position',[0.74 0.21-jsz/11 0.16 0.05+jsz/8],...
   'fontunits','normalized','fontsize',jsz/2+.5,'fontweight','bold',...
   'backgroundcolor','yellow','HorizontalAlignment','left','enable','off',...
   'visible','off','string',num2str(1),'tag','edit_romu');

%--------
if tipo==1 strck1='Trol = (ro^.5)*H*inv(sI-A)*B';
           strck2='Tlq  = Kc*inv(sI-A)*B';
           cb=['if get(gco,''value'')',...
                 'set(gca,''drawmode'',''fast'',''nextplot'',''add'');',...
                 'semilogx(stack.temp.w,stack.temp.sv_Tlq,''r'',''tag'',''plot_Tlq'');',...
                 'set(gca,''nextplot'',''replace'');',...
                 'else delete(findobj(''tag'',''plot_Tlq''));end;'];  
else       strck1='Tfol = (mu^.5)*C*inv(sI-A)*W';
           strck2='Tkf  = C*inv(sI-A)*Kf';
           cb=['if get(gco,''value'')',...
                 'set(gca,''drawmode'',''fast'',''nextplot'',''add'');',...
                 'semilogx(stack.temp.w,stack.temp.sv_Tkf,''r'',''tag'',''plot_Tkf'');',...
                 'set(gca,''nextplot'',''replace'');',...
                 'else delete(findobj(''tag'',''plot_Tkf''));end;'];  
end;

ltr_1(10)=uicontrol('style','checkbox','units','normalized','position',[0.36 0.11 0.38 0.05],...
   'fontunits','normalized','fontsize',szt+jsz/2,'fontweight','bold',...
   'backgroundcolor',[.6 .7 .9],'HorizontalAlignment','left','value',1,...
   'visible','off','string',strck1,'tag','ltr_1','callback','set(gco,''value'',1);');

ltr_1(11)=uicontrol('style','text','units','normalized','position',[0.74 0.115 0.05 0.04],...
   'backgroundcolor',[0 0 1],'visible','off','tag','ltr_1');

ltr_1(12)=uicontrol('style','checkbox','units','normalized','position',[0.36 0.05 0.38 0.05],...
   'fontunits','normalized','fontsize',szt+jsz/2,'fontweight','bold',...
   'backgroundcolor',[.6 .7 .9],'HorizontalAlignment','left','value',0,...
   'visible','off','string',strck2,'tag','ck_TlqTkf','callback',cb);

ltr_1(13)=uicontrol('style','text','units','normalized','position',[0.74 0.055 0.05 0.04],...
   'backgroundcolor',[1 0 0],'visible','off','tag','ltr_1');
%--------
campiback=['''incer'',''param'',''gates'',''H'',''W'',''w'',',...
      '''sv_Trol'',''sv_Tfol'',''Kc'',''Kf'',''sv_Tlq'',''sv_Tkf'','...
      '''GK_KG'',''sv_GKKG'',''K'''];
ltr_11(1)=uicontrol('style','push','unit','normalized','position',[0.05 0.05 0.14 0.12],...
   'fontunits','normalized','fontsize',.35,'fontweight','bold',...
   'string','BACK','Horizontalalignment','center','tag','ltr_1',...
   'TooltipString','Back to the previous window',...
   'callback',sprintf('back_syn(''ltr_0'',%u,%s);',length(stack.temp.handles),campiback)); 

campiclose=['''integratori'',''plant'',''sys'',''edit'',''incer'',',...
      '''param'',''gates'',''H'',''W'',''w'',''sv_Trol'',''sv_Tfol'',',...
      '''Kc'',''Kf'',''sv_Tlq'',''sv_Tkf'',''GK_KG'',''sv_GKKG'',''K'''];
ltr_11(2)=uicontrol('style','push','unit','normalized','position',[0.2 0.05 0.14 0.12],...
   'fontunits','normalized','fontsize',.35,'fontweight','bold',...
   'string','CLOSE','Horizontalalignment','center','tag','ltr_1',...
   'TooltipString','Back to the main SYNTHESIS window',...
   'callback',sprintf('back_syn(''syn0'',0,%s);',campiclose));

ltr_11(3)=uicontrol('style','push','unit','normalized','position',[0.81 0.05 0.14 0.12],...
   'fontunits','normalized','fontsize',.35,'fontweight','bold',...
   'Horizontalalignment','center','string','NEXT','tag','BNext',...
   'TooltipString','Go to the next window','callback','ltr_rec;',...
   'enable','off');

if tipo==1 str='Impossible to find Kc';
else str='Impossible to find Kf';end;
info=uicontrol('style','text','units','normalized','position',[0.4 0.32 0.26 0.05],...
   'fontunits','normalized','fontsize',szt,'fontweight','bold',...
   'backgroundcolor',[.6 .7 .9],'HorizontalAlignment','center',...
   'foregroundcolor','yellow','visible','off',...
   'string',str,'tag','inf1');

set(ltr_11,'visible','on');drawnow;
set(ltr_1,'visible','on');drawnow;

%----------------------------------------------------------
%grafico : barriere,crossover frequency and singular values
%----------------------------------------------------------

%limiti di frequenza del grafico
if isnan(freq) xmin=floor(log10(bul))-3;
else xmin=floor(log10(freq))-2;end;
xmax=ceil(log10(cf))+2;
w=logspace(xmin,xmax,500);

%barriere
x(1)=10^xmin;y(1)=0;
if isnan(freq)
       x(2)=10^xmin;y(2)=sg;
       x(3)=bul/10;y(3)=sg;
       x(4)=10^(sg/600+log10(bul)-1);y(4)=0;
else
       x(2)=10^xmin;y(2)=-20*(xmin-log10(freq))+sg;
       x(3)=freq;y(3)=sg;
       x(4)=freq*10^(sg/600);y(4)=0;
end;
x(5)=10^xmax;y(5)=0;
x(6)=10^xmax;y(6)=-ro*(xmax-log10(cf));
x(7)=cf;y(7)=0;

%--------------------
%--------------------
%aggiornamento stack.temp
stack.temp.gates=[x;y];
stack.temp.H=H;
stack.temp.W=W;
stack.temp.w=w;
stack.temp.sv_Trol=nan;
stack.temp.sv_Tfol=nan;
stack.temp.Kc=[];
stack.temp.Kf=[];
stack.temp.sv_Tlq=nan;
stack.temp.sv_Tkf=nan;
stack.temp.GK_KG=[];
stack.temp.sv_GKKG=nan;
stack.temp.K=[];
stack.temp.handles=[stack.temp.handles,ltr_1,ltr_11,info];

%-------------------
%-----grafico-------
axes('Position',[0.12 0.46 0.78 0.44]);
set(gca,'drawmode','fast');
semilogx(w,nan*zeros(size(w)));
set(gca,'NextPlot','add');
plot(bul,0,'*');
fill(x,y,'y');
ylabel('dB','fontsize',8);
set(gca,'Xlim',[10^xmin,10^xmax],'Ylim',[-3*sg,2*sg],...
   'tag','grafico','NextPlot','replace'); 

if tipo==1 titolo='   LQR SYNTHESIS with Q = H''H and R = ro*I';
else       titolo='   KFB SYNTHESIS with Qn = WW'' and Rn = mu*I';
end;
title(titolo,'color',[0 0 0],'fontsize',9,'fontweigh','demi');
crea_pop(1,'crea');

ltr_syn1;

watchoff

Contact us