⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amp_design_2.m

📁 spread spectrum communication will be helpful to you!
💻 M
字号:
% RF amplifier design example using S parameters measured with HP 8505A system. 
% Reference: 
%        Quick Amplifier Design with Scattering Parameters
%        William H. Froehner, Texas Instruments Inc. 
%        Electronics, October 16, 1967.   
%
% Dick Benson, The MathWorks Inc. 
%
clc
clear
    % specify amplifier design goals, gain and center frequency
    fmin = 145;           % freq range of interest in MHz,  for this example, it happens to be a single freq  
    fmax = 1000;          % not needed if df==0
    df   =  0 ;           % since df == 0 s_extract ignores fmax
    [st,f] = s_extract('mrf904_10_10a.rfa',fmin,fmax,df);  % st = S parameters of Transistor, f is a freq vector 
    L      = length(f);   % typically 1
    Gp_dB = 20;           % design goal gain in dB
    Gp = 10^(Gp_dB/10);   % design goal gain (linear units)



% compute Linville stability factor K
D = (st(1,1).s .* st(2,2).s) - (st(1,2).s .* st(2,1).s);  % eq 22
K = real((1 + abs(D).^2 - abs(st(1,1).s).^2   -  abs(st(2,2).s).^2 ) ./ (2*abs((st(2,1).s .* st(1,2).s))));  % eq 15
if length(K) > 1
   figure('name','stability factor K');  % Plot K as a function of f. Not relevent for scalar (single) freq 
   plot(f,K);   
end;

% compute stability circles 
 B1 = 1 + abs(st(1,1).s).^2  - abs(st(2,2).s).^2 - abs(D).^2;   % eq 24
 B2 = 1 + abs(st(2,2).s).^2  - abs(st(1,1).s).^2 - abs(D).^2;   % eq 26
 C1 = st(1,1).s - D.*conj(st(2,2).s);                           % eq 20
 [mC1,pC1]=cmplx2magphase(C1);                                  % magnitude, phase of C1 

 C2 = st(2,2).s - D.*conj(st(1,1).s);                           % eq 21
 [mC2,pC2]=cmplx2magphase(C2);                                  % magnitude and phase of C2

 center_input = conj(C1) ./ (abs(st(1,1).s).^2  - abs(D).^2);   % eq 16, center on input plane 
 rad_input    = abs(st(1,2).s .* st(2,1).s) ./ (abs(st(1,1).s).^2  - abs(D).^2);   % eq 17 radius on input plane
 
 center_output = conj(C2) ./ (abs(st(2,2).s).^2  - abs(D).^2);  % eq 18, center on output plane
 [stab_center_rad,stab_center_angle] = cmplx2magphase(center_output);
 rad_output    = abs(st(1,2).s .* st(2,1).s) ./ (abs(st(2,2).s).^2  - abs(D).^2); % eq 19, radius on output plane

 % draw a smith chart 
 Zo=50;
 if 1 
  figure('name','Smith Chart','units','pixels','position',[20 20 800 700],'color',[0 0 0])
  h.smith = smith_chart('draw', [5 10 20 30 50 75 100 150 200 300 500]/Zo,...
                                [5 10 20 30 50 75 100 150 200 300 500]/Zo,...
                                Zo,...
                                [40 40 700 620]); 
 set(h.smith,'xlim',[-2,2],'ylim',[-2,2]);
 h.axis = axes('units','pixels','position',get(h.smith,'pos'),'color','none','xlim',get(h.smith,'xlim'),'ylim',get(h.smith,'ylim'));  
end;
%           red   green  blue   vio    wht    cyan   yellow
colors = [1 0 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1; 1 1 0;];
 
