No BSD License  

Highlights from
BPSK Simulator for Low Rate Transmisions

image thumbnail
from BPSK Simulator for Low Rate Transmisions by César Delgado González
BPSK Simulator for didactical purposes. Systemic coding style.

creaGuiVisual.m
%------------------------------------------------------------------------
%|  	creaGuiVisual
%------------------------------------------------------------------------
%|      Script que genera todos los controles de la visualizacin
%------------------------------------------------------------------------
%|   Autor: Cesar Delgado
%|   Fecha: 19-Abril-2.004
%------------------------------------------------------------------------

%         1.- CREACIN CHECKBOXES
%#####################################

%           1.1.- Posiciones y Titulos
%-------------------------------------
titulos = {'GRFICA SUPERIOR', 'Mantener Grfica', 'Grid', ' ';
           'GRFICA INFERIOR', 'Mantener Grfica', 'Grid', ' ' ;};
ptosObsv = ['TX: Salida | TX: PAM I | TX: PAM Q | TX: Linea I | TX: Linea Q | '];
ptosObsv = [ptosObsv 'RX: Decisor | RX: Linea | RX: Portadora | RX: Out Divisor | '];
ptosObsv = [ptosObsv 'RX: In Divisor | RX: Salida PLL | RX: Error PLL | '];
ptosObsv = [ptosObsv 'RX: Comp. Fase PLL | RX: Fase Estimada PLL | RX: Referencia PLL '];

ptosObsvLab =' RX: Seal I | RX: Seal Q | RX: Seal I Compensada | ';
ptosObsvLab = [ptosObsvLab 'RX: Seal Q Compensada | RX: Decisor  | ' ];
ptosObsvLab = [ptosObsvLab 'RX : Fase Estimada |  RX :  Error de Fase ' ];

tipoVisual = ' Tiempo | Frecuencia ';

%       Left ,  Bottom ,  Width,   Height
pos = [0.6860, 0.27     ,  0.2 ,  0.035];
tamPops = [0.18, 0.035; 0.1, 0.035];
tamCheck = [0.2, 0.03];
tamRadio = [0.15, 0.03];
textoBar = sprintf('1........%d........%d',round(maxTrama/2), maxTrama);
coloresA  = ' Azul | Rojo | Verde | Amarillo | Cian | Blanco | Negro ';

%           1.2.- Creacin de CheckBoxes
%---------------------------------------
for fila = 1:size(titulos,1),   
   aux = pos;
   
   % CHECKBOX : Grfica Superior/Inferior
   Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
   contEventos = contEventos+1;
   graf(fila) = uicontrol('Style','Checkbox', ...
      'Units','normalized', ...
      'Position',pos, ...
      'String',char(titulos(fila,1)),...
      'FontWeight','bold',...
      'FontAngle','italic',...
      'Background',[.7 .7 .7],...
      'Foreground',[0 0 0],...
      'Callback',Texto); 
   
   % POPUP MENU: Pto. Observacin
   pos = [pos(1), pos(2)-tamCheck(2)-0.01, tamPops(1,1), tamPops(1,2)];
   Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
   contEventos = contEventos+1;
   ptoObsv(fila, 1) = uicontrol('Style','popupmenu',...
       'Units','normalized',...
       'String',ptosObsv,...
       'HorizontalAlignment', 'left',...
       'FontWeight','normal',...
       'Position',pos, ...
       'Backgroundcolor',[.8 .8 .8], ...
       'Callback',Texto);
   
   % POPUP MENU: Pto. Observacin en seales del laboratorio
   Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
   contEventos = contEventos+1;
   ptoObsv(fila, 2) = uicontrol('Style','popupmenu',...
       'Units','normalized',...
       'String',ptosObsvLab,...
       'HorizontalAlignment', 'left',...
       'FontWeight','normal',...
       'Position',pos, ...
       'Backgroundcolor',[.8 .8 .8], ...
       'Enable','Off',...
       'Visible','Off',...
       'Callback',Texto); 
   
    % POPUP MENU: Tiempo / Frecuencia 
    pos = [pos(1)+tamPops(1,1)+0.01, pos(2), tamPops(2,1), tamPops(2,2)];
    
    Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
    contEventos = contEventos+1;
    
    verFreq(fila) = uicontrol('Style','popupmenu',...
       'Units','normalized',...
       'String',tipoVisual,...
       'HorizontalAlignment', 'left',...
       'FontWeight','normal',...
       'Position',pos, ...
       'Backgroundcolor',[.8 .8 .8], ...
       'Callback',Texto);
   
    for col = 2:size(titulos,2),
       % RADIO BUTTONS: Mantener Grfica, Grid       
       if col<4,
          pos = [aux(1),  pos(2)-(tamRadio(2)+0.004) - 0.001*(fila==2), ...
                  tamRadio(1), tamRadio(2)];                     
             
           Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
           contEventos = contEventos+1;
           radioBut(fila, col-1) = uicontrol('Style','radiobutton',...
                   'Units','normalized',...
                   'String',char(titulos(fila,col)),...
                   'HorizontalAlignment', 'left',...
                   'FontWeight','normal',...          
                   'Position',pos, ...
                   'Backgroundcolor',[.8 .8 .8], ...
                   'Callback',Texto);
       else,
             % POPUP MENU: Colores    
              pos = [pos(1)+tamRadio(1)+0.04, ...
                    pos(2)+ (tamRadio(2)), ...
                    tamPops(2,1), tamPops(2,2)];
              Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
              contEventos = contEventos+1;

              colores(fila) =  uicontrol('Style','popupmenu',...
                 'Units','normalized',...
                 'String',coloresA,...
                 'HorizontalAlignment', 'left',...
                 'FontWeight','normal',...
                 'Position',pos, ...
                 'Backgroundcolor',[.8 .8 .8], ...
                 'Callback',Texto); 
              pos = [pos(1), pos(2) - (tamRadio(2)+0.007), ...
                     tamPops(2,1), tamPops(2,2)];
       end;
                
   end;
   pos = [aux(1), pos(2)-0.04, tamCheck(1), tamCheck(2)];          
