home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1
/
HamRadio.cdr
/
tech
/
design1
/
nrbnpas.bas
< prev
next >
Wrap
BASIC Source File
|
1987-02-07
|
11KB
|
312 lines
10 REM * NARROW BAND PASS FILTER DESIGN
20 REM * W.E.SABIN, 1982
30 REM *********************************
40 REM * USE K,Q VALUES (3 DB DOWN) *
50 REM * FOR THE LOWPASS PROTOTYPE. *
60 REM * RELATIVE BANDWIDTH=BW(3 DB) *
70 REM * /FO. ADJUST BW(3DB) TO GET *
80 REM * DESIRED PASSBAND. *
90 REM * BW(BP)=BW(LP) *
100 REM* COUPLING IS SERIES/SHUNT *
110 REM* C OR L. USE CAP *
120 REM* DIVIDER, IND. DIVIDER, OR *
130 REM* TOP L OR C FOR Z MATCH *
140 REM* AT INPUT AND OUTPUT. *
150 REM* SELECT FILTER INTERNAL Z *
160 REM* AND COIL UNLOADED Q. *
170 REM* MAX N=10. RESONATOR 1 IS *
180 REM* ALWAYS LOADED WITH R. *
190 REM*********************************
200 PI=4*ATN(1)
210 CLS
220 PRINT"DESIGN DISHAL NARROWBANDPASS FILTER"
230 PRINT:PRINT "2 TO 10 RESONATORS."
240 PRINT:INPUT "NUMBER OF RESONATORS=";N
250 INPUT"CENTER FREQUENCY=";FO
260 OM=2*PI*FO
270 INPUT"3 DB BANDWIDTH=";BW
280 PRINT"ENTER 'INF' FOR INFINITE VALUE"
290 INPUT "UNLOADED COIL Q=";QU$
300 IF QU$="INF" THEN QU=100000!:GOTO 320
310 QU=VAL(QU$)
320 W=BW/FO:QP=QU*W
330 PRINT"NORMALIZED QP OF LOW PASS PROTOTYPE =";QP
340 PRINT "BASED ON QP, DETERMINE THE LOWPASS PROTOTYPE 3 DB DOWN K,Q VALUES FROM SOME REFERENCE SOURCE"
350 PRINT:PRINT"IS QP LARGE ENOUGH (Y/N) ?"
360 A$=INKEY$:IF A$="" THEN 360
370 PRINT:PRINT "ENTER 'INF' FOR INFINITE Q"
380 PRINT"INPUT TERMINAL IS RESISTANCE LOADED"
390 INPUT"Q(1)=";Q(1)
400 PRINT"Q(";N;")=";:INPUT Q$
410 IF Q$="INF" THEN Q(N)=100000!:R2=1E+08: GOTO 430
420 Q(N)=VAL(Q$)
430 PRINT
440 FOR I=1 TO N-1
450 PRINT"K(";I;",";I+1;")=";
460 INPUT K(I)
470 NEXT:PRINT
480 PRINT"LOADED, DENORMALIZED Q:"
490 Q(1)=Q(1)/W:PRINT "Q(1)=";Q(1),
500 IF Q(N)=100000! THEN PRINT "Q(";N;")= INF":GOTO 520
510 Q(N)=Q(N)/W:PRINT "Q(";N;")=";Q(N)
520 IF QU < 1.25*Q(1) THEN PRINT:PRINT "COIL Q MUST BE AT LEAST ";1.25*Q(1);". INCREASE COIL Q OR START OVER.": GOTO 290
530 PRINT: PRINT "INPUT RESONATOR SPECIFICATION MENU:"
540 INPUT "SPECIFY 'L', 'C', 'R' :";A$
550 IF A$="R" THEN INPUT "R=";RF:C=Q(1)/(OM*RF):L=RF/(OM*Q(1))
560 IF A$="L" THEN INPUT "L=";L: C=1/(OM ^2*L):RF=OM*L*Q(1)
570 IF A$="C" THEN INPUT "C=";C:L=1/(OM^2*C): RF=OM*L*Q(1)
580 PRINT: PRINT "L=";L:PRINT "C=";C: PRINT "R=";RF
590 PRINT
600 PRINT "ARE L, C, R SATISFACTORY (Y/N) ?"
610 A$=INKEY$:IF A$="" THEN 610
620 IF A$="N" THEN GOTO 530
630 PRINT "ARE THE UNLOADED COIL Q AND THE 3 DB BANDWIDTH STILL SATISFACTORY ? (Y/N)"
640 A$=INKEY$:IF A$="" THEN 640
650 IF A$="N" THEN GOTO 250
660 RL=OM*L*QU: PRINT "COIL RESISTANCE=";RL: PRINT
670 RR(1)=1/(1/(OM*L*Q(1))-1/(OM*L*QU)): PRINT "REQUIRED SOURCE RESISTANCE =";RR(1)
680 IF Q(N)>= QP/W THEN PRINT "REQUIRED LOAD RESISTANCE = INF": RR(N)=1E+08: GOTO 700
690 RR(N)=1/(1/(OM*L*Q(N))-1/(OM*L*QU)):PRINT "REQUIRED LOAD RESISTANCE=";RR(N)
700 PRINT:FOR I=1 TO N
710 IF I=N THEN GOTO 750
720 K(I)=K(I)*W
730 CT(I)=K(I)*C
740 PRINT "CT(";I;")=";CT(I)
750 IF I=1 THEN C(1)=C-CT(1):PRINT "C(1)=";C(1): GOTO 780
760 IF I=N THEN C(N)=C-CT(N-1): PRINT "C(";N;")=";C(N):GOTO 780
770 C(I)=C-CT(I-1)-CT(I):PRINT "C(";I;")=";C(I)
780 L(I)=L
790 NEXT I:PRINT
800 INPUT "WIRING + AVERAGE TRIMMER C FOR EACH RESONATOR=";CS
810 PRINT: FOR I=1 TO N
820 C(I)=C(I)-CS:PRINT "C(";I;")=";C(I)
830 NEXT:PRINT
840 PRINT:PRINT "TYPE 'SPACE' TO GO ON":PRINT
850 A$=INKEY$:IF A$="" THEN 850
860 PRINT "COUPLING MODIFICATIONS MENU":PRINT
870 PRINT "TYPE 1 FOR CAPACITOR PI TO TEE"
880 PRINT "TYPE 2 FOR L COUPLED C"
890 PRINT "TYPE 3 FOR INDUCTOR TEE"
900 PRINT "TYPE 4 FOR C COUPLED L"
910 PRINT "TYPE 5 FOR M COUPLING"
920 PRINT "TYPE 6 TO CONTINUE"
930 INPUT X: PRINT
940 ON X GOTO 1160, 1240, 1330, 1430, 1520, 950
950 REM ***** DESIGN I/O TRANSFORMERS *****
960 CLS:PRINT
970 PRINT "DESIGN I/O IMPEDANCE TRANSFORMERS"
980 PRINT:PRINT "SELECT TYPE OF TRANSFORMER AT INPUT:":PRINT
990 U=1
1000 PRINT
1010 PRINT "TYPE 1 FOR C DIVIDER"
1020 PRINT "TYPE 2 FOR L DIVIDER"
1030 PRINT "TYPE 3 FOR LINK COUPLING"
1040 PRINT "TYPE 4 FOR TOP C"
1050 PRINT "TYPE 5 FOR TOP L"
1060 PRINT "TYPE 6 TO CONTINUE"
1070 INPUT T:PRINT
1080 IF T =6 THEN GOTO 1120
1090 IF U=1 THEN INPUT "SOURCE RESISTANCE=";R
1100 IF U=N THEN INPUT "LOAD RESISTANCE=";R
1110 ON T GOSUB 1580,1700,1830,2020,2100,1120
1120 IF U=N THEN GOTO 2410
1130 IF Q(N)>=QP/W THEN PRINT "OUTPUT PORT IS OPEN CIRCUIT":GOTO 2410
1140 PRINT:PRINT "SELECT TYPE OF TRANSFORMER AT OUTPUT:": PRINT:U=N
1150 GOTO 1000
1160 REM ***** CHANGE CAP PI TO CAP TEE *****
1170 PRINT: INPUT "FIRST NODE=";A
1180 PRINT "SECOND NODE=";A+1
1190 CD=C(A)*C(A+1)+C(A+1)*CT(A)+C(A)*CT(A)
1200 CA=CD/C(A+1):PRINT "C(";A;")=";CA
1210 CB=CD/C(A):PRINT "C(";A+1;")=";CB
1220 CC=CD/CT(A):PRINT "BOTTOM COUPLING C=";CC
1230 PRINT:GOTO 860
1240 REM ***** CHANGE TOP C TO L COUPLED C *****
1250 PRINT:INPUT "FIRST NODE=";A
1260 PRINT "SECOND NODE=";A+1
1270 C(A)=C(A)+CT(A):PRINT "C(";A;")=";C(A)
1280 C(A+1)=C(A+1)+CT(A):PRINT "C(";A+1;")=";C(A+1)
1290 M=CT(A)*SQR(L(A)*L(A+1))/SQR(C(A)*C(A+1)):PRINT "M=";M
1300 L(A)=L(A)-M:PRINT "L(";A;")=";L(A)
1310 L(A+1)=L(A+1)-M:PRINT "L(";A+1;")=";L(A+1)
1320 PRINT:GOTO 860
1330 REM ***** CHANGE TOP C TO INDUCTOR TEE *****
1340 INPUT "FIRST NODE=";A
1350 PRINT "SECOND NODE=";A+1
1360 C(A)=C(A)+CT(A):PRINT "C(";A;")=";C(A)
1370 C(A+1)=C(A+1)+CT(A):PRINT "C(";A+1;")=";C(A+1)
1380 M=K(A)*SQR(L(A)*L(A+1)):PRINT "MUTUAL INDUCTANCE=";M
1390 IF X=5 THEN RETURN
1400 L(A)=L(A)-M:PRINT "L(";A;")=";L(A)
1410 L(A+1)=L(A+1)-M: PRINT "L(";A+1;")=";L(A+1)
1420 PRINT: GOTO 860
1430 REM ***** CHANGE TOP C TO C COUPLED L *****
1440 INPUT "FIRST NODE=";A
1450 PRINT "SECOND NODE=";A+1
1460 C(A)=C(A)+CT(A):PRINT "C(";A;")=";C(A)
1470 C(A+1)=C(A+1)+CT(A): PRINT "C(";A+1;")=";C(A+1)
1480 M=K(A)*SQR(L(A)*L(A+1)):CM=1/(OM^2*M):PRINT "CM=";CM
1490 L(A)=L(A)+M:PRINT "L(";A;")=";L(A)
1500 L(A+1)=L(A+1)+M:PRINT "L(";A+1;")=";L(A+1)
1510 PRINT: GOTO 860
1520 REM ***** CHANGE TOP C TO M *****
1530 GOSUB 1340
1540 PRINT "COEFF OF COUPLING=";K(A)
1550 PRINT "L(";A;")=";L(A)
1560 PRINT "L(";A+1;")=";L(A+1)
1570 PRINT: GOTO 860
1580 REM ***** CAPACITIVE DIVIDER *****
1590 CX=C(U)*SQR(RR(U)/R)/SQR(RR(U)/R-1)
1600 K=C(U)*RR(U)
1610 CC=CX^2/4-(1-OM^2*R*CX*K)/(OM*R)^2
1620 IF CC<=0 THEN PRINT "CANNOT MATCH":GOTO 1000
1630 CY=-CX/2+SQR(CC)
1640 RI=(1+OM^2*R^2*(CY+CX)^2)/(OM^2*R*CX^2)
1650 IF ABS((RR(U)-RI)/RR(U))<.0001 THEN GOTO 1670
1660 CX=CX*RI/RR(U):GOTO 1610
1670 PRINT:PRINT "C(";U;")=";CX
1680 PRINT "BOTTOM CAP=";CY
1690 PRINT:RETURN
1700 REM ***** INDUCTIVE DIVIDER *****
1710 LY=L(U)*SQR(R/RR(U))
1720 K=RR(U)/L(U)
1730 LX=R*LY*(LY*K-R)/((OM*LY)^2+R^2)
1740 IF LX=LL THEN PRINT "NO MATCH":GOTO 1000
1750 RI=((OM*LX*LY)^2+R^2*(LX+LY)^2)/(R*LY^2)
1760 IF ABS ((RR(U)-RI)/RR(U))<.0001 THEN GOTO 1790
1770 LY=LY*SQR(RR(U)/RI)
1780 LL=LX:GOTO 1730
1790 PRINT:PRINT "BOTTOM COIL=";LY
1800 L(U)=LX
1810 PRINT "VALUE OF TOP COIL L(";U;")=";L(U)
1820 PRINT:RETURN
1830 REM ***** LINK COUPLING *****
1840 INPUT "ESTIMATE OF COUPLING COEFFICIENT=";KK
1850 XX=0
1860 LY=L(U)*R/RR(U)/KK^2
1870 LX=L(U)*((OM*LY)^2*(1-KK^2)+R^2)/((OM*LY)^2*(1-KK^2)^2+R^2)
1880 RI=R*LX/KK^2/LY+OM^2*LX*LY/R*(1-KK^2)^2/KK^2
1890 RM=2*OM*LX*(1-KK^2)/KK^2
1900 IF RM>=.8*RR(U) THEN PRINT "THE VALUE OF COUPLING COEFFICIENT, ";KK;" IS TOO SMALL":GOTO 1840
1910 IF ABS ((RR(U)-RI)/RR(U))<=.0001 THEN GOTO 1930
1920 LY=LY*RI/RR(U):GOTO 1870
1930 PRINT:PRINT "LX=";LX
1940 PRINT"LY=";LY
1950 PRINT:IF XX=0 THEN GOSUB 3070
1960 RZ=OM*LY/QL
1970 IF XX=0 THEN R=R+RZ:XX=1:GOTO 1860
1980 PRINT "TYPE 'Y' TO RECALCULATE USING NEW VALUE OF COUPLING COEFFICIENT"
1990 A$=INKEY$:IF A$="" THEN 1990
2000 IF A$="Y" THEN GOTO 1840
2010 RETURN
2020 REM ***** TOP C COUPLING TRANSFORMER *****
2030 CX=1/OM/SQR(R*(RR(U)-R))
2040 CO=CX/(1+(OM*CX*R)^2)
2050 C(U)=C(U)-CO
2060 PRINT:PRINT "TOP COUPLING C=";CX
2070 PRINT "NEW C(";U;")=";C(U)
2080 IF C(U)=<0 THEN PRINT "NO MATCH": C(U)=C(U)+CO:GOTO 1000
2090 RETURN
2100 REM ***** TOP L COUPLING TRANSFORMER *****
2110 Z=0:LX=1/OM*SQR(R*(OM*L*Q(U)-R))
2120 PRINT "APPROX. VALUE OF LX=";LX
2130 INPUT "APPROX. Q OF LX=";QX$
2140 IF QX$="INF" THEN QX=100000!:GOTO 2160
2150 QX=VAL(QX$)
2160 RI=((R+OM*LX/QX)^2+(OM*LX)^2)/(R+OM*LX/QX)
2170 LO=RI*(R+OM*LX/QX)/(OM^2*LX)
2180 L(U)=1/(1/L-1/LO)
2190 IF Z=1 THEN GOTO 2260
2200 PRINT "APPROX. VALUE OF L(";U;")=";L(U)
2210 IF L(U)=<0 THEN PRINT "NO MATCH": GOTO 1000
2220 PRINT "Q OF L(";U;")=";
2230 INPUT QL$
2240 IF QL$="INF" THEN QL=100000!:GOTO 2260
2250 QL=VAL(QL$)
2260 RY=QL*OM*L(U)
2270 IF L*Q(U)>.8*L(U)*QL THEN PRINT "Q CHOSEN TOO SMALL": GOTO 2100
2280 QI=1/(OM*L)/(1/RY+1/RI)
2290 IF ABS((Q(U)-QI)/Q(U))<.0001 THEN GOTO 2320
2300 LX=LX*SQR(Q(U)/QI)
2310 Z=1: GOTO 2160
2320 PRINT:PRINT"LX=";LX
2330 PRINT"L(";U;")=";L(U)
2340 PRINT "Q OF L(";U;")=";QL
2350 PRINT "TOTAL Q=";QI
2360 PRINT "LOAD RESISTANCE=";RI
2370 PRINT "DO YOU WANT TO REPEAT (Y/N)?"
2380 A$=INKEY$:IF A$="" THEN 2380
2390 IF A$="Y" THEN PRINT:GOTO 2110
2400 RETURN
2410 REM ***** INSERTION LOSS *****
2420 PRINT "TYPE 'SPACE' TO GO ON "
2430 A$=INKEY$:IF A$="" THEN 2430
2440 CLS:PRINT "FIND INSERTION LOSS"
2450 PRINT "FOR PSEUDO-EXACT, INPUT '1'"
2460 INPUT "FOR OTHERS, INPUT '0'";P
2470 PRINT "PROTOTYPE Q=";QP
2480 Q(1)=Q(1)*W:Q(N)=Q(N)*W
2490 X(1)=Q(1)
2500 RS=1/(1-X(1)/QP)
2510 IF 2*INT(N/2)=N THEN RS=1/RS
2520 IF P=1 THEN RS=1
2530 PRINT "PROTOTYPE RS=";RS
2540 FOR I=1 TO N-1
2550 K(I)=K(I)/W
2560 X(I+1)=1/(K(I)^2*X(I))
2570 NEXT
2580 S=0
2590 FOR I=1 TO N
2600 S=S+X(I)
2610 NEXT
2620 LR=4.343001*S/QP
2630 PRINT "RESISTIVE LOSS (DB)=";LR
2640 IF Q(N)=>QP THEN PRINT "MISMATCH LOSS NOT DEFINED":GOTO 2720
2650 R2=1/(X(N)/Q(N)-X(N)/QP)
2660 IF P=1 THEN R2=Q(N)/X(N)
2670 LM=4.343001*LOG((RS+R2)^2/(4*R2*RS))
2680 PRINT "PROTOTYPE RL=";R2;" OHMS"
2690 PRINT "MISMATCH LOSS (DB)=";LM
2700 LT=LR+LM
2710 PRINT "INSERTION LOSS (DB)=";LT
2720 REM ***** PROTOTYPE VALUES *****
2730 PRINT: PRINT "LOWPASS PROTOTYPE VALUES"
2740 A=-1*(-1)^N
2750 FOR I=1 TO N
2760 PRINT "X(";I;")=";X(I),
2770 IF A=1 THEN PRINT "R(";I;")=";QP/X(I)
2780 IF A=-1 THEN PRINT "R(";I;")=";X(I)/QP
2790 A=-A
2800 NEXT
2810 REM ***** STOPBAND RESPONSE *****
2820 A$=INKEY$:IF A$="" THEN 2820
2825 PRINT:PRINT "APPROXIMATE STOPBAND RESPONSE"
2830 INPUT "ENTER 1 FOR CHEBY, MIN-LOSS, 0 FOR OTHERS ";A
2840 X=1: FOR I=1 TO N: X=X*X(I):NEXT
2850 FOR I=20 TO 60 STEP 10
2860 U=I/(8.686001*N)-LOG(2*PI)-1/N*LOG(X)+1/N*LOG((RS+R2)/R2)
2870 F=EXP(U)
2880 BY=BW*2*PI*F*(1+.8499999*N/I*A)
2890 PRINT .1*INT(10*(I-LR)+.5);" DB BW=";INT(BY);" HZ"
2900 NEXT
2910 REM ***** UNLOADED OUTPUT RESISTANCE AT FO *****
2920 IF Q(N)<QP THEN GOTO 3060
2930 G(1)=1
2940 FOR I=2 TO N
2950 G(I)=(Q(1)*K(I-1))^2/G(I-1)+RF/RL
2960 NEXT
2970 RO=INT(RF/G(N))
2980 PRINT:PRINT "UNLOADED OUTPUT RESISTANCE AT F0=";RO
2990 INPUT "DESIRED OUTPUT RESISTANCE=";RP
3000 IF RO=RP THEN GOTO 3060
3010 PRINT "C DIVIDER, C1 BOTTOM, C2 TOP"
3020 C1=C(N)*SQR(RO/RP)
3030 PRINT "C1=";C1
3040 C2=C(N)*SQR(RO/RP)/(SQR(RO/RP)-1)
3050 PRINT "C2=";C2
3060 PRINT:PRINT "COMPLETE":END
3070 REM ***** LINK COIL SUBROUTINE *****
3080 INPUT "Q OF LINK COIL=";QL$
3090 IF QL$="INF" THEN QL=100000!:RETURN
3100 QL=VAL(QL$):RETURN