1 COMMON A, AL, B, BASEONLY, C, C$, C1, CAT$, CC, CKT$, D, D$, DD, DIA, DIMN$, DMS, E, EO, EX$, F, F$, FD, FF, FQ, FRQ, G$, GO$, I, I$, L, LATLONG, LD, LL, LN, LS, LW, LX, MAX, MENU, MIN, MX, N, NN, NT, OV, P, PI, PROG$, Q, QQ, QU, R, RA, RC, T, T$, U, U$, UH, UL$, V$, VC, W, WHIP, WIRD, WW, X, X$, X1, XS, Z$, ZP, ZS
5 'OMMON EX$,PROG$,UH,U,F,D,L,N,T,X
10 'TUNECCT - Tuned Circuit - 27 MAR 86 rev. 29 NOV 2007
20 IF EX$=""THEN EX$="EXIT"
30 PROG$="tunecct"
40 
50 CLS:KEY OFF
60 COLOR 7,0,1
70 U$="####.###"
80 U1$="####,###.###"
90 U2$="####,###"
100 UL$=STRING$(80,205)
110 L$=STRING$(40,205)
120 X$=STRING$(40,32)
130 PI=3.141592
140 DIM AWG(40,2)         'AWG sizes
150 '.....AWG calculator
160 K#=(4.600000E-01/4.999999E-03)^(1/39)  'incremental multiplier
170 FOR Z=1 TO 40
180  NZ=Z+3
190  WIRE=4.600000E-01/K#^NZ       'wire diameter in inches
200  CIRC=(WIRE*10^3)^2   'circular mils
210  OHM=10574/CIRC       'ohms per 1000 ft.
220  OHM=OHM/(12*10^3)    'ohms per inch
230  AWG(Z,1)=WIRE
240  AWG(Z,2)=OHM
250 NEXT Z
260 GOTO 340
270 '
280 '.....erase lines
290 FOR Z=E1 TO E2:LOCATE Z,E3:PRINT STRING$(40,32);
300 IF E2<24 THEN PRINT ""
310 NEXT Z
320 RETURN
330 '
340 '.....start
350 CLS
360 F=0:W=0:C=0:X=0:PF=0:FQC=0
370 D=0:R=0:L=0:N=0:T=0:Q=0:U=0:UH=0
380 COLOR 15,2
390 PRINT " L/C TUNED CIRCUITS (Inductor/Capacitor)";
400 PRINT TAB(57);;"by George Murphy VE3ERP ";
410 COLOR 1,0:PRINT STRING$(80,223);
420 COLOR 7,0
430 GOSUB 2300
440 PRINT " Press number in < > to choose standard units of measure:"
450 PRINT UL$;
460 PRINT "   < 1 >  Metric"
470 PRINT "   < 2 >  U.S.A./Imperial"
480 PRINT UL$;
490 PRINT "     or Press < 0 > to EXIT....."
500 Z$=INKEY$
510 IF Z$="0"THEN CLS:CHAIN EX$
520 IF Z$="1"THEN UM=2.539999E+01:UM$="mm.":GOTO 550
530 IF Z$="2"THEN UM=1:UM$="in.":GOTO 550
540 GOTO 500
550 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
560 PRINT " Press letter in < > to:"
570 PRINT UL$;
580 PRINT "  < 1 >  Design a tuned L/C network"
590 PRINT "  < 2 >  Design a single-layer air-core coil"
600 PRINT "  < 3 >  Find impedance of an L/C network"
610 PRINT UL$;
620 Z$=INKEY$
630 IF Z$="1"OR Z$="2" THEN VIEW PRINT 3 TO 24:CLS:VIEW PRINT
640 IF Z$="1"THEN 1350
650 IF Z$="2"THEN 690
660 IF Z$="3"THEN CLS:CHAIN"dsgnmenu"
670 GOTO 620
680 '
690 '.....coil
700 LOCATE 3
710 PRINT TAB(7);;"SINGLE-LAYER AIR-CORE COIL"
720 PRINT UL$;
730 LOCATE CSRLIN-3,40:PRINT "º"
740 LOCATE CSRLIN,40:PRINT "º"
750 LOCATE CSRLIN,40:PRINT "Ê"
760 PRINT " For best Q turns per inch should"
770 PRINT " be between 1.4 and 2.2. 1.33 is"
780 PRINT " recommended."
790 '.....inputs
800 GOSUB 920:IF R THEN 820
810 PRINT " ENTER: Coil diameter (";UM$;;")";:INPUT D:D=D/UM:R=D/2
820 GOSUB 920:IF L THEN 840
830 PRINT " ENTER: Coil length (";UM$;;")..";:INPUT L:L=L/UM
840 GOSUB 920:IF U+N THEN 860
850 INPUT " ENTER: Inductance (æH) .......";U
860 GOSUB 920:IF N+U THEN 880
870 INPUT " ENTER: Number of turns .......";N
880 GOSUB 920:IF T THEN 900
890 INPUT " ENTER: Turns per 25.4mm (inch)";T
900 GOSUB 920:GOTO 800
910 '
920 LOCATE 9:PRINT X$
930 IF U=0 THEN IF R*L*N THEN U=R^2*N^2/(9*R+10*L)
940 IF N=0 THEN IF R*L*U THEN N=(SQR(U*(9*R+10*L)))/R
950 IF N=0 THEN IF L*T THEN N=L*T
960 IF L=0 THEN IF N*T THEN L=N/T
970 IF T=0 THEN IF N*L THEN T=N/L
980 IF L=0 THEN IF R*T*U THEN Q=R^2*T^2/U:L=ABS(-10-SQR(100+36*R*Q))/2/Q
990 IF R*L*N*U THEN 1010 ELSE LOCATE 9:RETURN
1000 '
1010 LOCATE 9:PRINT X$:LOCATE 9
1020 PRINT " Coil diameter (";UM$;;")......";USING U1$;D*UM
1030 PRINT " Coil length (";UM$;;")........";USING U1$;L*UM
1040 PRINT " Number of turns .........";USING U1$;N
1050 PRINT " Turns per 25.4mm (inch)..";USING U1$;T
1060 SP=1/T
1070 PRINT " Turn spacing (";UM$;;").......";USING U1$;SP*UM
1080 PRINT " Inductance (æH) .........";USING U1$;U
1090 PRINT L$
1100 UCOIL=U      'remember inductance
1110 IF F*U THEN GOSUB 2130
1120 GOSUB 2470   'screen dump option
1130 '
1140 LOCATE 25,1:PRINT STRING$(80,32);
1150 LOCATE 17
1160 PRINT " Press number in ( ) for next step:";
1170 PRINT L$
1180 PRINT " (1) Design another coil with same uH"
1190 PRINT " (2) Design an optimum coil with same uH"
1200 PRINT " (3) Use above coil in an L/C circuit"
1210 PRINT " (4) Estimate Q of this coil"
1220 PRINT " (5) EXIT"
1230 Z$=INKEY$:IF Z$=""THEN 1230
1240 IF Z$="1"THEN R=0:L=0:N=0:T=0:E1=5:E2=23:E3=1:GOSUB 280:LOCATE 5:GOTO 760
1250 IF Z$="2"THEN UH=U:CLS:CHAIN"coildsgn"
1260 IF Z$="4"THEN CLS:CHAIN"coilequa"
1270 IF Z$="5"THEN CLS:GOTO 340
1280 E1=17:E2=23:E3=1:GOSUB 280
1290 IF Z$="3"THEN GOSUB 2440:F=0:W=0:X=0:C=0:GOTO 1360
1300 GOTO 1130
1310 '.....clear left screen
1320 E1=5:E2=23:E3=1:GOSUB 280
1330 R=0:L=0:N=0:T=0:GOTO 690
1340 '
1350 '.....L/C circuit
1360 LOCATE 3,54:PRINT "L/C NETWORK"
1370 PRINT UL$;
1380 LOCATE CSRLIN-3,40:PRINT "º"
1390 LOCATE CSRLIN,40:PRINT "º"
1400 LOCATE CSRLIN,40:PRINT "Ê"
1410 '
1420 '.....inputs
1430 GOSUB 1550:IF F+W THEN 1470
1440 INPUT "ENTER: Frequency (MHz) .........";F:IF F THEN W=300/F
1450 GOSUB 1550:IF W+F THEN 1470
1460 INPUT "ENTER: Wavelength (metres) .....";W:IF W THEN F=300/W
1470 GOSUB 1550:IF C THEN 1490
1480 INPUT "ENTER: Capacitance (pF).........";C
1490 GOSUB 1550:IF X THEN 1510
1500 INPUT "ENTER: Reactance (ohms) ........";X
1510 GOSUB 1550:IF U THEN 1530
1520 INPUT "ENTER: Inductance (æH)..........";U
1530 GOSUB 1550:GOTO 1430
1540 '
1550 JJ=1/(4*PI^2)*10^6    'JJ=25330.29
1560 IF U=0 AND C*F<>0 THEN U=JJ/F^2/C:GOTO 1550
1570 IF U=0 AND X*F<>0 THEN U=X/(2*PI*F):GOTO 1550
1580 IF C=0 AND F*U<>0 THEN C=JJ/F^2/U:GOTO 1550
1590 IF F=0 AND C*U<>0 THEN F=SQR(JJ/C/U):W=2.999249E+02/F:GOTO 1550
1600 IF F=0 AND X*U<>0 THEN F=X/(2*PI*U):W=2.997925E+02/F:GOTO 1550
1610 IF F=0 AND X*C<>0 THEN F=10^6/(2*PI*X*C):W=2.997925E+02/F:GOTO 1550
1620 IF X=0 AND F*C<>0 THEN X=10^6/(2*PI*F*C):GOTO 1550
1630 IF F*X*U*C THEN 1660 ELSE 1640
1640 E1=5:E2=5:E3=41:GOSUB 280:LOCATE 5,41:RETURN
1650 '
1660 LOCATE 5,41:PRINT X$
1670 LOCATE 5,42:PRINT "Frequency................";USING U$;F;:PRINT " MHz"
1680 LOCATE 6,42:PRINT "Wavelength...............";USING U$;W;:PRINT " m."
1690 LOCATE 7,42:PRINT "Reactance................";USING U$;X;:PRINT " ê"
1700 LOCATE 8,42:PRINT "Inductance...............";USING U$;U;:PRINT " æH"
1710 LOCATE 9,42:PRINT "Capacitance..............";USING U$;C;:PRINT " pF"
1720 COLOR 0,7
1730 LOCATE 10,41:PRINT " React.& Freq. with variable capacitor:"
1740 COLOR 7,0
1750 FOR VAR=1 TO 4
1760 PF=C*2.000000E-01*VAR:FQC=SQR(JJ/PF/U):XX=10^6/(2*PI*FQC*PF)
1770 LOCATE 15-VAR,41:PRINT USING U$;XX;:PRINT " ê"
1780 LOCATE 15-VAR,53:PRINT USING U$;FQC;:PRINT " MHz @";
1790 PRINT USING U$;PF;:PRINT " pF"
1800 NEXT VAR
1810 UFREQ=U
1820 IF UFREQ<>UCOIL THEN E1=5:E2=14:E3=1:GOSUB 280  'erase coil data
1830 LOCATE 15,41:PRINT L$;
1840 GOSUB 2470
1850 '
1860 LOCATE 25,1:PRINT STRING$(80,32);
1870 COLOR 0,7
1880 LOCATE 16
1890 LOCATE ,41:PRINT " Press number in ( ) for next step:"
1900 COLOR 7,0
1910 LOCATE ,41:PRINT " (1) Re-do with same Frequency"
1920 LOCATE ,41:PRINT " (2) Re-do with same Reactance"
1930 LOCATE ,41:PRINT " (3) Re-do with same Capacitance"
1940 LOCATE ,41:PRINT " (4) Re-do with same Inductance"
1950 LOCATE ,41:PRINT " (5) Design a";INT(C);;"pF Tuning Capacitor"
1960 UH=INT(U*1000+5.000000E-01)/1000
1970 LOCATE ,41:PRINT " (6) Design a";UH;;"æH coil"
1980 LOCATE ,41:PRINT " (7) Find a stock";UH;;"æH coil"
1990 LOCATE ,41:PRINT " (8) EXIT";
2000 Z$=INKEY$:IF VAL(Z$)>=1 AND VAL(Z$)<=8 THEN 2010 ELSE 2000
2010 E1=16:E2=24:E3=41:GOSUB 280
2020 IF Z$="1"THEN X=0:C=0:U=0:GOSUB 2440:GOTO 1420
2030 IF Z$="2"THEN F=0:W=0::C=0:U=0:GOSUB 2440:GOTO 1420
2040 IF Z$="3"THEN F=0:W=0:X=0:U=0:GOSUB 2440:GOTO 1420
2050 IF Z$="4"THEN F=O:W=0:X=0:C=0:GOSUB 2440:GOTO 1420
2060 IF Z$="5"THEN CLS:CHAIN"capytel"
2070 IF Z$="6"THEN E1=9:E2=23:E3=1:GOSUB 280:GOTO 1310
2080 IF Z$="7"THEN U=UH:CLS:CHAIN"aircore"
2090 IF Z$="8"AND F*U THEN GOSUB 2130:GOSUB 2470
2100 IF Z$="8"THEN CLS:GOTO 340
2110 END
2120 '
2130 LOCATE 19,2:COLOR 0,7
2140 PRINT " Want to estimate Q & bandwidth of this circuit?  (y/n) "
2150 COLOR 7,0
2160 Z$=INKEY$
2170 IF Z$="y"OR Z$="Y"THEN CLS:CHAIN"bandq"
2180 IF Z$="n"OR Z$="N"THEN 2200
2190 GOTO 2160
2200 IF N*T=0 THEN 340
2210 LOCATE 19,2:COLOR 0,7
2220 PRINT " Want to estimate Q of this coil  (y/n)                 ";:COLOR 7,0
2230 Z$=INKEY$
2240 IF Z$="y"OR Z$="Y"THEN CLS:CHAIN"coilequa"
2250 IF Z$="n"OR Z$="N"THEN 2270
2260 GOTO 2230
2270 VIEW PRINT 18 TO 24:CLS:VIEW PRINT
2280 RETURN
2290 '
2300 '.....diagram
2310 COLOR 0,7
2320 J=21
2330 LOCATE ,J:PRINT "       SERIES       Û      PARALLEL      "
2340 LOCATE ,J:PRINT "                    Û         L          "
2350 LOCATE ,J:PRINT "      L     C       Û     ÚÄÄïïïïÄÄ¿     "
2360 LOCATE ,J:PRINT " ÄÄÄÄïïïïÄÄÄ´ÃÄÄÄÄ  Û  ÄÄÄ´        ÃÄÄÄ  "
2370 LOCATE ,J:PRINT "                    Û     ÀÄÄÄ´ÃÄÄÄÙ     "
2380 LOCATE ,J:PRINT "                    Û         C          "
2390 LOCATE ,J:PRINT " Zo= 0 at resonance Û Zo= ì at resonance "
2400 COLOR 7,0
2410 PRINT UL$;
2420 RETURN
2430 '
2440 E1=5:E2=16:E3=41:GOSUB 280
2450 RETURN
2460 '
2470 'PRT
2480 KEY OFF:GOSUB 2550:LOCATE 25,5:COLOR 0,2
2490 PRINT " Send this page to:(1)Printer Queue? (2)Printout? ";
2500 PRINT "(3)Next page? (1/2/3)";:COLOR 7,0
2510 Z$=INKEY$:IF Z$<"1"OR Z$>"3"THEN 2510 ELSE GOSUB 2550
2520 IF Z$="3"THEN RETURN
2530 FOR I%=1 TO 24:FOR J%=1 TO 80:LPRINT CHR$(SCREEN(I%,J%));:NEXT J%:NEXT I%
2540 IF Z$="2"THEN LPRINT CHR$(12) ELSE 2480
2550 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
