1% rfdesign.m 2% 3% David Rowe Nov 2015 4% 5% Helper functions for RF Design 6 71; 8 9 10% convert a parallel R/X to a series R/X 11 12function Zs = zp_to_zs(Zp) 13 Xp = j*imag(Zp); Rp = real(Zp); 14 Zs = Xp*Rp/(Xp+Rp); 15endfunction 16 17 18% convert a series R/X to a parallel R/X 19 20function Zp = zs_to_zp(Zs) 21 Xs = imag(Zs); Rs = real(Zs); 22 Q = Xs/Rs; 23 Rp = (Q*Q+1)*Rs; 24 Xp = Rp/Q; 25 Zp = Rp + j*Xp; 26endfunction 27 28 29% Design a Z match network with a parallel and series reactance 30% to match between a low and high resistance. Note Xp and Xs 31% must be implemented as opposite sign, ie one a inductor, one 32% a capacitor (your choice). 33% 34% /--Xs--+---\ 35% | | | 36% Rlow Xp Rhigh 37% | | | 38% \------+---/ 39% 40 41function [Xs Xp] = z_match(Rlow, Rhigh) 42 assert(Rlow < Rhigh, "Rlow must be < Rhigh"); 43 Q = sqrt(Rhigh/Rlow -1); 44 Xs = Q*Rlow; 45 Xp = Rhigh/Q; 46endfunction 47 48 49% Design an air core inductor, Example 1-5 "RF Circuit Design" 50 51function Nturns = design_inductor(L_uH, diameter_mm) 52 Nturns = sqrt(29*L_uH/(0.394*(diameter_mm*0.1/2))); 53endfunction 54 55 56% Work out series resistance Rl of series resonant inductor. Connect 57% tracking generator to spec-an input, the series LC to ground. V is 58% the ref TG level (e.g. with perfect 50 ohm term) in volts, Vmin is the 59% minumum at series res freq. 60% 61% /-50-+---+ 62% | | | 63% TG C 50 spec-an 64% | | | 65% | L | 66% | | | 67% | Rl | 68% | | | 69% \----+---/ 70 71function Rl = find_rl(V,Vmin) 72 % at series resonance effect of C and L goes away and we are left with 73 % parallel combination of Ls and spec-an 50 ohm input impedance 74 75 Rp = Vmin*50/(2*V*(1-Vmin/(2*V))); 76 Rl = 1/(1/Rp - 1/50) 77endfunction 78