07 марта 2021

ELE.BAS

 10  '           ELE.BAS               (c) 1986, 1989 Ian White, G3SEK

20  '           Version 3, November 1989

30  WL$ = "L2 (wl)  = #.####": DWL$ = "L2 = L1 +#.#### wl"

40  MM$ = "L2 (mm)  = ####.#": DMM$ = "L2 = L1 +###.# mm"

50  IN$ = "L2 (in)  = ###.##": DIN$ = "L2 = L1 +##.## in"

60 D1 = 0: D2 = 0: L1 = 0: WL1 = 1: WL2 = 1: H1 = 1: H2 = 1

70 DEF FNA (X) = 186.77 * LOG(2 / X) - 320

80 KEY OFF: CLS : LOCATE 3, 36: COLOR 0, 7: PRINT " ELE ": COLOR 7, 0

90 PRINT : PRINT TAB(34); "by G3SEK": PRINT

100 PRINT TAB(10); "A program to adjust the lengths of cylindrical dipole elements,"

110 PRINT TAB(10); "to compensate for different frequencies and element diameters."

120 '         Adjustment is based on restoring the original value of

130 '         element reactance, and uses the reactance formula:

140 '       X = (430.3*log10(wavelength/radius) - 320)*(2*L -1) + 40 ohms,

150 PRINT

160 PRINT TAB(15); "D1 = old diameter.    L1 = old length"

170 PRINT TAB(15); "D2 = new diameter.    Program finds new length L2"

180 GOSUB 2070: M$ = "Press spacebar": GOSUB 2000: T$ = INPUT$(1): CLS

190 '

200 ' Set up I/O options

210 GOSUB 400: M$ = "Press spacebar": GOSUB 2000

220 T$ = INPUT$(1): CLS

230 M$ = "After the first time, <Enter> recalls old values of D1 and D2"

240 GOSUB 2000: LOCATE 1, 1

250 '

260 ' Main loop

300 GOSUB 1000: YPOS = CSRLIN: IF YPOS > 24 THEN YPOS = 24

310 M$ = "Press <Enter> to continue, <Esc> to quit": GOSUB 2000

320 T$ = INPUT$(1)

330 IF T$ <> CHR$(27) THEN GOSUB 2070: LOCATE YPOS, 1: GOTO 300' Repeat

340 CLS : END                                                  ' Finish

350 '

370 ' Subroutines

380 '

390 ' Set up I/O options

400 LOCATE 3, 28: COLOR 0, 7: PRINT " INPUT/OUTPUT OPTIONS ": COLOR 7, 0

410 M$ = "Press -  W for wavelengths, M for millimetres, I for inches"

420 GOSUB 2000

430 LOCATE 5, 10: PRINT "Input units   > ";

440 T$ = INPUT$(1): T$ = CHR$(ASC(T$) AND &H5F)

450 IF T$ <> "W" AND T$ <> "M" AND T$ <> "I" THEN BEEP: GOTO 440

460 IF T$ = "W" THEN U1$ = "wl": PRINT U1$

470 IF T$ = "M" THEN U1$ = "mm": PRINT U1$

480 IF T$ = "I" THEN U1$ = "in": PRINT U1$

490 LOCATE 7, 10: PRINT "Output units  > ";

500 T$ = INPUT$(1): T$ = CHR$(ASC(T$) AND &H5F)

510 IF T$ <> "W" AND T$ <> "M" AND T$ <> "I" THEN BEEP: GOTO 500

520 IF T$ = "W" THEN U2$ = "wl": PRINT U2$

530 IF T$ = "M" THEN U2$ = "mm": PRINT U2$

540 IF T$ = "I" THEN U2$ = "in": PRINT U2$

550 GOSUB 2070

560 '

570 '

580 ' Get frequencies, if needed

590 IF U1$ = "wl" GOTO 630

600 LOCATE 10, 10: INPUT "Original frequency (MHz)  : ", F1

610 IF F1 < 1 THEN BEEP: LOCATE 10, 33: PRINT SPACE$(10): GOTO 600

620 IF U1$ = "mm" THEN WL1 = 299800! / F1 ELSE WL1 = 11803 / F1

630 IF U2$ = "wl" GOTO 690

640 LOCATE 12, 10: INPUT "New frequency (MHz)       : ", F2

650 IF F2 < 1 THEN BEEP: LOCATE 12, 33: PRINT SPACE$(10): GOTO 620

660 IF U2$ = "mm" THEN WL2 = 299800! / F2 ELSE WL2 = 11803 / F2

670 '

680 ' Get boom corrections

690 M$ = "Press Esc for help with boom corrections": GOSUB 2000

