%Interactive MATLAB Animations for
%"UNDERSTANDING SEMICONDUCTOR DEVICES"
%Oxford University Press, New York, 2000
%by Sima Dimitrijev

%   Sima Dimitrijev, October 19, 1999.
%   Copyright (c) 2000, Oxford University Press.

%Open parent figure
Hf=figure('NumberTitle','off','Name','USD','Color','k',...
   'MenuBar','none');
set(gcf,'InvertHardCopy','off');
Ha2_usd=axes('XLim',[0 1],'YLim',[0 1],'Visible','off','Position',[0 0 1 1]);

hold on;
xx=[0:100]/100;
yy=(1/3.14)*atan(5*(0.5-xx))+0.4;
yy2=yy+0.008;
Hp_usd2=plot(xx,yy2,'r-','LineWidth',0.5);
yy3=yy+0.02;
Hp_usd3=plot(xx,yy3,'r-','LineWidth',0.5);
yy4=yy+0.045;
Hp_usd4=plot(xx,yy4,'r-','LineWidth',0.5);

xsh=0.1*gradient(yy)/(-0.0022);
for ii=1:500;
xx5s=rand(1,1);   
xx5(ii)=xx5s+((-1)^ii)*xsh(ceil(xx5s*100));
if xx5(ii)<0; xx5(ii)=xx5(ii)+1; end
if xx5(ii)>1; xx5(ii)=xx5(ii)-1; end
xx5(ii)=xx5(ii)*1.1-0.05;
yb=(1/3.14)*atan(5*(0.5-xx5(ii)))+0.4;   
yy5(ii)=-0.1*log(rand(1,1))*(1-yb)+yb;
end
Hp_usd5=plot(xx5,yy5,'y.','MarkerSize',25);
set(Hp_usd5,'Color',[0.55 0.55 0]);

Hpatch_usd1=patch([0,0,xx,1,1,0], [0,yy(1),yy,yy(100),0,0],[0 0 0.4]);
Hp_usd1=plot(xx,yy,'r-','LineWidth',2);

%Set the items text
seclist={'Section 1.3.1: The Concept of Diffusion';...
         'Section 1.3.3: Making an IC Resistor';...     
         'Section 1.3.4: Visualization of Diffusion Models and Process Simulation';...
         'Section 1.4.1: Drift Velocity';...
         'Sections 1.4.2/1.4.3: Mobility Dependence on Temperature and Doping';...   
         'Section 1.4.4: Haynes-Shockley Experiment';...
         'Section 1.5.2: Fermi-Dirac Distribution and Fermi Level';...   
         'Section 1.5.3: Drift Current in Energy-Band Presentation';...
         'Section 2.2: P-N Junction Energy Bands and Capacitance';...
         'Section 2.4: SPICE Model and Parameters of P-N Junction Capacitor';...   
         'Sections 2.5.3-2.5.5: MOS capacitor';...   
         'Section 3.1: Diode Principles';...
         'Section 3.2.2: Stored-Charge Related Transient Effects';...
         'Section 3.2: Diode Calculator (SPICE Model)';...   
         'Sections 5.1.2/5.1.3: MOSFET Principles';...
         'Section 5.2.1: Ion Implantation Models and Process Simulation';...
         'Section 5.4.1: MOSFET Calculator (SPICE LEVEL3 Model)';...
         'Sections 6.1 and 6.3: BJT Principles and Modeling';...
         'Section 6.4: BJT Calculator (SPICE Model)'};
   
constart_usd=2;

Hlist=uicontrol(Hf,'Style','listbox','Background','w','String',seclist,...
   'Units','normalized','Position',[0.1 0.25 0.8 0.3],'FontSize',12);
Hb_start=uicontrol(Hf,'Units','normalized','Position',[0.2 0.05 0.25 0.15],...
   'Style','pushbutton','String','START','CallBack','constart_usd=1;','FontSize',12,...
   'FontWeight','bold');
Hb_exit=uicontrol(Hf,'Units','normalized','Position',[0.55 0.05 0.25 0.15],...
   'Style','pushbutton','String','EXIT','CallBack','constart_usd=0;','FontSize',12,...
   'FontWeight','bold');