end;


% 2.- CREACIN DE BARRA DESLIZANTE PARA SELECCIN DE TRAMA
%#########################################################

%      2.1.- Ttulo
%-----------------------------
pos = [0.6860, 0.32    ,  0.07 ,  0.035];
uicontrol('Style','text',...
	        'Units','normalized',...
           'String','TRAMA:',...
           'HorizontalAlignment', 'left',...
           'FontWeight','normal',...
           'FontName','Arial Black',...
           'FontAngle','italic',...
           'FontSize',8,...
           'Position',pos, ...
           'Foregroundcolor',[0.502 0 0], ...
           'Backgroundcolor',[.7 .7 .7]);       
         
%      2.2.- Editable con nmero trama
%-------------------------------------
pos = [pos(1)+0.06, pos(2), 0.035, 0.035];
Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
contEventos = contEventos+1;
editTrama = uicontrol('Style','edit',...
       'Units','normalized',...
       'Position',pos, ... 
       'String',num2str(nTrama),...
       'Enable','on',...
       'Foregroundcolor',[0 0 0],...
       'Backgroundcolor',[1 1 1],...
       'Callback',Texto);     
    
pos = [pos(1)+pos(3)+0.0005, pos(2), 0.02, 0.035];    
uicontrol('Style','text',...
	        'Units','normalized',...
           'String',' x ',...
           'HorizontalAlignment', 'left',...
           'FontWeight','normal',...
           'FontName','Arial Black',...
           'FontAngle','normal',...
           'FontSize',8,...
           'Position',pos, ...
           'Foregroundcolor',[0.502 0 0], ...
           'Backgroundcolor',[.7 .7 .7]);       
         
 pos = [pos(1)+pos(3), pos(2), 0.035, 0.035];    
 Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
 contEventos = contEventos+1;
 editBitsTrama = uicontrol('Style','edit',...
       'Units','normalized',...
       'Position',pos, ... 
       'String',num2str(bitsTrama),...
       'Enable','on',...
       'Foregroundcolor',[0 0 0],...
       'Backgroundcolor',[1 1 1],...
       'Callback',Texto);     
     
pos = [pos(1)+pos(3)+0.001, pos(2)-0.003, 0.02, 0.035];    
uicontrol('Style','text',...
	        'Units','normalized',...
           'String','bits',...
           'HorizontalAlignment', 'left',...
           'FontWeight','normal',...
           'FontName','Arial',...
           'FontAngle','normal',...
           'FontSize',8,...
           'Position',pos, ...
           'Foregroundcolor',[0.502 0 0], ...
           'Backgroundcolor',[.7 .7 .7]);       

    

%      2.3.- Barra deslizante con n Trama
%------------------------------------------
pos = [pos(1)+0.03, 0.32 ,  0.13 ,  0.035];
Texto = sprintf('evento=%d; actualizaInterfaz;', contEventos);
contEventos = contEventos+1;
barraTrama = uicontrol('Style','Slider', ...
	'Units','normalized', ...
   'Position',pos, ...
   'Background',[.8 .8 .8],...
   'Max',maxTrama,...
   'SliderStep', [1/maxTrama 1.01/maxTrama],...
   'Min',1,...
   'Value',1,...
   'Callback',Texto);

pos = [pos(1)+0.015, pos(2)-0.05 0.13 0.05];
textoBarra = uicontrol('Style','text',...
	        'Units','normalized',...
           'String',textoBar,...
           'HorizontalAlignment', 'left',...
           'FontWeight','normal',...
           'FontName','Arial',...
           'FontAngle','normal',...
           'FontSize',8,...
           'Position',pos, ...
           'Foregroundcolor',[0.502 0 0], ...
           'Backgroundcolor',[.7 .7 .7]);       


% 3.- ELIMINAMOS VARIABLES INTILES
%#####################################
clear titulos ptosObsv tamPops tamCheck tamRadio tipoVisual
clear pos aux Texto fila col coloresA textoBar

Contact us at files@mathworks.com