Code covered by the BSD License  

Highlights from
Using S-Parameters in MATLAB & Simulink

image thumbnail
from Using S-Parameters in MATLAB & Simulink by Dick Benson
Example of rf amplifier design using S parameters in both MATLAB and Simulink.

s_plus_match_2.m
% This script takes the transistor s parameters that were measured with the HP 8505a 
% and adds the two LC matching networks where the values were previously
% computed and saved to a file. 
% To check the design, the voltage transfer function will be computed. 

% There are several ways to solve this, but here we will start by 
% transforming the s parameter two port network description to an ABCD two port (chain matrix) description. 
% Then, the LC matching netorks will be added to ech end of the transistor
% two port networks in ABCD form.  
% The advantage of using the chain matrix approach is that matrix
% multiplication gives the desired solution. The alternative would be to
% stay in s parameter form and solve the overall signal flowgraph. 
% Copywrite 2002-2010 The MathWorks, Inc. 



%% define some symbolic variables: 
clc
clear
syms Zo s11 s12 s21 s22 
% Unable to locate an accurate s to ABCD transform, so transform from 
% s to z parameters as a first step. 
z11 = Zo*((1+s11)*(1-s22)+s12*s21)/((1-s11)*(1-s22)-s12*s21);
z22 = Zo*((1+s22)*(1-s11)+s12*s21)/((1-s22)*(1-s11)-s12*s21);
z12 = Zo*2*s12/((1-s11)*(1-s22)-s12*s21);
z21 = Zo*2*s21/((1-s11)*(1-s22)-s12*s21);

% then transform from z to  ABCD ... call it the Fa 
Dz      = simple(z11*z22-z12*z21);
Fa(1,1) = simple(z11/z21);    % A 
Fa(1,2) = simple(Dz/z21);     % B
Fa(2,1) = simple(1/z21);      % C
Fa(2,2) = simple(z22/z21);    % D

disp('This converts an S parameter 2 port representation, to an ABCD or Chain Matrix representation.')
Fa         
% there is nothing "simple" about this,  it is a mess !  
% no wonder text books do not cover S <-> ABCD
           
%% With that out of the way, define input output matching network            
syms  x y Z Y s   L1 L2 C1 C2  Rl w
Z(1,1) = 1; Z(1,2) = x; Z(2,1) = 0; Z(2,2)=1;    % series impedance chain matrix 
Y(1,1) = 1; Y(1,2) = 0; Y(2,1) = y; Y(2,2)=1;    % shunt admittance chain matrix

% Build a network , same matching network topology just *happens* to be used on transistor input and output 
 Z(1,2) = L2*s;            % series L2
 Y(2,1) = C2*s;            % shunt C2
 N      = Z*Y;             % combine (series 1st)
 Z(1,2) = L1*s + 1/(C1*s); % series lC
 N      = N*Z;             % series L2, shunt C2, followed by series L1 C1
% N is now the symbolic matching network.  

load amp_data;     % pick up LC values for matching networks

% A picture is worth 1K words! 
%   ---L2i----L1i+Loi---Base-Collector---L2o----L1o--C1o--
%   |      |                           |     |            |
%   Rs    C2i                         Coo   C2o           Rl
%   |      |                           |     |            |
%   ------------------------------------------------------------
     % start at load end of circuit and terminate with a shunt conductance 
     Y(2,1)  = 1/50;                % termination  
     Nout = Y;     
     % add output matching network, note the ordering!  
     Nout = subs(N, {L1 L2 C1 C2}, {L1o L2o C1o C2o})*Nout;
     Y(2,1)  = Coo*s; % then a capacitor
     Nout  = simple(Y*Nout);
     
    %  input match network 
     Ninput = subs(N, {L1 L2 C1 C2}, {(L1i+Loi) L2i C1i C2i});
     % input series resistor representing the source Zo 
     Z(1,2) = 50; 
     Ninput = Z*Ninput;
     
 % load transistor s parameter data over a range of frequencies 
 fmin = 15;    % MHz
 fmax = 1000;  %  "
 df   = 10;    %  "
 [stx,f] = s_extract('mrf904_10_10a.rfa',fmin,fmax,df);  % get measured s parameter data for mrf904

 k=1; 
 
 for k=1:length(f)
     jw=j*2*pi*f(k)*1e6;
     % Transform the S parameter transistor data to a chain matrix
     % representation using the "F" transform derived above. 
     Ntr = double(subs(Fa, {s11 s12 s21 s22 Zo}, {stx(1,1).s(k), stx(1,2).s(k), stx(2,1).s(k), stx(2,2).s(k) 50} ));
     
     % The overall chain matrix is the product of the Input match, Transistor,
     % and Output match. 
     
     Nall = double(subs(Ninput,s,jw))*Ntr*double(subs(Nout,s,jw));
     H(k) =  2/Nall(1,1);       % the inverse of the  "A" term (in the ABCD) is the overall voltage xfer function, 
                                % need factor of 2 for the -6dB loss (a 0 dB gain amp has a 2:1 loss)
 end;    
 % plot the frequency response in dB 
 figure
 plot(f,20*log10(abs(H))); grid on;
 text(500, -30,'Note the 20 dB gain at 145 MHz')
 
                      









Contact us at files@mathworks.com