Ht0=text('Position',[0.95 0.95 0],'String',...
        ['INTERACTIVE MATLAB ANIMATIONS FOR'],...
        'Units','normalized','FontSize',18,...
        'FontAngle','Normal','Color','y','FontName','TimesRoman',...
        'HorizontalAlignment','right','FontWeight','bold');
Ht1=text('Position',[0.95 0.875 0],'String',...
        ['Understanding Semiconductor Devices'],...
        'Units','normalized','FontSize',24,...
        'FontAngle','Italic','Color','y','FontName','TimesRoman',...
        'HorizontalAlignment','right','FontWeight','bold');
Ht2=text('Position',[0.95 0.78 0],'String',...
        ['\copyright Oxford University Press, New York, 2000.'],...
        'Units','normalized','FontSize',16,...
        'FontAngle','Italic','Color','y','FontName','TimesRoman',...
        'HorizontalAlignment','right','FontWeight','bold');      
Ht3=text('Position',[0.95 0.65 0],'String',...
        ['    Sima Dimitrijev';...
         'Griffith University'],...
        'Units','normalized','FontSize',18,...
        'FontAngle','Normal','Color','r','FontName','TimesRoman',...
        'HorizontalAlignment','right','FontWeight','bold');      
hold off;

while constart_usd>0; %When constart_usd=0, exit.
   
   if ishandle(Hf)==0;
      return;
   end   
   pause(0.5);
   if ishandle(Hf)==0;
      return;
   end 
   
