Code covered by the BSD License  

Highlights from
Logiciels temps réel

Logiciels temps réel

by

 

Real-time software concerning the domains of the signal processing, feedback and regulation

ouvre_tt_x_y.m
function [MOG,DEF,G]=ouvre_tt_x_y(MOGi,DEFi,Gi)

MOG=MOGi;
DEF=DEFi;
G=Gi;
DEF(1)=2;
switch DEF(8)
    case 3
        modele='table_y_x';
    case 4
        modele='table_y_x_diff';
end;
repertoire=pwd;
cd ..
A=load('parametres_carte.mat');
cd(repertoire)
carte_entree=A.S.entree.carte;
plage_entree=num2str(A.S.entree.pop);
open_system([modele,'.mdl'])
set_param(gcs,'solver','FixedStepDiscrete')
set_param(gcs,'StartTime','0') 
set_param(gcs,'StopTime','Inf')
set_param(gcs,'SystemTargetFile','rtwin.tlc') 
s=modele;
sbai=[s,'/Analog Input'];
set_param(sbai,'drvname',carte_entree);
set_param(sbai,'voltrange',plage_entree);
sbai1=[s,'/Analog Input1'];
set_param(sbai1,'drvname',carte_entree);
set_param(sbai1,'voltrange',plage_entree);
switch DEF(8)
    case 3
        set_param(sbai,'drvoptions','[0 0 0 0 0]');
        set_param(sbai1,'drvoptions','[0 0 0 0 0]');
       
    case 4
        set_param(sbai,'drvoptions','[1 0 0 0 0]');
        set_param(sbai1,'drvoptions','[1 0 0 0 0]');
        