700 LOCATE 15, 10

710 PRINT "Boom correction to remove from all OLD lengths ("; U1$; ")  : ";

720 T$ = INPUT$(1)

730 IF T$ = CHR$(27) THEN WL = WL1: U$ = U1$: GOSUB 1300: BC1 = BC: GOTO 760 ELSE PRINT T$;

740 IF T$ = CHR$(13) THEN BC1 = 0: GOTO 760 ELSE INPUT "", BC$: BC1 = VAL(T$ + BC$)

750 BC1 = BC1 / WL1

760 M$ = "Press Esc for help with boom corrections": GOSUB 2000

770 LOCATE 17, 10

780 PRINT "Boom correction to add to all NEW lengths ("; U2$; ")  : ";

790 T$ = INPUT$(1)

800 IF T$ = CHR$(27) THEN WL = WL2: U$ = U2$: GOSUB 1300: BC2 = BC: GOTO 830 ELSE PRINT T$

810 IF T$ = CHR$(13) THEN BC2 = 0: GOTO 830 ELSE INPUT "", BC$: BC2 = VAL(T$ + BC$)

820 BC2 = BC2 / WL2

830 GOSUB 2070: LOCATE 20, 5

840 PRINT "Input as full lengths or half-lengths?   (Press F or h)   > ";

850 T$ = INPUT$(1)

860 IF T$ = "H" OR T$ = "h" THEN H1 = 2: PRINT "HALF" ELSE PRINT "FULL"

870 LOCATE 22, 5

880 PRINT "Output as full lengths or half-lengths?  (Press F or h)   > ";

890 T$ = INPUT$(1)

900 IF T$ = "H" OR T$ = "h" THEN H2 = 2: PRINT "HALF" ELSE PRINT "FULL"

910 RETURN

920 '

990 ' Main calculation

1000 PRINT

1010 PRINT "D1 ("; U1$; ")  : ";

1020 INPUT ; "", D$

1030 IF D$ = "" AND D1 <> 0 THEN GOTO 1060

1040 D1 = VAL(D$) / WL1: IF D1 < .000001 THEN D1 = .000001

1050 IF D1 > .02 THEN M$ = "TOO FAT": GOSUB 2110: GOTO 1010

1060 PRINT

1070 PRINT "L1 ("; U1$; ")  : "; : INPUT ; "", D$: L1 = H1 * VAL(D$) / WL1

1080 IF L1 > .55 THEN M$ = "TOO LONG": GOSUB 2110: GOTO 1070

1090 IF L1 < .3 THEN M$ = "TOO SHORT": GOSUB 2110: GOTO 1070

1100 L1 = L1 - BC1: X = FNA(D1) * (2 * L1 - 1) + 40

1110 PRINT TAB(40); : PRINT USING "X = j+### к"; X

1120 PRINT "D2 ("; U2$; ")  : ";

1130 INPUT ; "", D$

1140 IF D$ = "" AND D2 <> 0 THEN GOTO 1170

1150 D2 = VAL(D$) / WL2: IF D2 < .000001 THEN D2 = .000001

1160 IF D2 > .02 THEN M$ = "TOO FAT": GOSUB 2110: GOTO 1120

1170 PRINT

1180 L2 = (((X - 40) / FNA(D2)) + 1) / 2: L2 = L2 + BC2

1190 L2 = L2 * WL2: L1 = L1 * WL1: DL = L2 - L1: L2 = L2 / H2

1210 IF U2$ = "wl" THEN T$ = WL$ ELSE IF U2$ = "mm" THEN T$ = MM$ ELSE T$ = IN$

1220 PRINT USING T$; L2;

1230 IF F1 <> F2 THEN PRINT : RETURN ELSE PRINT TAB(40);

1240 IF U2$ = "wl" THEN T$ = DWL$ ELSE IF U2$ = "mm" THEN T$ = DMM$ ELSE T$ = DIN$

1250 PRINT USING T$; DL; : PRINT " (full lengths)"

1260 RETURN

1270 '

1290 ' Boom corrections

1300 GOSUB 2070 ' Clear help message

1310 CLS : LOCATE 3, 1

1320 PRINT "You have the following choices for boom material and element mounting method -"

1330 PRINT : PRINT TAB(10); "1 - Elements pass diametrically through round or square METAL boom,"

1340 PRINT TAB(14); "or across top of square boom, IN FULL CONTACT"

1350 PRINT

1360 PRINT TAB(10); "2 - Elements pass through METAL boom but are INSULATED"

1370 PRINT

1380 PRINT TAB(10); "3 - A non-metallic boom is used": PRINT TAB(14); "or"

