home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1
/
HamRadio.cdr
/
tech
/
eepub08
/
zcalc.bas
< prev
next >
Wrap
BASIC Source File
|
1987-01-22
|
11KB
|
199 lines
100 REM *********
110 REM
120 REM ZCALC.BAS 14-November-1986
130 REM
140 REM *********
150 REM INITIALIZE
160 CLS:PI=3.1416
170 REM *********
180 REM DISPLAY MENU
190 LOCATE 1,1
200 PRINT"ZCALC Version 2.3, 14-November-1986":LOCATE 1,70:PRINT"(E)xit":PRINT
210 PRINT"Reactance/Resonance, Q:"
220 PRINT" 1). C = 1/2*PI*F*Xc"
230 PRINT" 2). Xc = 1/2*PI*F*C"
240 PRINT" 3). F = 1/2*PI*Xc*C"
250 PRINT" 4). L = Xl/2*PI*F"
260 PRINT" 5). Xl = 2*PI*F*L"
270 PRINT" 6). F = Xl/2*PI*L
280 PRINT" 7). Fr = 1/2*PI*SQR(L*C)"
290 PRINT" 8). Cr = 1/4*PI^2*F^2*L"
300 PRINT" 9). Lr = 1/4*PI^2*F^2*C"
310 PRINT:PRINT"Inductors:"
320 PRINT"10). L = (N^2*RAD^2)/(9*RAD+10*H)"
330 PRINT"11). N = SQR((L*(9*RAD+10*H))/RAD^2)"
340 PRINT"12). H = ((N^2*RAD^2)-(9*L*RAD))/(10*L)"
350 PRINT"13). RAD = SQR((9*L/2*N^2)^2+(10*H*L/N^2))+(9*L/2*N^2)
360 PRINT:PRINT"Series/Parallel Conversion: (C)apacitive, (I)nductive"
370 PRINT"(W)ire Calculations":PRINT
380 REM *********
390 SELX$="":R=0
400 PRINT"Select: ";
410 SEL$=INKEY$:IF SEL$="" THEN GOTO 410
420 IF SEL$="C" OR SEL$="c" OR SEL$="I" OR SEL$="i" THEN GOTO 1480
430 IF SEL$="E" OR SEL$="e" THEN CLS:END
440 IF SEL$="W" OR SEL$="w" THEN GOTO 1600
450 IF SEL$=CHR$(13) OR (SEL$="0" AND LEN(SELX$)=1) THEN GOTO 470
460 IF VAL(SEL$)=0 THEN BEEP:GOTO 410
470 SELX$=SELX$+SEL$:SEL=INT(VAL(SELX$)):LOCATE 23,9:PRINT SELX$; 'E
480 IF SEL>1 AND SEL<=13 THEN PRINT:GOTO 510
490 IF SEL=1 AND LEN(SELX$)=2 THEN PRINT:GOTO 510
500 IF SEL<1 OR SEL>13 THEN BEEP:CLS:GOTO 180 ELSE GOTO 410
510 REM *********
520 CLS:IF SEL<10 THEN PRINT"To display Q and Time Constant: ":INPUT"Enter resistance, or <cr> to continue: ";R:PRINT
530 ON SEL GOSUB 650,690,730,770,810,850,890,930,970,1010,1060,1110,1160
540 IF SEL>9 OR R=0 THEN GOTO 180
550 IF SEL>6 GOTO 570
560 QS=X/R:QP=R/X:GOTO 580
570 QS=SQR(L/C)/R:QP=R/SQR(L/C)
580 IF SEL<3 THEN TC=C*R ELSE IF (SEL>3 AND SEL<7) THEN TC=L*R 'E
590 LOCATE 6,55:PRINT"R = ";R;" ohms":LOCATE 7,54:PRINT"Qs = ";QS:LOCATE 8,54:PRINT"Qp = ";QP:IF SEL<7 THEN LOCATE 9,54:PRINT"TC = ";TC;" secs.":LOCATE 10,52:PRINT"1/TC = ";1/TC;" hz"
600 IF SEL<7 THEN GOTO 180
610 IF (QS<10 AND QS>.5) THEN FREQATQ=SQR(1-(1/(4*QS^2)))/(2*PI*(SQR(L*C))):LOCATE 9,49:PRINT"Fr @ Qs = ";FREQATQ;" hz"
620 IF (QP<10 AND QP>.5) THEN FREQATQ=SQR(1-(1/(4*QP^2)))/(2*PI*(SQR(L*C))) ELSE GOTO 180
630 IF (QS<10 AND QS>.5) THEN LOCATE 10,49 ELSE LOCATE 9,49
640 PRINT"Fr @ Qp = ";FREQATQ;" hz":GOTO 180
650 REM ********* # 1
660 INPUT"Frequency (hz): ";FREQ:PRINT:INPUT"Xc (ohms): ";X
670 C=1/(2*PI*FREQ*X)
680 CLS:LOCATE 3,50:PRINT" #1 C = ";C;" farads ":LOCATE 4,55:PRINT"F = ";FREQ;" hz":LOCATE 5,54:PRINT"Xc = ";X;" ohms":RETURN
690 REM ********* # 2
700 INPUT"Frequency (hz): ";FREQ:PRINT:INPUT"C (farads): ";C
710 X=1/(2*PI*FREQ*C)
720 CLS:LOCATE 3,49:PRINT" #2 Xc = ";X;" ohms ":LOCATE 4,55:PRINT"F = ";FREQ;" hz":LOCATE 5,55:PRINT"C = ";C;" farads":RETURN
730 REM ********* # 3
740 INPUT"C (farads): ";C:PRINT:INPUT"Xc (ohms): ";X
750 FREQ=1/(2*PI*X*C)
760 CLS:LOCATE 3,50:PRINT" #3 F = ";FREQ;" hz ":LOCATE 4,54:PRINT"Xc = ";X;" ohms":LOCATE 5,55:PRINT"C = ";C;" farads":RETURN
770 REM ********* # 4
780 INPUT"Frequency (hz): ";FREQ:PRINT:INPUT"Xl (ohms): ";X
790 L=X/(2*PI*FREQ)
800 CLS:LOCATE 3,50:PRINT" #4 L = ";L;" henrys ":LOCATE 4,55:PRINT"F = ";FREQ;" hz":LOCATE 5,54:PRINT"Xl = ";X;" ohms":RETURN
810 REM ********* # 5
820 INPUT"Frequency (hz): ";FREQ:PRINT:INPUT"L (henrys): ";L
830 X=2*PI*FREQ*L
840 CLS:LOCATE 3,50:PRINT" #5 Xl = ";X;" ohms ":LOCATE 4,55:PRINT"L = ";L;" henrys":LOCATE 5,55:PRINT"F = ";FREQ;" hz":RETURN
850 REM ********* # 6
860 INPUT"Xl (ohms): ";X:PRINT:INPUT"L (henrys): ";L
870 FREQ=X/(2*PI*L)
880 CLS:LOCATE 3,50:PRINT" #6 F = ";FREQ;" hz ":LOCATE 4,55:PRINT"L = ";L;" henrys":LOCATE 5,54:PRINT"Xl = ";X;" ohms":RETURN
890 REM ********* # 7
900 INPUT"L (henrys): ";L:PRINT:INPUT"C (farads): ";C
910 FREQ=1/(2*PI*SQR(L*C))
920 CLS:LOCATE 3,50:PRINT" #7 Fr = ";FREQ;" hz ":LOCATE 4,55:PRINT"L = ";L;" henrys":LOCATE 5,55:PRINT"C = ";C;" farads":RETURN
930 REM ********* # 8
940 INPUT"L (henrys): ";L:PRINT:INPUT"F (hz): ";FREQ
950 C=1/(4*PI^2*FREQ^2*L)
960 CLS:LOCATE 3,50:PRINT" #8 Cr = ";C; " farads ":LOCATE 4,55:PRINT"L = ";L;" henrys":LOCATE 5,55:PRINT"F = ";FREQ;" hz":RETURN
970 REM ********* # 9
980 INPUT"C (farads): ";C:PRINT:INPUT"F (hz): ";FREQ
990 L=1/(4*PI^2*FREQ^2*C)
1000 CLS:LOCATE 3,50:PRINT" #9 Lr = ";L;" henrys ":LOCATE 4,55:PRINT"C = ";C;" farads":LOCATE 5,55:PRINT"F = ";FREQ;" hz":RETURN
1010 REM ********* #10
1020 INPUT"Number of turns: ";N:PRINT:INPUT"Radius (inches): ";RAD:PRINT:INPUT"Height (inches): ";H
1030 L=(N^2*RAD^2*.000001)/(9*RAD+10*H):GOSUB 1250:IF FLAG1>0 OR FLAG2>0 THEN GOSUB 1380 ELSE GOTO 1050
1040 L=(N^2*RAD^2*.000001)/(9*RAD+10*H)
1050 CLS:LOCATE 3,50:PRINT" #10 L = ";L;" henrys ":LOCATE 4,55:PRINT"N = ";N;" turns":LOCATE 5,55:PRINT"H = ";H;" inches":LOCATE 6,53:PRINT"RAD = ";RAD;" inches":GOSUB 1220:RETURN 'E
1060 REM ********* #11
1070 INPUT"Inductance (henrys): ";L:PRINT:INPUT"Radius (inches): ";RAD:PRINT:INPUT"Height (inches): ";H
1080 N=SQR((L*1000000!*(9*RAD+10*H))/RAD^2):GOSUB 1250:IF FLAG1>0 OR FLAG2>0 THEN GOSUB 1380 ELSE GOTO 1100
1090 N=SQR((L*1000000!*(9*RAD+10*H))/RAD^2)
1100 CLS:LOCATE 3,50:PRINT" #11 N = ";N;" turns ":LOCATE 4,55:PRINT"H = ";H;" inches ":LOCATE 5,55:PRINT"L = ";L;" henrys":LOCATE 6,53:PRINT"RAD = ";RAD;" inches":GOSUB 1220:RETURN 'E
1110 REM ********* #12
1120 INPUT"Inductance (henrys): ";L:PRINT:INPUT"Radius (inches): ";RAD:PRINT:INPUT"# of Turns: ";N
1130 H=((N^2*RAD^2)-(9*L*1000000!*RAD))/(10*L*1000000!):GOSUB 1250:IF FLAG1>0 OR FLAG2>0 THEN GOSUB 1380 ELSE GOTO 1150
1140 H=((N^2*RAD^2)-(9*L*1000000!*RAD))/(10*L*1000000!)
1150 CLS:LOCATE 3,50:PRINT" #12 H = ";H;" inches ":LOCATE 4,55:PRINT"N = ";N;" turns ":LOCATE 5,55:PRINT"L = ";L;" henrys":LOCATE 6,53:PRINT"RAD = ";RAD;" inches":GOSUB 1220:RETURN 'E
1160 REM ********* #13
1170 INPUT"Inductance (henrys): ";L:PRINT:INPUT"Heigth (inches): ";H:PRINT:INPUT"Number of turns: ";N
1180 RAD=SQR((((9*L*1000000!)/(2*N^2))^2)+((10*H*L*1000000!)/N^2))+((9*L*1000000!)/(2*N^2)):GOSUB 1250:IF FLAG1>0 OR FLAG2>0 THEN GOSUB 1380 ELSE GOTO 1200
1190 RAD=SQR((((9*L*1000000!)/(2*N^2))^2)+((10*H*L*1000000!)/N^2))+((9*L*1000000!)/(2*N^2))
1200 CLS:LOCATE 3,50:PRINT" #13 H = ";H;" inches ":LOCATE 4,55:PRINT"N = ";N;" turns ":LOCATE 5,55:PRINT"L = ";L;" henrys":LOCATE 6,53:PRINT"RAD = ";RAD;" inches":GOSUB 1220:RETURN 'E
1210 REM *********
1220 REM PRINT MISC. INDUCTOR PARAMETERS
1230 LOCATE 7,53:PRINT"L/D = ";H/(2*RAD):LOCATE 8,54:PRINT"OD = ";H/N:LOCATE 9,50:PRINT"LG(ft) = ";(N*2*PI*RAD)/12
1240 RETURN
1250 REM *********
1260 REM INDUCTOR OPTIMIZER
1270 PRINT:PRINT:PRINT"Optimize H and N for value of wire OD, Y/N? ":PRINT"Note: Adjust height for smallest value determined by wire OD.
1280 X$=INKEY$:IF X$="" THEN GOTO 1280
1290 IF X$="Y" OR X$="y" THEN FLAG2=1:PRINT:INPUT"Wire OD: ";OD:GOTO 1320
1300 IF X$="N" OR X$="n" OR X$=CHR$(13) THEN FLAG2=0:GOTO 1320
1310 BEEP:GOTO 1280
1320 PRINT:PRINT:PRINT"Input L/D ratio, Y/N? ":PRINT"Note: Adjust radius for value of L/D input."
1330 X$=INKEY$:IF X$="" THEN GOTO 1330
1340 IF X$="Y" OR X$="y" THEN FLAG1=1:PRINT:PRINT:INPUT"L/D: ";LDOPT:RETURN
1350 IF X$="N" OR X$="n" OR X$=CHR$(13) THEN FLAG1=0:RETURN
1360 BEEP:GOTO 1330
1370 REM *********
1380 REM OPTIMIZE INDUCTOR
1390 IF FLAG2=0 THEN GOTO 1410
1400 FOR I%=1 TO 100:H=N*OD:N=(SQR(L*1000000!*(9*RAD+10*H)))/RAD:NEXT I%
1410 IF FLAG1=0 THEN RETURN ELSE LG=N*2*PI*RAD:OD=H/N:LD=H/(2*RAD) 'E
1420 FOR I%=1 TO 10
1430 RAD=RAD*((LD/(2*LDOPT))+.5)
1440 N=LG/(2*PI*RAD)
1450 H=N*OD
1460 LD=H/(2*RAD):NEXT I%:RETURN
1470 REM *********
1480 REM SERIES/PARALLEL CONVERSION
1490 CLS:PRINT"SERIES/PARALLEL CONVERSION":PRINT
1500 INPUT"Resistance (ohms): ";R:PRINT
1510 INPUT"Reactance (ohms): ";X:IF X<=0 THEN BEEP:PRINT:GOTO 1510 ELSE CLS
1520 RP=(R^2+X^2)/R:XP=(R^2+X^2)/X:IF SEL$="C" OR SEL$="c" THEN XP=-XP
1530 RS=R/(1+(R/X)^2):XS=(RS*R)/X:IF SEL$="C" OR SEL$="c" THEN XS=-XS
1540 IF SEL$="c" THEN SEL$="C" ELSE IF SEL$="i" THEN SEL$="I"
1550 LOCATE 3,49:PRINT"# ";SEL$;" R = ";R;" ohms":LOCATE 4,55:PRINT"X = ";X;" ohms"
1560 LOCATE 6,55:PRINT"Rp = ";RP;" ohms":LOCATE 7,55:PRINT"Xp = ";XP;" ohms"
1570 LOCATE 9,55:PRINT"Rs = ";RS;" ohms":LOCATE 10,55:PRINT"Xs = ";XS;" ohms"
1580 GOTO 180
1590 REM *********
1600 REM WIRE CALCULATIONS
1610 CLS:PRINT"WIRE CALCULATIONS:":LOCATE 1,70:PRINT"(E)xit":PRINT
1620 PRINT" 1). Enter Gauge."
1630 PRINT" 2). Enter Resistance."
1640 PRINT" 3). Enter Wire Diameter."
1650 PRINT" 4). Enter Cross-section."
1660 PRINT" 5). Enter Lbs./1000 Feet."
1670 PRINT:PRINT"Select: ";
1680 SEL$=INKEY$:IF SEL$="" THEN GOTO 1680
1690 IF SEL$="E" OR SEL$="e" THEN CLS:GOTO 180
1700 SEL=INT(VAL(SEL$)):IF SEL < 1 OR SEL > 5 THEN BEEP:GOTO 1680
1710 ON SEL GOTO 1720,1760,1800,1840,1880
1720 REM *********
1730 PRINT:PRINT:INPUT"Wire Gauge: ";WG:PRINT
1740 RFT=.0001/.793^WG:WD=.325/1.123^WG:WX=106000!/1.261^WG:WT=3.02699E-03*WX
1750 GOTO 1920
1760 REM *********
1770 PRINT:PRINT:INPUT"Resistance/Foot: ";RFT:PRINT
1780 WG=LOG (.0001/RFT)/LOG(.793):WD=.325/1.123^WG:WX=106000!/1.261^WG:WT=3.02699E-03*WX
1790 GOTO 1920
1800 REM *********
1810 PRINT:PRINT:INPUT"Wire Diameter: ";WD:PRINT
1820 WG=LOG(.325/WD)/LOG(1.123):RFT=.0001/.793^WG:WX=106000!/1.261^WG:WT=3.02699E-03*WX
1830 GOTO 1920
1840 REM *********
1850 PRINT:PRINT:INPUT"Cross-section: ";WX:PRINT
1860 WG=LOG(106000!/WX)/LOG(1.261):RFT=.0001/.793^WG:WD=.325/1.123^WG:WT=3.02699E-03*WX
1870 GOTO 1920
1880 REM *********
1890 PRINT:PRINT:INPUT"Lbs./1000 Feet: ";WT:PRINT
1900 WX=WT/3.02699E-03:WG=LOG(106000!/WX)/LOG(1.261):RFT=.0001/.793^WG:WD=.325/1.123^WG:WT=3.02699E-03*WX
1910 GOTO 1920
1920 REM *********
1930 INPUT"Frequency, or <cr>: ";FREQ
1940 SKNDP=2.6/SQR(FREQ)
1950 RX=WD/2:RACK=(PI*RX^2)/((2*PI*SKNDP*RX)-(PI*SKNDP^2)):IF RACK<1 THEN RACK=1
1960 RAC=RFT*RACK
1970 REM *********
1980 CLS:WG%=WG
1990 LOCATE 3,45:PRINT"Wire Gauge: ";WG%
2000 LOCATE 4,45:PRINT"Resistance/Foot: ";RFT
2010 LOCATE 5,45:PRINT"Wire Diameter: ";WD
2020 LOCATE 6,45:PRINT"Lbs./1000 Feet: ";WT
2030 LOCATE 7,45:PRINT"Cross-section: ";WX;" mils"
2040 LOCATE 8,45:PRINT"Resistance/Foot (AC): ";RAC
2050 LOCATE 9,45:PRINT"@ Frequency (hz): ";FREQ
2060 GOTO 180
2070 REM END