10 '*********************************************************************** 20 '| ARRAY | 30 '| A linear array antenna pattern plotter | 40 '| by Dennis D. King | 50 '| Version 1.0 11/87 | 60 '*********************************************************************** 70 'Main Program 80 DIM E(361),UNIT(361),L(361),M(25),THETA(25),D(25) 90 GOSUB 170 'Get input parameters 100 GOSUB 490 'Calculate field strength 110 GOSUB 3380 'Print main menu 120 A$=INKEY$:IF A$="" THEN 120 'Input menu choice 130 P=VAL(A$) 140 ON P GOSUB 1150,1630,2170,90,2740,2150 150 GOTO 110 160 '********************************************************************* 170 'getting input parameters 180 CLS:INPUT"How many elements in this linear array?";E 190 CLS:PRINT"What is the magnitude of element 1 current" 200 PRINT"(1 amp is often convenient, it need only be relative)?" 210 INPUT M(1) 'M(?) defines the element currents 220 FOR J=2 TO E 230 PRINT"What's the magnitude of element current ";J;" rel to element 1?" 240 INPUT M(J) 250 PRINT"What is the phase (in deg) of element ";J;" rel to element 1?" 260 INPUT THETA(J) 270 PRINT"How many wavelengths from element ";J;" to element ";J-1;"?" 280 INPUT D(J-1) 290 NEXT J 300 CLS:PRINT:PRINT"Is each element:":PRINT"0-omnidirectional or;" 310 PRINT"D-a half wave dipole" 320 A$=INKEY$:IF A$="" THEN 320 330 IF A$="O" OR A$="o" THEN EL=0:GOTO 360 340 IF A$="d" OR A$="D" THEN EL=1:GOTO 360 350 GOTO 300 360 CLS:INPUT"What step size in degrees for the analysis";ST 370 CLS:PRINT:INPUT"Is there a ground plane beneath the array(Y/N)?";A$ 380 IF A$="Y" OR A$="y" THEN 400 390 GP=0:EEND=360:RETURN 'GP indicates existence of ground plan 400 GP=1:EEND=180 410 INPUT"How many wavelengths below the array is the ground plane?";GPWL 420 PRINT:PRINT"Are the array elements:":PRINT"H-Horizontally polarized or;" 430 PRINT"V-Vertically polarized?" 440 A$=INKEY$:IF A$="" THEN 440 450 IF A$="h" OR A$="H" THEN POL=0:RETURN 460 IF A$="v" OR A$="V" THEN POL=1:RETURN 470 GOTO 420 480 '************************************************************************ 490 'Calculating field strength for each degree of angle 500 'Output is E(0-359) 510 CLS 520 FOR DEG=0 TO EEND STEP ST 530 LOCATE 12,25:PRINT"Working on ";DEG;" degree angle." 540 ANG=DEG/57.2975 'converts degrees to radians 550 CO=COS(ANG) 560 IF EL=1 THEN SI=SIN(ANG+1.5708):IF ABS(SI)<.001 THEN RT=0:GOTO 610 570 ' that statement defined sin(angle+90 degrees) for later 580 :IF EL=1 THEN GOSUB 1090:RT=M(1)*MDIP:GOTO 610 590 ' that statement defined the mag. of element pattern if dipole 600 RT=M(1) 610 IT=0:D=0 620 FOR I=2 TO E 630 D=D+D(I-1) 640 IF EL=1 AND ABS(SI)<.001 THEN MAG=0:GOTO 670 650 IF EL=1 THEN GOSUB 1090:MAG=M(I)*MDIP:GOTO 670 660 MAG=M(I) 670 THET=THETA(I)+6.283*D*CO*57.2975 680 GOSUB 1010 ' changing mag and phase to rectangular 690 RT=RT+REAL:IT=IT+IM 700 NEXT I 710 REAL=RT:IM=IT 720 GOSUB 1060 'changing from rect back to polar 730 E(DEG)=MAG 740 NEXT DEG 750 IF GP=1 THEN GOSUB 780 'this does the ground plane calcs 760 RETURN 770 '-------------------------------------------------------------------- 780 'this sub accommodates ground plane in field 790 'generate image pattern 800 MAG=1:IF POL=0 THEN THETA=180 'accounts for phase of ref. due to polarity 810 IF POL=1 THEN THETA=0 820 FOR DEG=0 TO 360 STEP ST 830 CO=COS((DEG-90)/57.2975) 'this rotates pattern -90 deg 840 D=2*GPWL 850 LOCATE 12,22:PRINT"Working on image pattern, ";DEG;" degrees." 860 MAG=1:THET=THETA+6.283*D*CO*57.2975 870 GOSUB 1010 'polar to rect 880 RT=1+REAL:IT=IM 890 REAL=RT:IM=IT 900 GOSUB 1060 'changing rect to polar 910 UNIT(DEG)=MAG 920 NEXT DEG 930 'we now have image pattern 940 'multiplying image and array patterns 950 FOR DEG=0 TO EEND STEP ST 960 E(DEG)=E(DEG)*UNIT(DEG) 970 NEXT DEG 980 RETURN 990 '--------------------------------------------------------------------- 1000 'changing polar coordinates MAG and THET to rect REAL and IM 1010 REAL=MAG*COS(THET/57.2975) 1020 IM=MAG*SIN(THET/57.2975) 1030 RETURN 1040 '-------------------------------------------------------------------- 1050 'changes rect coordinates REAL and IM to magnitude MAG 1060 MAG=(REAL^2+IM^2)^.5 'changes rect to magnitude 1070 RETURN 1080 '------------------------------------------------------------------- 1090 'this sub returns a value MDIP which is the gain factor of dipole element 1100 MDIP=((COS(1.57*COS(ANG+1.5708)))/SI) 1110 RETURN 1120 '------------------------------------------------------------------- 1130 ' 1140 '******************************************************************** 1150 'plotting field strength data 1160 SCREEN 2:CLS 1170 CIRCLE (320,100),239 1180 CIRCLE (320,100),192 1190 CIRCLE (320,100),144 1200 CIRCLE (320,100),96 1210 CIRCLE (320,100),48 1220 LINE (80,100)-(560,100) 1230 LOCATE 23,1:PRINT"shft-PrtSc for plot" 1240 LOCATE 3,2:PRINT"Push any key" 1250 LOCATE 4,2:PRINT"To continue" 1260 LINE (320,0)-(320,200) 1270 LOCATE 13,72:PRINT"0 DEG" 1280 LOCATE 12,10 :PRINT"1" 1290 LOCATE 12,15:PRINT ".8" 1300 LOCATE 12,21:PRINT".6" 1310 LOCATE 12,27:PRINT".4" 1320 LOCATE 12,33:PRINT".2" 1330 LOCATE 1,2:PRINT"Relative Field Strength" 1340 LOCATE 13,3:PRINT"180 deg." 1350 GOSUB 1470 'sizing data, finding min and max 1360 SCALE=1/MAX 'scale factor to make max=1 1370 X1=320:Y1=100 1380 FOR DEG=0 TO EEND STEP ST 1390 M=SCALE*E(DEG):A=DEG 1400 GOSUB 1550 1410 LINE (X1,Y1)-(X,Y) 'draws lines between x1 y1 points 1420 X1=X:Y1=Y 1430 NEXT DEG 1440 A$=INKEY$:IF A$="" THEN 1440 1450 RETURN 1460 '------------------------------------------------------------------------ 1470 'this sub sizes the data, finds min and max 1480 MIN=1000000!:MAX=-1000000! 1490 FOR DEG=0 TO EEND STEP ST 1500 IF MAXE(DEG) THEN MIN=E(DEG) 1520 NEXT DEG 1530 RETURN 1540 '------------------------------------------------------------------------ 1550 'this sub returns x,y coordinates for unit plot 1560 'given inputs of magnitude M and angle A in degrees 1570 X=320+240*M*COS(A/57.2975) 1580 Y=100-100*M*SIN(A/57.2975) 1590 RETURN 1600 '------------------------------------------------------------------------ 1610 ' 1620 '************************************************************************ 1630 'Plotting in dB the highest 25db of magnitude data 1640 GOSUB 1990 'logging data 1650 GOSUB 2080 'determines scale 1660 SCREEN 2:CLS 1670 CIRCLE (320,100),239 1680 CIRCLE (320,100),192 1690 CIRCLE (320,100),144 1700 CIRCLE (320,100),96 1710 CIRCLE (320,100),48 1720 LINE (80,100)-(560,100) 1730 LOCATE 23,1:PRINT"shft-PrtSc for plot" 1740 LOCATE 5,2:PRINT"Push any key" 1750 LOCATE 6,2:PRINT"To continue" 1760 LINE (320,0)-(320,200) 1770 LOCATE 13,72:PRINT"0 deg" 1780 LOCATE 12,10:PRINT OUTRING 1790 LOCATE 12,15:PRINT OUTRING-5 1800 LOCATE 12,21:PRINT OUTRING-10 1810 LOCATE 12,27:PRINT OUTRING-15 1820 LOCATE 12,33:PRINT OUTRING-20 1830 LOCATE 1,2:PRINT"Field Strength in db" 1840 LOCATE 2,2:PRINT"Rel to 1 element" 1850 LOCATE 3,2:PRINT"At 1 amp" 1860 LOCATE 13,3:PRINT "180 deg." 1870 SCALE=1/25 1880 X1=320:Y1=100 1890 FOR DEG=0 TO EEND STEP ST 1900 M=SCALE*((L(DEG)-OUTRING+25)):A=DEG 'this scales data 1910 IF M<0 THEN M=0 1920 GOSUB 1550 1930 LINE (X1,Y1)-(X,Y) 1940 X1=X:Y1=Y 1950 NEXT DEG 1960 A$=INKEY$:IF A$="" THEN 1440 1970 RETURN 1980 '------------------------------------------------------------------------ 1990 'this sub changes the data to db's rel to single element 2000 MIN=1000000!:MAX=-1000000! 2010 FOR DEG=0 TO EEND STEP ST 2020 IF E(DEG)=0 THEN L(DEG)=-100:GOTO 2040 2030 L(DEG)=8.686*LOG(E(DEG)) 2040 IF MAXL(DEG) THEN MIN=L(DEG) 2060 NEXT DEG 2070 '------------------------------------------------------------------------ 2080 'this sub determines the scale 2090 OUTRING=5*INT(MAX/5)+5 'outring is the nearest 5db increment 2100 CENT=OUTRING-25 2110 RETURN 2120 '------------------------------------------------------------------------- 2130 ' 2140 '************************************************************************* 2150 SYSTEM 'send execution back to DOS 2160 '************************************************************************* 2170 'printing out data 2180 CLS:GOSUB 1990 'logging data 2190 PRINT"Do you want to:":PRINT" S-print on screen": 2200 PRINT" P-print out on printer" 2210 PRINT" Q-quit" 2220 A$=INKEY$:IF A$="" THEN 2220 2230 IF A$="s" OR A$="S" THEN GOSUB 2460 2240 IF A$="p" OR A$="P" THEN GOSUB 2580 2250 IF A$="q" OR A$="Q" THEN RETURN 2260 GOTO 2170 2270 '------------------------------------------------------------------------ 2280 'this sub prints the parameters on the screen 2290 PRINT:PRINT E;" Element linear array":PRINT 2300 PRINT"Element magnitude phase(DEG) separation" 2310 PRINT" 1",M(1),THETA(I),D(I-1) 2320 FOR I=2 TO E 2330 PRINT I,M(I),THETA(I),D(I-1) 2340 NEXT I 2350 PRINT 2360 IF EL=0 THEN PRINT"Array elements are omnidirectional." 2370 IF EL=1 THEN PRINT"Array elements have 1/2 wave dipole pattern." 2380 PRINT"Step size for analysis is currently ";ST;" degrees." 2390 IF GP=1 THEN 2410 2400 RETURN 2410 PRINT"Ground plane is ";GPWL;" wavelengths below the array. " 2420 IF POL=0 THEN PRINT"Array elementsare horizontally polarized." 2430 IF POL=1 THEN PRINT"Array elements are vertically polarized." 2440 RETURN 2450 '-------------------------------------------------------------------------- 2460 CLS'printing out on screen 2470 GOSUB 2280 'prints out parameters 2480 PRINT:PRINT"Angle FS(Volts) REL GAIN to 1 ELEMENT(DB)" 2490 PRINT 2500 FOR DEG=0 TO EEND STEP ST 2510 PRINT DEG,E(DEG);TAB(31) L(DEG) 2520 NEXT DEG 2530 PRINT"Hit any key to continue" 2540 B$=INKEY$:IF B$="" THEN 2540 2550 RETURN 2560 '------------------------------------------------------------------------- 2570 'printing out on printer 2580 CLS:PRINT"Sending to printer" 2590 LPRINT E;" Element linear array":PRINT 2600 LPRINT"Element magnitude phase separation" 2610 LPRINT" 1 1 0 N/A" 2620 FOR I=2 TO E 2630 LPRINT E,M(I),THETA(I),D(I-1) 2640 NEXT I 2650 LPRINT:LPRINT"Angle FS(Volts) Rel Gain to 1 Element(DB)" 2660 LPRINT 2670 FOR DEG=0 TO EEND STEP ST 2680 LPRINT DEG,E(DEG);TAB(31) L(DEG) 2690 NEXT DEG 2700 RETURN 2710 '--------------------------------------------------------------------------2720 ' 2730 '**************************************************************************2740 'change parameters 2740 'change parameters 2750 GOSUB 2280 'prints out current parameters 2760 PRINT:PRINT"Do you want to change:" 2770 PRINT"E-element parameters" 2780 PRINT"G-toggle presence or absence of ground plane" 2790 PRINT"P-toggle polarization of elements" 2800 PRINT"H-change distance from array to ground plane" 2810 PRINT"D-toggle omnidirectional elements or 1/2 wave dipole elements" 2820 PRINT"S-change step size of analysis" 2830 PRINT"A-analyze" 2840 A$=INKEY$:IF A$="" THEN 2840 2850 IF A$="e" OR A$="E" THEN GOSUB 2990 2860 IF A$="g" OR A$="G" THEN GOSUB 3160 2870 IF A$="p" OR A$="P" THEN GOSUB 3210 2880 IF A$="h" OR A$="H" THEN GOSUB 3260 2890 IF A$="a" OR A$="A" THEN CLS:GOTO 100 2900 IF A$="d" OR A$="D" THEN GOSUB 3310 2910 IF A$="s" OR A$="S" THEN GOSUB 2940 2920 CLS:GOTO 2750 2930 '------------------------------------------------------------------------- 2940 'changes step size of analysis 2950 CLS:PRINT"Step size is currently ";ST;" degrees." 2960 INPUT"What new step size in degrees";ST 2970 RETURN 2980 '------------------------------------------------------------------------ 2990 'changes element parameters 3000 CLS:INPUT"Which element to change";R 3010 CLS:PRINT:PRINT"element magnitude phase(deg) separation" 3020 PRINT R,M(R),THETA(R),D(R-1) 3030 PRINT 3040 PRINT"Do you want to change:" 3050 PRINT"M-magnitude" 3060 PRINT"P-phase":PRINT"S-separation in wavelengths" 3070 PRINT"F-finished" 3080 A$=INKEY$:IF A$="" THEN 3080 3090 IF A$="m" OR A$="M" THEN INPUT"What is new magnitude";M(R):GOTO 3010 3100 IF A$="p" OR A$="P" THEN INPUT"What new phase(in deg)";THETA(R):GOTO 3010 3110 IF A$="s" OR A$="S" THEN INPUT"What new separ.(in wvlths)";D(R-1):GOTO 3010 3120 IF A$="f" OR A$="F" THEN RETURN 3130 GOTO 3010 3140 RETURN 3150 '------------------------------------------------------------------------- 3160 'toggles presence ofground plane 3170 IF GP=1 THEN GP=0:EEND=360:RETURN 3180 IF GP=0 THEN GP=1:EEND=180:RETURN 3190 RETURN 3200 '------------------------------------------------------------------------ 3210 'toggles polarization of elements 3220 IF POL=0 THEN POL=1:RETURN 3230 IF POL=1 THEN POL=0:RETURN 3240 RETURN 3250 '------------------------------------------------------------------------ 3260 'changes distance from ground 3270 PRINT 3280 INPUT"What is new distance from array to ground in wavelengths";GPWL 3290 RETURN 3300 '----------------------------------------------------------------------- 3310 'toggles omni or dipole element patterns 3320 IF EL=1 THEN EL=0:RETURN 3330 IF EL=0 THEN EL=1:RETURN 3340 RETURN 3350 '---------------------------------------------------------------------- 3360 ' 3370 '********************************************************************** 3380 'this sub prints the main menu 3390 CLS:PRINT"Do you want to:":PRINT" 1-plot field strength data" 3400 PRINT " 2-plot data in db" 3410 PRINT " 3-print out data":PRINT" 4-start over" 3420 PRINT" 5-change Parameters":PRINT" 6-quit" 3430 RETURN 3440 '------------------------------------------------------------------------- --------------------------------------------------------------------- 2280 'th