if constart_usd==1; %Clicking on the list items should result with constart_usd=2
   constart_usd=2;
   set(Hb_start,'Enable','off'); 
   set(Hb_exit,'Enable','off');
   
   switch get(Hlist,'Value');
   case 1;
      global whcon1_usd1; global whcon2_usd1; global whcon3_usd1; global whcon4_usd1;
      diff_usd;
      clear global;
      
   case 2;   
      global con_exit_usd2; global con_go_usd2; 
      global con_sl_brght_usd2; global con_pr_list_usd2;
      icrs_usd;
      clear global;
      
   case 3;
      global con_exit_usd3; global con_stop_usd3; global con_start_usd3; 
      global con_sl_ener_usd3; global con_r_pr_usd3; 
      global con_sl_temp_usd3; 
      global con_sl_sub_usd3; global con_r_el_usd3;
      global con_sl_brght_usd3; global con_sl_time_usd3; global con_pr_list_usd3;
      introtext ={'UNDERSTANDING SEMICONDUCTOR DEVICES ';...
      'Section 1.3.4: Visualization of Diffusion Models and Process Simulation' ;...
      ' ';...
      'DO IT YOURSELF - select doping elements, set diffusion temperature, ';...
      'control the diffusion time, and watch 1D and 2D doping profiles. ';...
      'Can have any combination of deposition diffusion (up to 3) and '; ... 
      'drive-in diffusion steps.'};
      dpng_usd(introtext);
      clear global;
      
   case 4;
      global con_m_usd4; global con_t_usd4; global con_d_usd4; global con_start_usd4; 
      global con_stop_usd4; global con_close_usd4; global con_e_usd4; global con_go_usd4;
      vdr_usd;
      clear global;
      
   case 5;
      global con_m_usd5; global con_t_usd5; global con_d_usd5; global con_start_usd5; 
      global con_stop_usd5; global con_close_usd5; global con_e_usd5; global con_go_usd5;
      global con_r_usd5;
      mu_usd;
      clear global;

   case 6;
      global hsecon1_usd6; global hsecon3_usd6; global hsecon4_usd6;
      hse_usd;
      clear global;
      
   case 7;
      global con_sl_usd7; 
      global con_b_usd7; global con_go_usd7; global con_b_ex_usd7;
      ef_usd;
      clear global;
      
  case 8;
      global debcon1_usd8; global debcon2_usd8; global debcon3_usd8; global debcon4_usd8; global debcon5_usd8;
      rseb_usd;
      clear global;
      
   case 9;
      global con_vg_usd18; global con_vds_usd18; 
      global con_r_usd18; global con_start_usd18; 
      global con_close_usd18; global con_br_usd18; 
      global con_sl_usd18;
      capr_usd;
      clear global;
      
   case 10;
      global conW_usd14; global conEXP_usd14; 
      global con_go_usd14; 
      casp_usd;
      clear global;
      
   case 11;   
      global uf_usd11; global con_vg_usd11; 
      global con_close_usd11; global con_doping_usd11;
      global con_ox_usd11; global con_gate_usd11;
      global con_chrg_usd11; global con_lfhf_usd11;
      global con_stp_usd11; global con_strt_usd11;
      global con_br_usd11;
      mosc_usd;
      clear global;
      
   case 12;
      global con_vg_usd17; global con_vds_usd17; global con_r_usd17;
      global con_start_usd17; global con_close_usd17; 
      global con_br_usd17; global con_sl_usd17;
      dipr_usd;
      clear global;

   case 13;
      global debcon1_usd9; global debcon3_usd9; global debcon4_usd9; global debcon5_usd9;
      introtext ={'UNDERSTANDING SEMICONDUCTOR DEVICES ';...
      'Section 3.2.2: Stored-Charge Related Transient Effects' ;...
      ' ';...      
      'Start the animation with zero bias and observe for a while the flow of';... 
      'majority and minority electrons and holes through the P-N junction.';...
      'Note that the P-N junction barrier balances the number of minority ';...
      'and majority carriers able to go through the junction.';...
      ' ';...
      'Change the bias voltage to positive and note that this reduces the '; ...
      'barrier height, enabling many majority carriers to go over the barrier.';...
      'Noting that the "sparks" indicate electron-hole recombination,';...
      'observe how this leads to a gradient in the excess minority ';...
      'carrier concentration. (Excess minority carriers are differently';...
      'colored.)';...
      ' ';...     
      'Remembering that the differently colored particles are the excess ';...
      'minority carriers (stored charge), change the voltage to negative,'; ... 
      'and observe the mechanisms of stored-charge removal: ';...
      '(i) recombination and (ii) a flow of excess minority carriers back'; ...
      'to the original regions. Note that this causes a transient';...
      'negative current.'};   
      pn_usd(introtext);
      clear global;
      
   case 14; 
      global conW_usd15; 
      global con_go_usd15; global conLIN_usd15;
      disp_usd;
      clear global;
      
   case 15;    
      global con_vg_usd10; global con_vds_usd10; 
      global con_r_usd10; global con_start_usd10; 
      global con_close_usd10; global con_br_usd10;
      global con_go_usd10;
      mfet_usd;
      clear global;
      
  case 16;
      global con_exit_usd3; global con_stop_usd3; global con_start_usd3; 
      global con_sl_ener_usd3; global con_r_pr_usd3; 
      global con_sl_temp_usd3; 
      global con_sl_sub_usd3; global con_r_el_usd3;
      global con_sl_brght_usd3; global con_sl_time_usd3; global con_pr_list_usd3;
      introtext ={'UNDERSTANDING SEMICONDUCTOR DEVICES ';...
      'Section 5.2.1: Ion Implantation Models and Process Simulation' ;...
      ' ';...
      'DO IT YOURSELF - select doping elements, set ion implant energy, ';...
      'control the implant dose, and watch 1D and 2D doping profiles. ';...
      'Can have any combination of ion implant and deposition diffusion '; ... 
      '(up to 3) and drive-in diffusion steps.'};
      dpng_usd(introtext);
      clear global;
      
   case 17;      
      global conW_usd13; global conNP_usd13; 
      global con_go_usd13; global conLIN_usd13;
      mosp_usd;
      clear global;
      
   case 18;
      global convbe_usd12; global convcb_usd12; global conr_usd12; 
      global con_start_usd12; global con_close_usd12; global con_n_usd12; 
      global con_m_usd12; global con_q_usd12; global con_go_usd12;
      bjt_usd;
      clear global;
      
   case 19;
      global conW_usd16; 
      global con_go_usd16; global conLIN_usd16;
      bjts_usd;
      clear global;
   end   
   
   
if ishandle(Hf)==0;
   return;
end   
set(Hb_start,'Enable','on'); 
set(Hb_exit,'Enable','on');   
end %if   
end %while   
close;

