From a1339378edddeea00830c6a92fac003e2a90c5f0 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 1 Dec 2015 22:23:50 +0000 Subject: [PATCH] scripts for VHf PA git-svn-id: https://svn.code.sf.net/p/freetel/code@2498 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/rfdesign.m | 77 +++++++++++++++++++++++ codec2-dev/octave/s_param_rf.m | 53 +--------------- codec2-dev/octave/vhf_pa.m | 111 +++++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+), 50 deletions(-) create mode 100644 codec2-dev/octave/rfdesign.m create mode 100644 codec2-dev/octave/vhf_pa.m diff --git a/codec2-dev/octave/rfdesign.m b/codec2-dev/octave/rfdesign.m new file mode 100644 index 00000000..bc75b6e9 --- /dev/null +++ b/codec2-dev/octave/rfdesign.m @@ -0,0 +1,77 @@ +% rfdesign.m +% +% David Rowe Nov 2015 +% +% Helper functions for RF Design + +1; + + +% convert a parallel R/X to a series R/X + +function Zs = zp_to_zs(Zp) + Xp = j*imag(Zp); Rp = real(Zp); + Zs = Xp*Rp/(Xp+Rp); +endfunction + + +% convert a series R/X to a parallel R/X + +function Zp = zs_to_zp(Zs) + Xs = imag(Zs); Rs = real(Zs); + Q = Xs/Rs; + Rp = (Q*Q+1)*Rs; + Xp = Rp/Q; + Zp = Rp + j*Xp; +endfunction + + +% Design a Z match network with a parallel and series reactance +% to match between a low and high resistance. Note Xp and Xs +% must be implemented as opposite sign, ie one a inductor, one +% a capacitor (your choice). +% +% /--Xs--+---\ +% | | | +% Rlow Xp Rhigh +% | | | +% \------+---/ +% + +function [Xs Xp] = z_match(Rlow, Rhigh) + assert(Rlow < Rhigh, "Rlow must be < Rhigh"); + Q = sqrt(Rhigh/Rlow -1); + Xs = Q*Rlow; + Xp = Rhigh/Q; +endfunction + + +% Design an air core inductor, Example 1-5 "RF Circuit Design" + +function Nturns = design_inductor(L_uH, diameter_mm) + Nturns = sqrt(29*L_uH/(0.394*(diameter_mm*0.1/2))); +endfunction + + +% Work out series resistance Rl of series resonant inductor. Connect +% tracking generator to spec-an input, the series LC to ground. V is +% the ref TG level (e.g. with perfect 50 ohm term) in volts, Vmin is the +% minumum at series res freq. +% +% /-50-+---+ +% | | | +% TG C 50 spec-an +% | | | +% | L | +% | | | +% | Rl | +% | | | +% \----+---/ + +function Rl = find_rl(V,Vmin) + % at series resonance effect of C and L goes away and we are left with + % parallel combination of Ls and spec-an 50 ohm input impedance + + Rp = Vmin*50/(2*V*(1-Vmin/(2*V))); + Rl = 1/(1/Rp - 1/50) +endfunction diff --git a/codec2-dev/octave/s_param_rf.m b/codec2-dev/octave/s_param_rf.m index aca50268..8c5186af 100644 --- a/codec2-dev/octave/s_param_rf.m +++ b/codec2-dev/octave/s_param_rf.m @@ -2,57 +2,10 @@ % % David Rowe Nov 2015 % -% RF small signal amplifier design, using equations from "RF Cicruit -% Design" by Chris Bowick +% Working for small signal VHF amplifier design using +% S-param techniques from "RF Circuit Design" by Chris Bowick -1; - -% Helper functions ------------------------------------------------- - -% convert a parallel R/X to a series R/X - -function Zs = zp_to_zs(Zp) - Xp = j*imag(Zp); Rp = real(Zp); - Zs = Xp*Rp/(Xp+Rp); -endfunction - - -% convert a series R/X to a parallel R/X - -function Zp = zs_to_zp(Zs) - Xs = imag(Zs); Rs = real(Zs); - Q = Xs/Rs; - Rp = (Q*Q+1)*Rs; - Xp = Rp/Q; - Zp = Rp + j*Xp; -endfunction - - -% Design a Z match network with a parallel and series reactance -% to match between a low and high resistance. Note Xp and Xs -% must be implemented as opposite sign, ie one a inductor, one -% a capacitor (your choice). -% -% /--Xs--+---\ -% | | | -% Rlow Xp Rhigh -% | | | -% \------+---/ -% - -function [Xs Xp] = z_match(Rlow, Rhigh) - assert(Rlow < Rhigh, "Rlow must be < Rhigh"); - Q = sqrt(Rhigh/Rlow -1); - Xs = Q*Rlow; - Xp = Rhigh/Q; -endfunction - - -% Design an air core inductor, Example 1-5 "RF Circuit Design" - -function Nturns = design_inductor(L_uH, diameter_mm) - Nturns = sqrt(29*L_uH/(0.394*(diameter_mm*0.1/2))); -endfunction +rfdesign; % library of helped functions more off; diff --git a/codec2-dev/octave/vhf_pa.m b/codec2-dev/octave/vhf_pa.m new file mode 100644 index 00000000..4b5486f4 --- /dev/null +++ b/codec2-dev/octave/vhf_pa.m @@ -0,0 +1,111 @@ +% vhf_pa.m +% +% David Rowe Dec 2015 +% +% Working for 0.5W VHF PA + +rfdesign; + +% BFQ19 Vce=5V Ic=50mA. These are small signal S-params, +% which (according to "RF Cicruit Design") are not valid. +% However I need to start somewhere. + +S11 = 0.324*exp(j*(-158.1)*pi/180); +S12 = 0.031*exp(j*(75.9)*pi/180); +S21 = 19.693*exp(j*(102.7)*pi/180); +S22 = 0.274*exp(j*(-74.6)*pi/180); + +% Lets check stability + +Ds = S11*S22-S12*S21; +Knum = 1 + abs(Ds)^2 - abs(S11)^2 - abs(S22)^2; +Kden = 2*abs(S21)*abs(S12); +K = Knum/Kden +figure(1); +clf +scCreate; + +if K < 1 + C1 = S11 - Ds*conj(S22); + C2 = S22 - Ds*conj(S11); + rs1 = conj(C1)/(abs(S11)^2-abs(Ds)^2); % centre of input stability circle + ps1 = abs(S12*S21/(abs(S11)^2-abs(Ds)^2)); % radius of input stability circle + rs2 = conj(C2)/(abs(S22)^2-abs(Ds)^2); % centre of input stability circle + ps2 = abs(S12*S21/(abs(S22)^2-abs(Ds)^2)); % radius of input stability circle + + s(1,1)=S11; s(1,2)=S12; s(2,1)=S21; s(2,2)=S22; + plotStabilityCircles(s) +end + + +% determine collector load Rl for our desired power output + +if 0 +P = 0.5; +Vcc = 5; +w = 2*pi*150E6; + +Rl = Vcc*Vcc/(2*P); +end +Rl = 10; + +% choose gammaL based on Rl + +zo = Rl/50; +[magL,angleL] = ztog(zo); +gammaL = magL*exp(j*angleL*pi/180); + +% calculate gammaS and Zi and plot + +gammaS = conj(S11 + ((S12*S21*gammaL)/(1 - (gammaL*S22)))); +[zi Zi] = gtoz(abs(gammaS), angle(gammaS)*180/pi,50); + +scAddPoint(zi); +scAddPoint(zo); + +% design Pi network for matching Rl to Ro, where Ro > Rl +% +% /---+-Xs1-Xs2-+---\ +% | | | | +% Rl Xp1 Xp2 Ro +% | | | | +% \---+---------+---/ +% +% highest impedance used to define Q of pi network and determine R, +% the "virtual" impedance at the centre of the network, whuch is smaller +% than Rl and Ro + +Ro = 50; +Q = 3; +R = Ro/(Q*Q+1); + +Xp2 = Ro/Q; +Xs2 = Q*R; + +Q1 = sqrt(Rl/R - 1); +Xp1 = Rl/Q1; +Xs1 = Q1*R; + +Cp1 = 1/(w*Xp1); +Cp2 = 1/(w*Xp2); +Ls = (Xs1+Xs2)/w; + +printf("Output Matching:\n"); +printf(" Rl = %3.1f Ro = %3.1f\n", Rl, Ro); +printf(" Q = %3.1f virtual R = %3.1f\n", Q, R); +printf(" Xp1 = %3.1f Xs1 = %3.1f Xs2 = %3.1f Xp2 = %3.1f\n", Xp1, Xs1, Xs2, Xp2); +printf(" Cp1 = %3.1f pF Ls = %3.1f nH Cp2 = %3.1f pF\n", Cp1*1E12, Ls*1E9, Cp2*1E12); + +% design input matching network between 50 ohms source and 10 ohms at base + +Rb = 10; Rs = 50; + +[Xs Xp] = z_match(Rb, Rs); + +Lp = Xp/w; +Cs = 1/(w*Xs); + +printf("Input Matching:\n"); +printf(" Xs = %3.1f Xp = %3.1f\n", Xs, Xp); +printf(" Lp = %3.1f nH Cs = %3.1f pF\n", Lp*1E9, Cs*1E12); + -- 2.25.1