end;
set_param(gcs,'SimulationMode','external');
set_param(gcs,'ExtMode','on');
duration=10000;
set_param(gcs,'ExtModeTrigDuration',duration);
bloc=[modele,'/XY Graph'];
set_param(bloc,'Nb_Pt','10000');
h=get_param(bloc,'userdata');
%************************************************
%  paramtrage de la scope figure
%************************************************
if ~ishandle(h)
    e=ecran;
    FigHandle = figure('Units',          'pixel',...
                   'Position',       e,...
                   'Name',           'XY Graph',...
                   'Tag',            'SIMULINK_XYGRAPH_FIGURE',...
                   'NumberTitle',    'off',...
                   'IntegerHandle',  'off',...
                   'Toolbar',        'none',...
                   'Menubar',        'none',...
                   'DeleteFcn',      'sfunxy([],[],[],''DeleteFigure'')');
    ud.Block=bloc;
    ud.XYAxes   = axes;
    ud.XYLine   = plot(0,0,'EraseMode','None');
    ud.XYXlabel = xlabel('X Axis');
    ud.XYYlabel = ylabel('Y Axis');
    ud.XYTitle  = get(ud.XYAxes,'Title');
    ud.XData    = [];
    ud.YData    = [];
    set(ud.XYAxes,'Xtick',-10:1:10,'XTickLabel',num2str((-10:1:10)'),...
        'YTick',-7:1:7,'YTickLabel',num2str((-7:1:7)'),...
        'unit','normalized','position',[0.05 0.475 0.5 0.5],...
        'color',[0 0 0],'xcolor',[0.5  0.5 0.5],'ycolor',[0.5  0.5 0.5]);
    set(ud.XYLine,'color',[1 1 0]);
    set_param(bloc,'userdata',FigHandle)
    set(FigHandle,'HandleVisibility','callback','UserData',ud);
    MOG(6,1)=ud.XYAxes;
    MOG(1,6)=FigHandle;
end;
set(MOG(1,6),'color','w','unit','normalized')
n_fig=get(MOG(1,6),'name');
% On affiche dans le titre
% la position du zro de chaque voie

zx=get_param([get_param(gcs,'name'),'/Constant'],'value');
zy=get_param([get_param(gcs,'name'),'/Constant1'],'value');
 n_fig=[n_fig,'   VOIE X : zro = ',zx,' cm  ;  VOIE Y : zro = ',zy,' cm'];
pause(0.1)
set(MOG(1,6),'name',n_fig);
p_fe=[0.6,0.9,0.2,0.1];
% choix de la BdT
txt_fe=uicontrol(MOG(1,6),'style','text','unit','normalized',...
		            'position',p_fe,'backgroundcolor','w',...
	                'foregroundcolor','b','fontunits','normalized','fontsize',0.3,...
                    'fontweight','bold',...
                    'string','Fe (Hz) : Fe <= 1 000 Hz');
txt_leg= uicontrol(MOG(1,6),'style','text','unit','normalized',...
		            'position',[0.6,0.8,0.25,0.05],'backgroundcolor','w',...
	                'foregroundcolor','b','fontunits','normalized','fontsize',0.4,...
                    'fontweight','bold','fontangle','italic',...
                    'string','Nombre de points affichs limit  10 000');
txt_leg2= uicontrol(MOG(1,6),'style','text','unit','normalized',...
		            'position',[0.6,0.75,0.25,0.05],'backgroundcolor','w',...
	                'foregroundcolor','b','fontunits','normalized','fontsize',0.4,...
                    'fontweight','bold','fontangle','italic',...
                    'string','(Exemple : si Fe = 400 Hz, on affiche');     
txt_leg3= uicontrol(MOG(1,6),'style','text','unit','normalized',...
		            'position',[0.6,0.725,0.25,0.05],'backgroundcolor','w',...
	                'foregroundcolor','b','fontunits','normalized','fontsize',0.4,...
                    'fontweight','bold','fontangle','italic',...
                    'string','les 25 dernires secondes)');     
                
p_edit=[0.6,0.85,0.1,0.05];
 if MOG(1,2)~=0
        s=get(MOG(1,2),'string');
    else
        s='400';
    end;
MOG(1,2)=uicontrol(MOG(1,6),'style','edit','unit','normalized','position',p_edit,...
                    'string',s,'backgroundcolor','y',...
	                'foregroundcolor','b','fontunits','normalized','fontsize',0.5,...
                    'fontweight','bold',...
  'callback','s=get(MOG(1,2),''string'');fe=str2num(s);if fe>1000 fe=1000;set(MOG(1,2),''string'',num2str(fe));end;DEF(4)=1/fe;');                
choix_calibre_y={'','2 V/cm','1 V/cm','0,5 V/cm','0,2 V/cm','0,1 V/cm','50 mV/cm','20 mV/cm','VAR'};
calibre_y=[2,1,0.5,0.2,0.1,0.05,0.02,1];
%  choix calibres
k=1;
    p_y=[0.25*(k-1)+0.125,0.35,0.1,0.1];
    s=['VOIE X'];
    txt_y_titre=uicontrol(MOG(1,6),'style','text','unit','normalized',...
		            'position',p_y,'backgroundcolor','w',...
	                'foregroundcolor','b','fontunits','normalized','fontsize',0.25,'fontweight','bold','string',s);
    p_p=[0.25*(k-1)+0.125,0.30,0.1,0.1];   
    MOG(1+k,2)=uicontrol(MOG(1,6),'style','popupmenu','unit','normalized','position',p_p,...
                    'string',choix_calibre_y,'backgroundcolor','w',...
	                'foregroundcolor','r','fontunits','normalized','fontsize',0.25,'fontweight','bold');
 k=2;
    p_y=[0.25*(k-1)+0.125,0.35,0.1,0.1];
    s=['VOIE Y'];
    txt_y_titre=uicontrol(MOG(1,6),'style','text','unit','normalized',...
		            'position',p_y,'backgroundcolor','w',...
	                'foregroundcolor','b','fontunits','normalized','fontsize',0.25,'fontweight','bold','string',s);
    p_p=[0.25*(k-1)+0.125,0.30,0.1,0.1];   
    MOG(1+k,2)=uicontrol(MOG(1,6),'style','popupmenu','unit','normalized','position',p_p,...
                    'string',choix_calibre_y,'backgroundcolor','w',...
	                'foregroundcolor','r','fontunits','normalized','fontsize',0.25,'fontweight','bold');      
% Filtrage ?
MOG(12,1)=uicontrol(MOG(1,6),'style','text','unit','normalized','position',[0.02,0.18,0.06,0.05],...
           'backgroundcolor','w','string','Filtrage ?','foregroundcolor','b','fontunits','normalized','fontsize',0.4,'fontweight','bold');

k=1;
    p_p=[0.25*(k-1)+0.125,0.18,0.05,0.03]; 
    s={'','NON','OUI'};
    MOG(12,2+k)=uicontrol(MOG(1,6),'style','popupmenu','unit','normalized','position',p_p,'userdata',k,...
                    'backgroundcolor','w','string',s,'foregroundcolor','r','fontunits','normalized','fontsize',0.6,'fontweight','bold',...
                    'callback','K=get(gco,''userdata'');MOG=nombre_point(MOG,K);'); 
k=2;
p_p=[0.25*(k-1)+0.125,0.18,0.05,0.03]; 
    s={'','NON','OUI'};
    MOG(12,2+k)=uicontrol(MOG(1,6),'style','popupmenu','unit','normalized','position',p_p,'userdata',k,...
                    'backgroundcolor','w','string',s,'foregroundcolor','r','fontunits','normalized','fontsize',0.6,'fontweight','bold',...
                    'callback','K=get(gco,''userdata'');MOG=nombre_point(MOG,K);'); 
% rglage zros                
for k=1:1:2
   p_p=[0.25*(k-1)+0.125,0.34,0.05,0.03]; 
    MOG(3,2+k)=uicontrol(MOG(1,6),'style','push','unit','normalized','position',p_p,'userdata',k,...
                    'backgroundcolor','w','string',['+1cm'],'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
                    'callback','K=get(gco,''userdata'');MOG=regle_zero_xy(3,K,G,MOG);'); 
   p_p=[0.25*(k-1)+0.125,0.30,0.05,0.03]; 
    MOG(4,2+k)=uicontrol(MOG(1,6),'style','push','unit','normalized','position',p_p,'userdata',k,...
                    'backgroundcolor','w','string',['-1cm'],'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
                    'callback','K=get(gco,''userdata'');MOG=regle_zero_xy(4,K,G,MOG);');   
     p_p=[0.25*(k-1)+0.175,0.34,0.05,0.03]; 
    MOG(5,2+k)=uicontrol(MOG(1,6),'style','push','unit','normalized','position',p_p,'userdata',k,...
                    'backgroundcolor','w','string',['+1/2mm'],'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
                    'callback','K=get(gco,''userdata'');MOG=regle_zero_xy(5,K,G,MOG);'); 
   p_p=[0.25*(k-1)+0.175,0.30,0.05,0.03]; 
    MOG(6,2+k)=uicontrol(MOG(1,6),'style','push','unit','normalized','position',p_p,'userdata',k,...
                    'backgroundcolor','w','string',['-1/2mm'],'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
                    'callback','K=get(gco,''userdata'');MOG=regle_zero_xy(6,K,G,MOG);');  
    p_p=[0.25*(k-1)+0.05,0.32,0.05,0.03];
    MOG(2,2+k)=uicontrol(MOG(1,6),'style','text','unit','normalized','position',p_p,...
                    'backgroundcolor','w','string','ZERO','foregroundcolor','b','fontunits','normalized','fontsize',0.6,'fontweight','bold');
end;
MOG(8,1)=uicontrol(MOG(1,6),'style','push','unit','normalized',...
		'position',[0.9 0.9 0.1 0.05],...
	    'string','OK','foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
        'callback','[MOG,DEF,G]=lance_tt_xy(MOG,DEF,G);');
MOG(9,1)=uicontrol(MOG(1,6),'style','push','unit','normalized',...
		'position',[0.9 0.8 0.1 0.05],...
	    'string','STOP','foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
        'callback','[MOG,DEF,G]=stop_tt(MOG,DEF,G);');
MOG(10,1)=uicontrol(MOG(1,6),'style','push','unit','normalized',...
		'position',[0.9 0.7 0.1 0.05],...
	    'string','MENU','foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
        'callback','close_system(gcs,0);[MOG,DEF,G]=table_menu(MOG,DEF,G);');

MOG(11,1)=uicontrol(MOG(1,6),'style','push','unit','normalized',...
		'position',[0.9 0.6 0.1 0.05],...
	    'string','FIN','foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
        'callback','[MOG,DEF,G]=stop_tt(MOG,DEF,G);close_system(gcs,0);cd ..;');

Contact us