theta = 0: pi/20 : 2*pi;

 % Gmax calculation only valid for K > 1
 if K > 1
    Gmax = (abs(st(2,1).s) ./ abs(st(1,2).s)).* abs(K - sign(B1).*(K.^2-1).^0.5)
    Gmax_dB = 10*log10(Gmax)   
   
    Rml = conj(C2) .* [B2 - sign(B2).*(B2.^2 - 4*(abs(C2).^2)).^0.5]./(2*(abs(C2).^2));
    [mag_Rml,ang_Rml]=cmplx2magphase(Rml);
    Rms = conj(C1) .* (B1 - sign(B1).*(B1.^2 - 4*(abs(C1).^2)).^0.5)./(2*(abs(C1).^2));
    [mag_Rms,ang_Rms]=cmplx2magphase(Rms);
    
    Zs_max_gain =  (Zo*(1+Rms)/(1-Rms));
    Zl_max_gain =  (Zo*(1+Rml)/(1-Rml));
    
    line('xdata',real(Rml),'ydata',imag(Rml),'color',colors(2,:),'linestyle','o');
    line('xdata',real(Rms),'ydata',imag(Rms),'color',colors(3,:),'linestyle','+');
    if Gp > Gmax
       disp('cant be built , Gp > Gmax')
    end;
 else
    Gmax    = nan;
    Gmax_dB = nan;
 end;

 
 % Use output mismatch to achieve a prescribed gain .... 
 D2 = abs(st(2,2).s).^2 - abs(D).^2;     % eq 30
 Go = abs(st(2,1).s).^2;                 % eq 32
 G = Gp./Go;                             % eq 31 
  center_const_gain_circle = (conj(C2).* G) ./(1 + D2.*G);         % eq 28
  [magcent,angcent]=cmplx2magphase(center_const_gain_circle);      
  radius_const_gain_circle = ((1 - 2*K.*abs(st(1,2).s .* st(2,1).s).*G  + abs( st(1,2).s .* st(2,1).s).^2 .* G.^2 ).^0.5)./(1 + D2.*G); % eq 29 
  
 for k=1:L
     inputcircles(k,:)  =  center_input(k)   + rad_input(k)*exp(j*theta);
     outputcircles(k,:) =  center_output(k)   + rad_output(k)*exp(j*theta);
     line('xdata',real(outputcircles(k,:)),'ydata',imag(outputcircles(k,:)),'color',colors(1,:),'linestyle','-');
     line('xdata',real(inputcircles(k,:)),'ydata',imag(inputcircles(k,:)),'color',colors(2,:) ,'linestyle','+');
     gaincircles(k,:) = center_const_gain_circle(k) + radius_const_gain_circle(k)*exp(j*theta);
     line('xdata',real(gaincircles(k,:)),'ydata',imag(gaincircles(k,:)),'color',colors(1,:),'linestyle','.');
 end;  
 
 
 % design output and input matching circuits 
 if L==1
    % choose an output load point on the gain circle with minimum magnitude of reflection coefficient point 
     k = 1;
     f = fmin*1e6;
    [Rml, index] = min(gaincircles(k,:));   % pick a point with minimum magnitude of refl.
    
    line('xdata',real(Rml),'ydata',imag(Rml),'color',colors(5,:),'linestyle','none','marker','x','markersize',10);
    
    Zl = (Zo*(1+Rml)/(1-Rml));  % this represents the optimal Zl in that it is the CONGUGATE match 
    Yl = 1/Zl;
    w=2*pi*f;  
    Yo = imag(Yl)
    if Yo < 0
        % need inductor 
        Loo = -(1/Yo)/w;
        Coo =nan;
    else
        % need capacitor 
        Coo = Yo/w;
        Loo = nan;
    end;
    
    Q  = 3.32; % pick a Q
    Yr = real(Yl);  % now for the real part 
    R2 = 1/Yr;
    [L1o,L2o,C1o,C2o] = zmatch_4(Zo, R2,Q,f);  % "o" = output
    
    
    % input match   
    Rms= conj((st(1,1).s - Rml*D)/(1-Rml*st(2,2).s));
    Zs = Zo*(1+Rms)/(1-Rms);
    Zoi = imag(Zs);
    if Zoi > 0
        % need series inductor 
        Loi = Zoi/w
        Coi =nan;
    else
        % need series capacitor 
        Coi = -1/(Zoi*w)
        Loi = nan;
    end;
    Q  = 3.32;
    R1 = real(Zs);  % 
    R2 = Zo;
    [L1i,L2i,C1i,C2i] = zmatch_4(R1,Zo,Q,f);   % "i" = input 
  
    line('xdata',real(Rms),'ydata',imag(Rms),'color',colors(4,:),'linestyle','none','marker','x','markersize',10);  % input conjugate match
    %line('xdata',real(st(1,1).s),'ydata',imag(st(1,1).s),'color',colors(1,:),'linestyle','none','marker','+','markersize',10);
    %line('xdata',real(st(2,2).s),'ydata',imag(st(2,2).s),'color',colors(2,:),'linestyle','none','marker','o','markersize',10);

    % annotate the plot
    text(-2.0,2.0,sprintf('Stability Factor K = %7.2f',K),'color',[1 1 1]);
    text(-2.0,1.9,sprintf('Center Freq  = %7.2f MHz',fmin),'color',[1 1 1]);
    text(-2.0,1.8,sprintf('Desired Gain = %7.2f dB',Gp_dB),'color',[1 1 1]);
    
    text(-2, 1.5, 'Output Stability Circle --', 'color',colors(1,:));
    text(-2, 1.4,sprintf('%5.2fdB Gain Circle ..',Gp_dB), 'color',colors(1,:));
    text(-2, 1.3, 'Output Load Point on Gain Circle X', 'color',colors(5,:));
    text(-2, 1.2, 'Input  Stability Circle ++', 'color',colors(2,:));
    text(-2, 1.1, 'Input Conjugate Match X', 'color',colors(4,:));
    
    % see zmatch_4.m  to understand values <-> component association 
    save amp_data Loi Coo L1o L2o C1o C2o L1i L2i C1i C2i
end;




                         
                        
 
 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -