% Chebyshev Lowpass Filter Designer
% http://leleivre.com/rf_chebyshev_LPF.html

% impedance of the capacitor
%  for 2m use 20 picofarad   (162MHz, 0.1dB, 50 ohm)
%  for 70cm use 6.8 picofarad (505MHz, 0.1dB, 50 ohm)
function z = Z1(w)
  z = -i ./ ( w * 6.8e-12 );
endfunction

% impedance of the inductor
%  for 2m use 56 nanohenry    (162MHz, 0.1dB, 50 ohm)
%  for 70cm use 18 nanohenry   (505MHz, 0.1dB, 50 ohm)
function z = Z2(w)
  z = i * w * 18e-9;
endfunction

% impedance of the next capacitor
function z = Z3(w)
  z = Z1(w);
endfunction

% impedance of the terminating resistor / ideal transmission line
function z = Z4(w)
  z = 50;
endfunction

% impedance of Z3||Z4
function z = Z34(w)
  z = Z3(w).*Z4(w) ./ (Z3(w) + Z4(w));
endfunction

% impedance of Z2 + Z3||Z4
function z = Z234(w)
  z = Z2(w) + Z34(w);
endfunction

% impedance of Z1 || ( Z2 + Z3||Z4 )
function z = Z(w)
  z = Z1(w).*Z234(w) ./ (Z1(w) + Z234(w));
endfunction

% impedance, but for frequency in MHz
function z = ZMhz(f)
  w = 2 * pi * f * 1.e6;
  z = Z(w);
endfunction

% Plot impedance from 100MHz to 500MHz
f = [100:5:500]; z1 = real(ZMhz(f)); z2 = imag(ZMhz(f)); zmag = abs(ZMhz(f)); plot(f,z1,"1", f,z2,"2", f,zmag,"3")

input( "Press enter:" );

% Plot just the 2m band impedance
f = [144 : .25 : 148 ]; z1 = real(ZMhz(f)); z2 = imag(ZMhz(f)); zmag = abs(ZMhz(f)); plot(f,z1,"1", f,z2,"2", f,zmag,"3")

input( "Press enter:" );

% Plot just the 70cm band impedance
f = [420 : 1 : 450 ]; z1 = real(ZMhz(f)); z2 = imag(ZMhz(f)); zmag = abs(ZMhz(f)); plot(f,z1,"1", f,z2,"2", f,zmag,"3")

input( "Press enter:" );
