#!/usr/bin/perl -w # # Moxon antenna dimension calculator # John Simpson, KG4ZOW # # 2006-08-08 # # Idea, algorithm, and diagram by L.B. Cebik, W4RNL # http://www.cebik.com/moxon/moxgen.html # # Diagram showing which parts of the antenna correspond to which variables # http://www.cebik.com/moxon/moxgen-1.gif # ############################################################################### # # Copyright (C) 2006 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### require 5.003 ; use strict ; use CGI qw ( :standard ) ; my %unam = ( "in" => "in" , "ag" => "AWG" , "mm" => "mm" , "wl" => "λ" , # lambda ) ; my ( $freq , $diam , $unit , $go ) ; ############################################################################### sub phead(;$) { my $err = ( shift || "" ) ; return < Moxon Calculator

Moxon Calculator

$err

EOF } sub pfoot() { return < John Simpson, KG4ZOW Download source code for this program
Moxon algorithm and diagram are from http://www.cebik.com/moxon/moxgen.html
AWG Conversion algorithm from Wikipedia
EOF } sub showform(;$) { my $err = ( shift || "" ) ; my $sin = ( $unit eq "in" ) ? " selected" : "" ; my $sag = ( $unit eq "ag" ) ? " selected" : "" ; my $smm = ( $unit eq "mm" ) ? " selected" : "" ; my $swl = ( $unit eq "wl" ) ? " selected" : "" ; print phead ( $err ) , <
Frequency in MHz
Wire Diameter
EOF print pfoot() ; exit 0 ; } sub fix($) { my $n = shift ; my $f = sprintf ( "%014.6f" , $n ) ; # trim all but one leading zero while ( $f =~ s/\G0(?!\.)/ /g ) {} ; # trim all trailing zeros (except one) $f =~ s/0+$//g ; $f =~ s/\.$/.0/ ; return "
$f
" ; } ############################################################################### ############################################################################### ############################################################################### $freq = ( param ( "freq" ) || "" ) ; $diam = ( param ( "diam" ) || "" ) ; $unit = ( param ( "unit" ) || "" ) ; $go = ( param ( "go" ) || "" ) ; showform() unless ( $go eq "yes" ) ; showform ( "Invalid frequency." ) unless ( $freq > 0 ) ; showform ( "Invalid diameter." ) unless ( $diam > 0 ) ; my $dw = $diam ; # already good if unit is wavelengths if ( $unit eq "in" ) { $dw = $diam / ( 11802.71 / $freq ) ; } elsif ( $unit eq "mm" ) { $dw = $diam / ( 299792.5 / $freq ) ; } elsif ( $unit eq "ag" ) # convert to inches first { my $zi = 0.005 * 92 ** ( ( 36 - $diam ) / 39 ) ; $dw = $zi / ( 11802.71 / $freq ) ; } elsif ( $unit ne "wl" ) { showform ( "Invalid units code." ) ; } my $note = "" ; my $d1 = 0.4342945 / log ( $dw ) ; if ( $d1 < -6 ) { $note = "Wire diameter too small, results uncertain" ; } elsif ( $d1 > -2 ) { $note = "Wire diameter too large, results uncertain" ; } # calculate dimensions my $a = ( -0.0008571428571 * $d1 * $d1 ) + ( -0.009571428571 * $d1 ) + 0.3398571429 ; my $b = ( -0.002142857143 * $d1 * $d1 ) + ( -0.02035714286 * $d1 ) + 0.008285714286 ; my $c = ( 0.001809523381 * $d1 * $d1 ) + ( 0.01780952381 * $d1 ) + 0.05164285714 ; my $d = ( 0.001 * $d1 ) + 0.07178571429 ; my $e = $b + $c + $d ; # calculate values needed for display my $wf = 983.5592 / $freq ; my $wi = 11802.71 / $freq ; my $wm = 299.7925 / $freq ; my $wl = 299792.5 / $freq ; my $drv = ( $a / 2 ) + 2 * $b ; my $ref = $a + 2 * $d ; my $tot = 2 * $a + 2 * $b + 2 * $d ; # format numbers for display my $flw = fix ( 1 ) ; my $flf = fix ( $wf ) ; my $fli = fix ( $wi ) ; my $flm = fix ( $wm ) ; my $fll = fix ( $wl ) ; my $fmw = fix ( $dw ) ; my $fmf = fix ( $dw * ( 983.5592 / $freq ) ) ; my $fmi = fix ( $dw * ( 11802.71 / $freq ) ) ; my $fmm = fix ( $dw * ( 299.7925 / $freq ) ) ; my $fml = fix ( $dw * ( 299792.5 / $freq ) ) ; my $qunit = ( $unam{$unit} || "($unit ??)" ) ; my $faw = fix ( $a ) ; my $faf = fix ( $a * $wf ) ; my $fai = fix ( $a * $wi ) ; my $fam = fix ( $a * $wm ) ; my $fal = fix ( $a * $wl ) ; my $fbw = fix ( $b ) ; my $fbf = fix ( $b * $wf ) ; my $fbi = fix ( $b * $wi ) ; my $fbm = fix ( $b * $wm ) ; my $fbl = fix ( $b * $wl ) ; my $fcw = fix ( $c ) ; my $fcf = fix ( $c * $wf ) ; my $fci = fix ( $c * $wi ) ; my $fcm = fix ( $c * $wm ) ; my $fcl = fix ( $c * $wl ) ; my $fdw = fix ( $d ) ; my $fdf = fix ( $d * $wf ) ; my $fdi = fix ( $d * $wi ) ; my $fdm = fix ( $d * $wm ) ; my $fdl = fix ( $d * $wl ) ; my $few = fix ( $e ) ; my $fef = fix ( $e * $wf ) ; my $fei = fix ( $e * $wi ) ; my $fem = fix ( $e * $wm ) ; my $fel = fix ( $e * $wl ) ; my $fdrvw = fix ( $drv ) ; my $fdrvf = fix ( $drv * $wf ) ; my $fdrvi = fix ( $drv * $wi ) ; my $fdrvm = fix ( $drv * $wm ) ; my $fdrvl = fix ( $drv * $wl ) ; my $frefw = fix ( $ref ) ; my $freff = fix ( $ref * $wf ) ; my $frefi = fix ( $ref * $wi ) ; my $frefm = fix ( $ref * $wm ) ; my $frefl = fix ( $ref * $wl ) ; my $ftotw = fix ( $tot ) ; my $ftotf = fix ( $tot * $wf ) ; my $ftoti = fix ( $tot * $wi ) ; my $ftotm = fix ( $tot * $wm ) ; my $ftotl = fix ( $tot * $wl ) ; ######## print phead() , < Dimension Wavelengths Feet Inches Meters Millimeters Frequency
$freq MHz
$flw $flf $fli $flm $fll Diameter
$diam $qunit
$fmw $fmf $fmi $fmm $fml A $faw $faf $fai $fam $fal B $fbw $fbf $fbi $fbm $fbl C $fcw $fcf $fci $fcm $fcl D $fdw $fdf $fdi $fdm $fdl E $few $fef $fei $fem $fel [Diagram] EOF print pfoot() ; exit 0 ;