100 ' RF1CHAR.BAS Dan Maguire AC6LA 110 ' 120 ' Determine transmission line characteristics using the RF-1. 130 ' 140 ' Transmission line equation algorithm by John Grebenkemper, KI6WX. 150 ' Line Xo component algorithm by Charlie Michaels, W7XC. 160 ' For more explanatory notes on both, see the ZIZL.BAS program. 170 ' 180 NEPER = 8.685889 190 TWOPI = 6.283185 200 SL = 983.5712 210 SIGMA.EST = .56 220 DIM FQ.X(5), ZP.X(5), VF.X(5), DBFQ.X(5), DB10.X(5), SIGMA.X(5) 230 DIM FB$(9) 240 FB$(1)=" 1.8" : FB$(2)=" 3.5" : FB$(3)=" 7.0" 250 FB$(4)="10.1" : FB$(5)="14.0" : FB$(6)="18.1" 260 FB$(7)="21.0" : FB$(8)="24.9" : FB$(9)="28.0" 270 ' 280 COLOR 7,1 290 CLS 300 PRINT "--- RF1CHAR ---"; 310 PRINT " Determine transmission line characteristics using the RF-1" 320 PRINT 330 PRINT "Attach a long (30+ feet) length of transmission line to the RF-1." 340 PRINT "Terminate the other end of the line with a short or open circuit." 350 ' 360 PRINT 370 INPUT "Line length in feet. If unsure enter best guess"; LF 380 IF LF = 0 THEN BEEP : GOTO 360 390 ' 400 PRINT 410 INPUT "Is termination a short or open circuit (s/o)"; TERM$ 420 IF TERM$ = "s" THEN RA = 0 : XA = 0 : N = .25 : GOTO 460 430 IF TERM$ = "o" THEN RA = 1E+10 : XA = 0 : N = .5 : GOTO 460 440 BEEP : GOTO 410 450 ' 460 PRINT 470 PRINT "Approximate velocity factor (eg, .66), if known." 480 INPUT "If unsure then just press Enter without a value"; VF.EST 490 IF VF.EST = 0 THEN FQ.NEXT = 0 ELSE FQ.NEXT = (N * SL * VF.EST) / LF 500 ' 510 CLS 520 PRINT "--- RF1CHAR ---"; 530 PRINT " Determine transmission line characteristics using the RF-1" 540 PRINT 550 PRINT "Slowly increase the frequency from minimum until the Z reading peaks." 560 IF FQ.NEXT = 0 THEN GOTO 590 570 PRINT "(At approximately "; USING "##.##"; FQ.NEXT; 580 PRINT " MHz, depending on length and velocity factor.) 590 PRINT "If Z reads 'H' then determine the center frequency of the 'H' range." 600 ' 610 PREF$ = "Lowest " 620 FOR I% = 1 TO 5 STEP 1 630 PRINT 640 PRINT PREF$;"frequency (MHz) at which Z peaks"; 650 IF FQ.NEXT = 0 THEN GOTO 690 660 CSRX = POS(0) 670 PRINT SPC(12);"(";CHR$(126);USING"##.##";FQ.NEXT;:PRINT ")"; 680 LOCATE ,CSRX 690 INPUT ""; FQ.X(I%) 700 ' 710 VF.X(I%) = (LF * FQ.X(I%)) / (SL * N) 720 IF I% > 1 THEN GOTO 920 730 PREF$ = " Next " 740 IF N = .25 THEN FQ.QTR = FQ.X(I%) ELSE FQ.QTR = FQ.X(I%) / 2 750 ' 760 ' Sanity check. 770 ' 780 IF VF.X(I%) > .5 AND VF.X(I%) < 1 THEN GOTO 920 790 BEEP 800 COLOR 14 810 PRINT 820 PRINT "Velocity factor computed to be"; USING "##.###"; VF.X(I%); 830 PRINT ", which is not reasonable." 840 PRINT "Line length, termination, or lowest frequency may be incorrect." 850 PRINT "For long lines you may have to use open circuit termination." 860 PRINT 870 INPUT "Enter 'q' to quit now, anything else to start again"; QUIT$ 880 COLOR 7 890 IF QUIT$ = "q" THEN COLOR 7,0: CLS: SYSTEM 900 GOTO 400 910 ' 920 PRINT TAB(25); "Z value at peak"; 930 IF I% > 1 THEN GOTO 970 940 CSRX = POS(0) 950 PRINT SPC(12);"(If 'H' enter 0)"; 960 LOCATE ,CSRX 970 INPUT ""; ZP.X(I%) 980 ' 990 CNT% = I% 1000 N = N + .5 1010 FQ.NEXT = FQ.X(I%) + FQ.QTR * 2 1020 IF FQ.NEXT > 35 THEN GOTO 1100 'Approx RF-1 max freq 1030 NEXT I% 1040 ' 1050 ' Determine line Ro by measuring Z at low frequency quarter wave points. 1060 ' Using quarter wave points puts the line X value at a minimum, so the 1070 ' measured Z is almost all R. Note that line Xo is always calculated, 1080 ' so there is no need to measure it. (Antenna Book pg 27-27, 17th ed) 1090 ' 1100 CLS 1110 PRINT "--- RF1CHAR ---"; 1120 PRINT " Determine transmission line characteristics using the RF-1" 1130 PRINT 1140 PRINT "Change termination to approximately the line Zo (ie, 50, 75, 450, etc ohms)." 1150 PRINT "If you do not have such a termination available enter your best guess for" 1160 PRINT "the line Zo for both of the following prompts." 1170 ' 1180 F1 = FQ.X(1) - FQ.QTR 1190 IF F1 < 1.2 THEN F1 = FQ.X(1) 'Aprox RF-1 min freq 1200 F2 = F1 + FQ.QTR 1210 ' 1220 PRINT 1230 PRINT " Z value at "; USING "##.###"; F1; : PRINT " MHz"; 1240 INPUT ""; Z1 1250 PRINT 1260 PRINT " Z value at "; USING "##.###"; F2; : PRINT " MHz"; 1270 INPUT ""; Z2 1280 ' 1290 R0 = SQR(Z1 * Z2) 1300 ' 1310 ' Determine attenuation at Z peak frequencies by iteratively solving 1320 ' the transmission line equation using estimates of the attenuation 1330 ' value. This is more accurate than directly measuring the Z value 1340 ' at Z minimum frequencies, since a relatively small change in 1350 ' attenuation produces a much larger change in Z at a Z peak point 1360 ' than at a Z minimum point. 1370 ' 1380 FOR I% = 1 TO CNT% STEP 1 1390 ZP = ZP.X(I%) 1400 IF ZP = 0 THEN GOTO 1680 1410 FQ = FQ.X(I%) 1420 VF = VF.X(I%) 1430 DBFQ = 0 1440 ' 1450 DBFQ = DBFQ + 1! 1460 GOSUB 2580 1470 IF ZIN > ZP THEN GOTO 1450 1480 ' 1490 DBFQ = DBFQ - .1 1500 GOSUB 2580 1510 IF ZIN < ZP THEN GOTO 1490 1520 ' 1530 DBFQ = DBFQ + .01 1540 GOSUB 2580 1550 IF ZIN > ZP THEN GOTO 1530 1560 ' 1570 PREV.ZIN = ZIN 1580 DBFQ = DBFQ - .001 1590 GOSUB 2580 1600 IF ZIN < ZP THEN PREV.ZIN = ZIN : GOTO 1580 1610 ' 1620 IF (ZP - PREV.ZIN) < (ZIN - ZP) THEN DBFQ = DBFQ + .001 1630 DBFQ.X(I%) = DBFQ 1640 ' 1650 DB10.X(I%) = DBFQ * (10 / FQ) ^ SIGMA.EST 1660 IF DBFQ.X(I%-1) = 0 THEN GOTO 1680 1670 SIGMA.X(I%) = LOG(DBFQ/DBFQ.X(I%-1)) / LOG(FQ/FQ.X(I%-1)) 1680 NEXT I% 1690 ' 1700 ' Results 1710 ' 1720 CLS 1730 PRINT "--- RF1CHAR ---"; 1740 PRINT " Determine transmission line characteristics using the RF-1" 1750 PRINT 1760 PRINT "Line length ="; USING "####.##"; LF; : PRINT " feet"; 1770 PRINT SPC(8); "Termination ="; 1780 IF TERM$ = "o" THEN PRINT " Open circuit" ELSE PRINT " Short circuit" 1790 PRINT 1800 PRINT "Calculated Zo ="; USING"####.#"; R0 1810 PRINT 1820 PRINT " dB per dB/100ft" 1830 PRINT " Freq Z WL VF 100 ft sigma at 10 MHz" 1840 PRINT SPC(1); STRING$(6,196); SPC(3); STRING$(4,196); SPC(3); STRING$(4,196); 1850 PRINT SPC(4); STRING$(5,196); SPC(3); STRING$(6,196); SPC(4); STRING$(5,196); 1860 PRINT SPC(3); STRING$(9,196) 1870 ' 1880 IF TERM$ = "s" THEN N = .25 ELSE N = .5 1890 VF.SUM = 0 : SIGMA.SUM = 0 : DB10.SUM = 0 : J% = 0 : K% = 0 1900 FOR I% = 1 TO CNT% STEP 1 1910 PRINT USING "###.###"; FQ.X(I%); 1920 IF ZP.X(I%) = 0 THEN PRINT SPC(7); : GOTO 1940 1930 PRINT USING "#######"; ZP.X(I%); 1940 PRINT USING "####.##"; N; 1950 PRINT USING "#####.###"; VF.X(I%); 1960 VF.SUM = VF.SUM + VF.X(I%) 1970 IF DBFQ.X(I%) = 0 THEN PRINT SPC(9); : GOTO 1990 1980 PRINT USING "#####.###"; DBFQ.X(I%); 1990 IF SIGMA.X(I%) = 0 THEN PRINT SPC(9); : GOTO 2020 2000 PRINT USING "#####.###"; SIGMA.X(I%); 2010 SIGMA.SUM = SIGMA.SUM + SIGMA.X(I%) : J% = J% + 1 2020 IF DB10.X(I%) = 0 THEN PRINT : GOTO 2050 2030 PRINT USING "######.###"; DB10.X(I%) 2040 DB10.SUM = DB10.SUM + DB10.X(I%) : K% = K% + 1 2050 N = N + .5 2060 NEXT I% 2070 ' 2080 PRINT SPC(25); STRING$(5,205); SPC(13); STRING$(5,205); SPC(5); STRING$(5,205) 2090 PRINT SPC(9); "Averages -->"; 2100 PRINT USING "#####.###"; VF.SUM/CNT%; 2110 PRINT SPC(8); 2120 IF J% = 0 THEN PRINT SPC(10); : GOTO 2140 2130 PRINT USING "######.###"; SIGMA.SUM/J%; 2140 IF K% = 0 THEN PRINT SPC(10); : GOTO 2160 2150 PRINT USING "######.###"; DB10.SUM/K% 2160 ' 2170 IF K% = 0 THEN GOTO 2380 2180 DB10LF = (DB10.SUM / K%) / 100 * LF 2190 LOCATE 3,62 2200 PRINT CHR$(201); STRING$(16,205); CHR$(187) 2210 LOCATE ,62 2220 PRINT CHR$(186); " dB per band at "; CHR$(186) 2230 LOCATE ,62 2240 PRINT CHR$(186); " given length "; CHR$(186) 2250 LOCATE ,62 2260 PRINT CHR$(186); " Freq dB "; CHR$(186) 2270 LOCATE ,62 2280 PRINT CHR$(186); SPC(2); STRING$(4,196); SPC(3); STRING$(5,196); SPC(2); CHR$(186) 2290 FOR I% = 1 TO 9 STEP 1 2300 LOCATE ,62 2310 PRINT CHR$(186); SPC(2); 2320 PRINT FB$(I%); USING "####.###"; DB10LF * (VAL(FB$(I%))/10) ^ SIGMA.EST; 2330 PRINT SPC(2); CHR$(186) 2340 NEXT I% 2350 LOCATE ,62 2360 PRINT CHR$(200); STRING$(16,205); CHR$(188) 2370 ' 2380 LOCATE 19,1 2390 PRINT "Note: The 'dB/100ft at 10 MHz' and 'dB per band' values were all calculated" 2400 PRINT "using the same estimated sigma ("; USING "#.###"; SIGMA.EST; 2410 PRINT "). They are accurate only if that" 2420 PRINT "estimated sigma value was approximately correct." 2430 ' 2440 PRINT 2450 INPUT "New sigma for attenuation interpolation, or 0 to quit"; SIGMA.EST 2460 IF SIGMA.EST = 0 THEN COLOR 7,0: CLS: SYSTEM 2470 ' 2480 FOR I% = 1 TO CNT% STEP 1 2490 DB10.X(I%) = DBFQ.X(I%) * (10 / FQ.X(I%)) ^ SIGMA.EST 2500 NEXT I% 2510 GOTO 1720 2520 '---------------------------------------------------------------------- 2530 ' 2540 ' Subroutine to compute line Xo and solve transmission line equation. 2550 ' Variables expected to be set: R0, DBFQ, FQ, VF, LF 2560 ' Variables which are calculated: RIN, XIN, ZIN 2570 ' 2580 ALPHA = (DBFQ / 100) / NEPER 2590 BETA = (TWOPI * FQ) / (SL * VF) 2600 X0 = -R0 * ALPHA / BETA 2610 ' 2620 LW = (LF * FQ) / (SL * VF) 2630 MLDB = DBFQ / 100 * LF 2640 ' 2650 F1 = FQ / LW 2660 GR = MLDB / NEPER 2670 GI = TWOPI * FQ / F1 2680 ' 2690 E1 = EXP(GR) 2700 E2 = EXP(-GR) 2710 SR = COS(GI) * (E1 - E2) / 2 2720 SI = SIN(GI) * (E1 + E2) / 2 2730 CR = COS(GI) * (E1 + E2) / 2 2740 CI = SIN(GI) * (E1 - E2) / 2 2750 ' 2760 HR = RA * CR - XA * CI + R0 * SR - X0 * SI 2770 HI = RA * CI + XA * CR + R0 * SI + X0 * SR 2780 QR = R0 * CR - X0 * CI + RA * SR - XA * SI 2790 QI = R0 * CI + X0 * CR + RA * SI + XA * SR 2800 YR = ( HR * QR + HI * QI) / (QR * QR + QI * QI) 2810 YI = (-HR * QI + HI * QR) / (QR * QR + QI * QI) 2820 ' 2830 RIN = R0 * YR - X0 * YI 2840 XIN = R0 * YI + X0 * YR 2850 ZIN = SQR(RIN * RIN + XIN * XIN) 2860 ' 2870 RETURN