1390 PRINT TAB(14); "Elements are mounted on insulators above or below the boom,"

1400 PRINT TAB(14); "with metal-to-metal spacing greater than the boom radius."

1410 PRINT

1420 PRINT "WARNING - option 3 means NO CORRECTION for influence of metal boom!"

1430 PRINT "If in doubt, select 1 or 2, and you can review your decision later."

1440 PRINT : PRINT "Press 1, 2 or 3   > ";

1450 E$ = INPUT$(1)

1460 IF E$ <> "1" AND E$ <> "2" AND E$ <> "3" THEN BEEP: GOTO 1450 ELSE PRINT E$

1470 IF E$ = "3" THEN BC = 0: GOTO 1860 ELSE PRINT

1480 PRINT "Diameter of metal boom must be less than 0.06 wavelengths";

1490 IF U$ = "wl" THEN PRINT "." ELSE PRINT ", ie": PRINT "less than ";

1500 IF U$ = "in" THEN PRINT USING "##.### in."; .06 * WL

1510 IF U$ = "mm" THEN PRINT USING "###.# mm."; .06 * WL

1520 PRINT

1530 PRINT "Enter boom diameter (or width of square/rectangular boom) in "; U$

1540 INPUT " : ", BD

1550 BD = BD / WL: IF BD > .06 THEN M$ = "TOO FAT": GOSUB 2100: GOTO 1540

1560 CLS : LOCATE 3, 1

1570 PRINT "Your choice of boom material and element mounting method involves a"

1580 PRINT "correction to all the element lengths."

1590 PRINT

1600 BC = 733 * BD * (.055 - BD) - 504 * BD * (.03 - BD)' Fits DL6WU data for BD<=0.055

1610 PRINT "Correction for elements in FULL CONTACT with METAL boom is"

1620 PRINT USING "#.### of the boom diameter."; BC

1630 PRINT : IF E$ = "1" GOTO 1670 ELSE BC = BC / 2

1640 PRINT "Since you have chosen INSULATED elements, the boom correction is half of that,"

1650 PRINT USING "ie #.### of the boom diameter."; BC

1660 PRINT

1670 PRINT "Is this boom correction OK? (Y/n)  > "; : A$ = INPUT$(1)

1680 IF A$ <> "N" AND A$ <> "n" GOTO 1850 ELSE PRINT

1690 PRINT: PRINT "You can either -"

1690 PRINT

1700 PRINT TAB(10); "1 - Enter your own boom correction"

1710 PRINT

1720 PRINT TAB(10); "2 - Go back and choose another element mounting method"

1730 PRINT

1740 PRINT "   or    3 - Accept the above boom correction after all"

1750 PRINT

1760 PRINT "Press 1, 2 or 3  > ";

1770 BC$ = INPUT$(1)

1780 IF BC$ <> "1" AND BC$ <> "2" AND BC$ <> "3" THEN BEEP: GOTO 1770 ELSE PRINT

1790 IF BC$ = "3" GOTO 1850

1800 IF BC$ = "2" GOTO 1310

1810 PRINT

1820 PRINT "Enter your own boom correction (as a fraction of boom diameter)"

1830 INPUT " : ", BC

1840 IF BC < 0 OR BC > 1 THEN BEEP: GOTO 1830

1850 BC = BC * BD

1860 CLS

1870 RETURN

1880 '

1970 ' Utility subroutines

1980 '

1990 ' Print message M$, centred on line 25 in reverse video

2000 IF LEN(M$) > 76 THEN PRINT "THIS MESSAGE IS TOO LONG": PRINT M$: STOP

2010 GOSUB 2070

2020 M$ = " " + M$ + " "

2030 LOCATE 25, (40 - INT(LEN(M$) / 2)): COLOR 0, 7: PRINT M$; : COLOR 7, 0

2040 RETURN

2050 '

2060 ' Clear line 25

2070 LOCATE 25, 1: PRINT SPACE$(79);

2080 RETURN

2090 '

2100 ' Print error message on line 25, pause, then clear input line

2110 YPOS = CSRLIN: IF YPOS > 24 THEN YPOS = 24

2120 BEEP

2130 GOSUB 2000  ' print msg

2140 GOSUB 2220  ' pause

2150 GOSUB 2070  ' clear msg

2160 LOCATE YPOS, 1

2170 PRINT SPACE$(50);

2180 LOCATE YPOS, 1

2190 RETURN

2200 '

2210 ' Delay loop

2220 TT = TIMER

2230 WHILE TIMER < (TT + 1.5): WEND

2240 RETURN