1 'ANT-PAT.BAS Updated 10 July 2011
2 DEFINT I-J
3 I = 0'General counter
4 J = 0'General counter
'Log to Linear conversion factors
5 DIM MAN(10)
6 MAN(0)=1.000
7 MAN(1)=1.260
8 MAN(2)=1.584
9 MAN(3)=2.000
10 MAN(4)=2.505
11 MAN(5)=3.160
12 MAN(6)=4.000
13 MAN(7)=5.001
14 MAN(8)=6.290
15 MAN(9)=8.000
20 IXL = 20'Left border of display
IXR = 600 'Right border of display
22 IY0 = 80 'Vertical zero antenna centroid
24 IYT = 20 'Y Top of display on screen
26 IYB = 180 'bottom of screen
30 'New Run Starting Address
NP% = 4 'Number of driven elements
32 IX = 0 'Screen X coordinate
34 IY = 0 'Screen Y coordinate
36 C = 0
40 SF = 1
MHDN = 12'Max Horizontal Distance in nautical miles
MHDF = MHDN * 6079 ' Max Horizontal distance in feet
HM = 1'Horizontal Multiple for screen display
VM = .4'Vertical Multiple for screen display
RAD% = 0' Radius of impact areas
RC = 1 ' Refraction Coefficient
MUL = 30
FRQ = 1900 'Transmit frequency in MHz
FRQMUL = 300^2 'Frequency multiplier constant
TPW = 20 'transmit power to antenna (in watts)
DBM = -77 'Receive Power in dbm
'This will be converted to milliwatts in the program
FF = 0.064 'Fudge Factor to make things come out right
'includes 3db gain of dipole ' 0.056 '0.013
Refl$ = "Y" 'Reflector behind array? Yes/No
UL = MUL * .00104 'Upper Limit - redefined in program
LL = MUL * 1E-3 'Lower Limit - redefined in program
D% = 0
X = 0
Y = 0
z = 0
50 P = 0
R = 0 ' Element to receiver point distance
Rsq = 0' Element to receiver point distance Squared
DIM A(4) 'Radiating element Amplitude Array (Watts)
APF = 0' Amplitude at receiver point
FAMP = 0
FAMP1 = 0
FAMP2 = 0
SRC = 0'Scaled Reflection Coefficient
XO = 0
YO = 0
ZO = 0
HA = 20
XC = 0' Centroid of refracting bodies
YC = 0' "
ZC = 0' "
PDF = 0' Phase Delay Factor for driven elements
WLF = (300 / FRQ) * (39.37 / 12): ' WaveLength of source in feet
SpMul = 0.75 'Spacing Multiple x wavelength for antenna elements
SpBE = WLF * SpMul 'Spacing between element centroids. Can be modified in program.
Pi = 3.14159 'Pi
130 TwoPi = 2 * 3.1417'2 PI '2 X Pi
150 NP% = 4
ESC$ = CHR$(27)
z$ = ""'Inkeys value
270 DIM X(50), Y(50), z(50)
BLANK$=STRING$(70," ")
300 CLS : PRINT
PRINT " Multipole Antenna Pattern Generation"
PRINT
PRINT " Robert S. Fritzius"
PRINT " Low-Tec Shareware"
PRINT " http//www.shadetreephysics.com/low-tec.htm"
PRINT " "
PRINT
PRINT
PRINT
370 PRINT " 1) Create Antenna Patterns"
PRINT " 2) Info on program"
385 PRINT " 3) Exit"
390 PRINT
400 INPUT " Which Choice"; T
410 IF T < 1 AND T > 4 THEN 400
440 ON T GOTO 800, 6000, 9000
450 :
800 CLS :PRINT
PRINT " Signal Strength Contour Plotting Parameters"
810 LOCATE 4, 1
PRINT USING "(a) Transmit power (watts) = ###.# "; TPW
print using "(b) Fudge Factor = #.###";FF
PRINT USING "(c) Frequency in MHz = ####.## "; FRQ
WLF = (300 / FRQ) * (39.37 / 12): ' WaveLength of source in feet
PRINT USING " Wavelength (feet) = ##.## "; WLF
PRINT USING "(d) Rcv Sig (dbm) integers only = #### "; DBM 'was RSL
PRINT " Refracting body data"
PRINT USING "(e) Array Reflector (Y/N) = \\"; Refl$
PRINT USING "(f) Array X centroid = ####"; XC
PRINT USING "(g) Array Y centroid = ####"; HA
PRINT USING "(h) Max Horiz Distance (NM) = ##.## "; MHDN
PRINT USING "(i) No. of Dipoles (0=Isotropic) = ### "; NP%
PRINT USING "(j) Phase Delay Factor = ###.#"; PDF
PRINT USING "(k) Element ctr-ctr Spacing W/L = ##.##"; SpMul 'SpBE
PRINT "(l) Return to first menu"
850 LOCATE 18, 5
PRINT "Which item to change to run";
LOCATE 19,15
PRINT "(esc) Exit program"
855 WI$ = INKEY$: IF WI$ = "" THEN 855
IF WI$ = "L" OR WI$ = "l" THEN 300 'Return to Main Menu
IF WI$ = ESC$ THEN CLS : END
LOCATE 17, 1: PRINT STRING$(40, " ");
WI% = ASC(WI$)
IF WI% = 13 THEN 890' Key was depressed
IF WI% < 64 OR WI% > 124 THEN 850' Outside usable range
IF WI% > 96 AND WI% < 125 THEN WI% = WI% - 32'make upper case
WI% = WI% - 64
IF WI%>12 THEN 850 'CHECK THIS
LCWI$ = CHR$(WI% + 96)
LOCATE 17, 1: PRINT " New Value for ("; LCWI$; ") ";
INPUT NV$
IF NV$ = "" THEN GOTO 810
NV = VAL(NV$)
LOCATE 17, 1: PRINT STRING$(50, " ");
ON WI% GOTO 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872
861 TPW = NV: GOTO 810 '(a) Transmit Power in Watts
862 FF = NV : GOTO 810 '(b) Fudge Factor
863 FRQ = NV: GOTO 810 '(c) Frequency in MHz
864 DBM = NV: GOTO 810 '(d) Received Signal Strength in dbm
865 IF NV$ ="y" THEN NV$="Y"
IF NV$ ="n" THEN NV$="N"
IF NV$<>"Y" AND NV$<>"N" THEN 810
Refl$ = NV$: GOTO 810 '(e) Array Reflector Yes/No
866 XC = NV: GOTO 810 '(f) Array X centroid
867 HA = NV: GOTO 810 '(g) Array Y centroid
868 MHDN = NV: GOTO 810 '(h) Max Horizontal Distance in nautical miles
869 IF NV >=0 AND NV < 6 THEN NP% = NV: GOTO 810
'(i) Number of driven elements
870 PDF = NV: GOTO 810 '(j) Phase delay factor
871 SpMul = NV:GOTO 810 '(k) Spacing multiple elements in wavelengths
872 GOTO 30 '(l) Return to first menu
890 STORE = 0
LOCATE 20,5:PRINT BLANK$;
LOCATE 20,5:
PRINT "Create and store Pattern? (Y/N)";:INPUT PAT$
IF PAT$="Y" OR PAT$="y" THEN STORE=1
IF STORE=0 THEN 895
892 LOCATE 21,5
PRINT "Typical data file names: 108412.dat or c:\pats\108412.dat"
LOCATE 22,5:PRINT BLANK$;
LOCATE 23,5:PRINT BLANK$;
LOCATE 24,5:PRINT BLANK$;
LOCATE 22,5:PRINT "Data File Name = ";:INPUT DATNAME$
IF DATNAME$="" THEN 890
LOCATE 23,5:PRINT "data file name is "; DATNAME$;
LOCATE 24,5:PRINT " Is this correct? (Y/N)";
894 Z$=INKEY$:IF Z$="" THEN 894
IF Z$<>"Y" AND Z$<>"y" THEN 892
895 CLS: SCREEN 2
CLOSE
IF STORE=1 THEN OPEN "O", #1, DATNAME$
WLF = (300 / FRQ) * (39.37 / 12) 'wavelength in feet
MHDF=MHDN * 6079 'Max Horizontal Distance in feet
SF = 600 / MHDF'Scale
SpBE = SpMul * WLF 'Spacing between element centers in feet
'Calculate received power in watts based on dbm
SIGN=SGN(DBM)
DBA=ABS(DBM)
ORD=INT(DBA/10)
MAN=DBA-10*ORD
IF SIGN>=1 THEN P=.001*MAN(MAN)*10^ORD
IF SIGN=-1 AND ORD>0 THEN Prx = 0.001/(MAN(MAN)*10^ORD)
RSL=Prx*1000 'Received Signal Level in milliwatts
'Establish contour limits
UL = 1.002 * RSL / 1000
LL = 0.998 * RSL / 1000
'Scaled Reflection Coefficients
SRC = RC / SQR(NP% + 1)
X(3) = XC: Y(3) = YC + 1.5 * SpBE '6!
X(1) = XC: Y(1) = YC + 0.5 * SpBE '2!
X(2) = XC: Y(2) = YC - 0.5 * SpBE '2!
X(4) = XC: Y(4) = YC - 1.5 * SpBE '6!
'Phase Delay (for radiator elements)
DIM PH(4)
PH(3) = .3 * PI * PDF
PH(1) = .15 * PI * PDF
PH(2) = -.15 * PI * PDF
PH(4) = -.3 * PI * PDF
'Split total power among individual radiating elements
FOR I = 1 TO NP%
A(I) = TPW / NP% 'transmit element power in watts
NEXT I
FMT1$ = " #### dbm Contour for ###.# watt multipole transmit antenna"
FMT2$ = " Freq = ####.# MHz # Elements Centroid Spacing = #.## * W/L"
LOCATE 1,5: PRINT USING FMT1$; DBM; TPW
LOCATE 2,5: PRINT USING FMT2$; FRQ; NP%; SpMul;
DRAW "BM" + STR$(IXL) + "," + STR$(IYT)'x,y origin
DRAW " M" + STR$(IXR) + "," + STR$(IYT)
DRAW " M" + STR$(IXR) + "," + STR$(IYB)
DRAW " M" + STR$(IXL) + "," + STR$(IYB)
DRAW " M" + STR$(IXL) + "," + STR$(IYT)
IF STORE=0 THEN 880
'Print dots at corners in data file
PRINT #1, IXL,IYT
PRINT #1, IXR,IYT
PRINT #1, IXR,IYB
PRINT #1, IXL,IYB
'Print dots along left and right edges of data file
FOR I= 0 TO 3
PRINT #1, IXL, IYT+I*40
PRINT #1, IXR, IYT+I*40
NEXT I
880 DELTAV = (IYB - IYT) / 4
DELTAH = (IXR - IXL) / 6
FOR I = DELTAV TO 3 * DELTAV STEP DELTAV
DRAW "BM" + STR$(IXL) + "," + STR$(I + IYT)
DRAW " M" + STR$(IXR) + "," + STR$(I + IYT)
NEXT I
IF STORE=0 THEN 885
FOR I = DELTAV TO 3 * DELTAV STEP DELTAV
PRINT #1, IXL,IYT
NEXT I
885 FOR I = DELTAH TO 6 * DELTAH STEP DELTAH
DRAW "BM" + STR$(I + IXL) + "," + STR$(IYT)
DRAW " M" + STR$(I + IXL) + "," + STR$(IYB)
NEXT I
IF STORE=0 THEN 888
FOR I=DELTAH TO 6 * DELTAH STEP DELTAH
PRINT #1, I+IXL,IYT
PRINT #1, I+IXL,IYB
NEXT I
888'Draw postions of driven elements if on screen
FOR I = 1 TO NP%
X = X(I)
Y = Y(I)
IX = IXL + SF * HM * X
IY = IYT + IY0 - SF * VM * Y
FOR RAD% = 1 TO 3
CIRCLE (IX, IY), RAD%
NEXT RAD%
NEXT I
LOCATE 25, 20: PRINT "Press any key to begin antenna pattern.";
900 z$ = INKEY$: IF z$ = "" THEN 900
LOCATE 24, 1: PRINT STRING$(78, " ");
950 GOSUB 5500: ' Print Parameters
'Print horizontal distance scale
for i=0 to 6
j= 1+12*i
k=i*MHDN/6
locate 24,j:print using "##.##";k;
next i
locate 25,5:print " Press [space bar] to pause/resume. Press [Esc] to end run";
'Create random points in X/Y space
1050 X = RND(1) * MHDF
Y = -MHDF / 2 + RND(1) * MHDF
'LOCATE 4,5:PRINT USING "X =####.### Y=####.### ";X,Y;
'Source to Receiver Points
FAMP1 = 0
FAMP2 = 0
Rsq = X^2 + Y^2
R = SQR(Rsq)
COSPF = ABS(X) / R
IF NP%=0 THEN APF = FF*TPW/Rsq: GOTO 1220 'Isotropic source
APF = FF * TPW/NP% * 2*COSPF / Rsq 'Dipole signal strength
' 'at field point in watts
1120 FOR I = 1 TO NP%
DX = X - X(I) : DY = Y - Y(I)
'Calculate distance "R" between radiating element and field point
1170 Rsq = DX ^ 2 + DY ^ 2 'Radius squared
R = SQR(Rsq) 'Radius (in feet)
'Calculate cosine and sine for angle to field point
COSPF = ABS(DX) / R 'Cos Theta
1200 FAMP1 = FAMP1 + COS(TwoPi * R / WLF + PH(I))
FAMP2 = FAMP2 + SIN(TwoPi * R / WLF + PH(I))
1210 NEXT I
1220 IF NP%=0 THEN FAMP=FRQMUL*APF/FRQ^2:GOTO 1235
FAMP = FRQMUL * APF*(FAMP1^2 + FAMP2^2) / FRQ^2
1235 IF Refl$="Y" then FAMP=2*FAMP
IX = IXL + SF * HM * X
IY = IYT + IY0 - SF * VM * Y
IF IX < IXL OR IX > IXR THEN 1300
IF IY < IYT OR IY > IYB THEN 1300
'locate 5,5:print using "#.###### #### ####";famp;IX;IY;
IF FAMP>UL OR FAMP