Output of file : FILPLT.BAS contained in archive : FILTDES.ZIP
10 REM FILPLT.BAS FILTER GAIN AND PHASE RESPONSE
20 REM
30 DIM AP(3,200):DIM B(40):DIM FO(40):DIM JMPV(40):DIM Q(40):DIM FIL\$(8)
40 DIM FZ(40):DIM DF(40):DIM QZ(40):DIM DQ(40)
50 HZ\$=" Hz":KHZ=0
60 FIL\$(1)="HIGHPASS":FIL\$(2)="LOWPASS":FIL\$(3)="HIGHPASS":FIL\$(4)="LOWPASS"
65 FIL\$(5)="BANDPASS":FIL\$(6)="ALLPASS":FIL\$(7)="NOTCH"
70 INPUT "Is filter design on file (ENTER Y OR N)";FDES\$
80 IF FDES\$="Y" OR FDES\$="y" THEN 120
90 IF FDES\$="N" OR FDES\$="n"THEN 100 ELSE GOTO 70
100 N1=0:NU2=0:NZ=0:GOSUB 2040
110 GOTO 130
120 N1=0:NU2=0:NZ=0:GOSUB 1410
130 PRINT"Enter the starting frequency of the response in "HZ\$; :INPUT FS
140 PRINT"Enter the ending frequency of the response in "HZ\$;:INPUT FE
150 PRINT"Would you like linear or logarithmic steps (Enter lin or log)";:INPUT A\$
160 IF A\$="LIN" OR A\$="LOG" OR A\$="lin" OR A\$="log" THEN GOTO 180
170 GOTO 150
180 PRINT"How many steps would you like in the response";:INPUT ST
190 IF ST<=0 THEN GOTO 180
200 ST=ST+1
210 PRINT"Would you like the gain response normalized to 1 at a ";
215 PRINT"particular frequency?"
220 PRINT "If YES then enter the frequency, in " HZ\$ ", if not enter N";:INPUT NORM\$
230 NORM=VAL(NORM\$)
240 IF NORM\$="N" OR NORM\$="n" THEN NORM=-1:GOTO 270
250 IF ASC(NORM\$)=48 OR NORM>0 THEN 270
260 GOTO 210
270 GOSUB 2530
280 GOSUB 810
290 GOSUB 1350
300 REM
310 FOR N=1 TO N1+NU2
320 W=6.28318*FS:WO=6.28318*FO(N):Q=Q(N)
330 IF N>N1 THEN WZ=6.28318*FZ(N-N1)
340 ON JMPV(N) GOSUB 910,930,950,970,990,1010,1030
350 NEXT N
360 NORML=NORML+1
370 IF NORM>=0 AND NORML=1 THEN FSN=FS:FS=NORM:GOTO 310
380 IF NORML=2 AND NORM>=0 THEN FS=FSN
390 NORML=0
400 I=0:I2=0:ST2=0
410 IF ST=ST2 THEN 530
420 I2=1+I2
430 IF ST>I2*20 THEN ST2=I2*20:I=(ST2-19):GOTO 450
440 ST2=ST:I=((I2-1)*20)+1
450 FOR N=I TO ST2
460 PRINT"FREQ="AP(3,N) HZ\$ TAB( 25)"GAIN="AP(1,N)"DB"TAB( 50)"PHASE="AP(2,N)"DEG"
470 NEXT N
480 IF ST=ST2 AND ST2-I<17 THEN 530
490 IF NORM>=0 THEN PRINT "FILTER RESPONSE NORMALIZED AT "NORM HZ\$ " "AMPN"dB."
500 PRINT"PRESS RETURN TO CONTINUE WITH OUTPUT OR E TO END OUTPUT";:INPUT V\$
510 IF V\$="E" OR V\$="e" THEN 530
520 GOTO 410
530 REM
540 IF NORM>=0 THEN PRINT "FILTER RESPONSE NORMALIZED AT "NORM HZ\$ " "AMPN"dB."
550 PRINT"FILTER RESPONSE COMPLETE ....."
560 PRINT" PRESS P - PRINT RESPONSE ON LINE PRINTER"
570 PRINT" V - VIEW RESPONSE AGAIN"
580 PRINT" D - DESIGN ANOTHER FILTER"
590 PRINT" E - END(EXIT TO OPERATING SYSTEM)"
600 PRINT" R - RERUN FILTER RESPONSE"
610 INPUT V\$
620 IF V\$="E" OR V\$="e" THEN SYSTEM
630 IF V\$="D" OR V\$="d" THEN RUN "FILDES.BAS"
640 IF V\$="P" OR V\$="p" THEN I=0:I2=0:ST2=0:GOTO 680
650 IF V\$="V" OR V\$="v" THEN ST2=0:I=0:I2=0:GOTO 410
660 IF V\$="r" OR V\$="R" THEN ST=ST-1:GOTO 1720
670 GOTO 530
680 REM PRINT ROUTINE
690 LPRINT
700 LPRINT:LPRINT:LPRINT
710 IF ST=ST2 THEN 530
720 I2=I2+1
730 IF ST>I2*60 THEN ST2=I2*60:I=(ST2-59):GOTO 760
740 ST2=ST:I=(I2*60)-59
750 IF NORM>=0 THEN LPRINT "FILPTER RESPONSE NORMALIZED AT "NORM HZ\$ " "AMPN"dB"
760 FOR N=I TO ST2
770 LPRINT "FREQ="AP(3,N) HZ\$ TAB( 25)"GAIN="AP(1,N)"DB"TAB( 50)"PHASE="AP(2,N)"DEG"
780 NEXT N
790 IF N=I2*60 THEN LPRINT CHR\$(12)
800 GOTO 700
810 REM lin/log
820 IF A\$="log" OR A\$="LOG" THEN GOTO 870
830 IF A\$="lin" OR A\$="LIN" THEN GOTO 850
840 GOTO 150
850 SS=6.28318*(FE-FS)/(ST-1):B=1
860 GOTO 900
870 B=0
880 IF FS=0 THEN FS=.1
890 SS=(FE/FS)^(1/(ST-1))
900 RETURN
910 A1=0:A2=1:A3=0:B1=0:B2=1:B3=WO
920 GOTO 1040
930 A1=0:A2=0:A3=WO:B1=0:B2=1:B3=WO
940 GOTO 1040
950 A1=1:A2=0:A3=0:B1=1:B2=WO/Q:B3=WO^2
960 GOTO 1040
970 A1=0:A2=0:A3=WO^2:B1=1:B2=WO/Q:B3=A3
980 GOTO 1040
990 A1=0:A2=WO/Q:A3=0:B1=1:B2=A2:B3=WO^2
1000 GOTO 1040
1010 A1=1:A2=-WZ/QZ:A3=WZ^2:B1=1:B2=WO/Q:B3=WO^2
1020 GOTO 1040
1030 A1=1:A2=0:A3=WZ^2:B1=1:B2=WO/Q:B3=WO^2
1040 IF NORML=1 THEN 1060
1050 FOR NO=1 TO ST
1060 W2=W^2:A4=A3-A1*W2:B4=B3-B1*W2
1070 R=A4*B4+A2*B2*W2
1080 IF R=0 THEN R=1E-09
1090 I=(A2*B4-B2*A4)*W
1100 IF I=0 THEN I=1E-09
1110 D=B4^2+(B2^2)*W2
1120 AMP=((R^2+I^2)^.5)/D
1130 IF REGY=3 THEN 1150
1140 IF REGY=1 AND JMPV(N)=7 THEN AMP=B3/A3*AMP
1150 AMPD=20*.43429*LOG(AMP)
1160 IF NORML=1 THEN 2010
1170 IF R=0 AND I>0 THEN PH=1.5708:GOTO 1210
1180 IF R=0 AND I<0 THEN PH=-1.5708:GOTO 1210
1210 PHA=PH
1220 IF R<0 AND I>0 THEN PHA=3.1415+PH
1230 IF R<0 AND I<0 THEN PHA=-3.1415-PH
1240 IF PHA>3.14159 THEN PHA=PHA-3.14159
1250 IF PHA<-3.14159 THEN PHA=PHA+3.14159
1260 PHA=PHA*180/3.14159
1270 AP(1,NO)=AP(1,NO)+AMPD:REM PRINT AP(1,NO)
1280 AP(2,NO)=AP(2,NO)+PHA:REM PRINT AP(2,NO)
1290 AP(3,NO)=W/6.28318:REM PRINT AP(3,NO)
1300 IF B=0 THEN W=W*SS:GOTO 1330
1310 IF B=1 THEN W=W+SS:GOTO 1330
1320 PRINT"ERROR IN B"
1330 NEXT NO
1340 RETURN
1350 FOR X=1 TO ST
1360 FOR Y=1 TO 3
1370 AP(Y,X)=0
1380 NEXT Y
1390 NEXT X
1400 RETURN
1410 OPEN "I",1,"PLTDATA"
1420 INPUT #1,REGY,T,NUMB
1430 FOR I=1 TO NUMB
1440 INPUT #1,DF(I),DQ(I)
1450 NEXT I
1460 CLOSE 1
1470 N1=0:NU2=0:NZ=0
1480 FOR I=1 TO NUMB
1490 IF DQ(I)=0 THEN N1=N1+1:FO(N1)=DF(I):GOTO 1520
1500 IF DQ(I)<0 THEN NZ=NZ+1:FZ(NZ)=DF(I):GOTO 1520
1510 NU2=NU2+1
1520 NEXT I
1530 FOR I=1 TO NUMB
1540 IF DQ(I)<=0 THEN 1570
1550 Q(I+N1)=DQ(I):FO(N1+I)=DF(I)
1560 NEXT I
1570 FOR I=1 TO N1+NU2
1580 IF N1=0 OR N1 1590 IF REGY=1 THEN JMPV(I)=2:GOTO 1640
1600 IF REGY=2 THEN JMPV(I)=1:GOTO 1640
1610 PRINT"ERROR IN PLTDATA":END
1620 IF NU2=0 THEN 1640
1630 GOSUB 1660
1640 NEXT I
1650 RETURN
1660 IF REGY=1 THEN JMPV(I)=4
1670 IF REGY=2 THEN JMPV(I)=3
1680 IF REGY=3 THEN JMPV(I)=5
1690 IF REGY=4 THEN JMPV(I)=7
1700 IF T=3 AND I<=NZ THEN JMPV(I)=7
1710 RETURN
1720 X=0:NORM2=NORM
1730 PRINT "ENTER ","CURRENT VALUE"
1740 PRINT " FS - STARTING FREQUENCY OF RESPONSE",FS, HZ\$
1750 PRINT " FE - ENDING FREQUENCY OF RESPONSE",FE, HZ\$
1760 PRINT " ST - LINear OR LOGarithmic RESPONSE",A\$
1770 PRINT " NU - NUMBER OF STEPS IN RESPONSE",ST
1780 PRINT " FN - FREQUENCY OF NORMALIZATION",;
1790 IF NORM2>=0 THEN PRINT NORM2 HZ\$ ELSE PRINT
1800 PRINT " A - CHANGE ALL PARAMETERS"
1810 PRINT " E - END OF CHANGES"
1820 INPUT V\$
1830 IF V\$="A" OR V\$="a" THEN 60
1840 IF V\$="FN" OR V\$="fn" THEN 1850 ELSE GOTO 1870
1850 PRINT "ENTER VALUE IN "HZ\$;:INPUT NORM2:X=X^X
1860 IF NORM2<0 GOTO 1850
1870 IF V\$="FE" OR V\$="fe" THEN 1875 ELSE GOTO 1880
1875 PRINT"ENTER VALUE OF ENDING FREQUENCY IN "HZ\$;:INPUT FE:X=2
1880 IF V\$="FS" OR V\$="fs" THEN 1885 ELSE GOTO 1890
1885 PRINT"ENTER VALUE OF STARTING FREQUENCY IN "HZ\$;:INPUT FS:X=2
1890 IF V\$="NU" OR V\$="nu" THEN INPUT "ENTER NUMBER OF STEPS IN RESPONSE";ST:X=2
1900 IF V\$="ST" OR V\$="st" THEN INPUT "ENTER LIN OR LOG";A\$:X=2
1910 IF V\$="E" OR V\$="e" THEN ST=ST+1:GOTO 1930
1920 GOTO 1730
1930 IF X>=2 THEN 1980
1940 IF X=1 AND NORM2> 1950 GOSUB 2010
1960 NORML=0:AMPD=0:AMPN=0:NORM=NORM2:X=0:GOTO 360
1970 REM
1980 REM
1990 NORML=0:AMPD=0:AMPN=0:X=0:NORM=NORM2
2000 GOTO 270
2010 FOR N0=1 TO ST:AP(1,N0)=AP(1,N0)-AMPD:NEXT N0
2020 AMPN=AMPN+AMPD
2030 RETURN
2040 PRINT "ENTER:"
2050 PRINT " 1 - SINGLE ORDER LOWPASS"
2060 PRINT " 2 - SINGLE ORDER HIGHPASS"
2070 PRINT " 3 - 2ND ORDER LOWPASS"
2080 PRINT " 4 - 2ND ORDER HIGHPASS"
2090 PRINT " 5 - 2ND ORDER BANDPASS"
2100 PRINT " 6 - 2ND ORDER ALLPASS"
2110 PRINT " 7 - 2ND ORDER NOTCH OR ELLIPTIC LOWPASS,HIGHPASS,BANDPASS"
2120 PRINT " 8 - END OF DATA ENTRY"
2130 INPUT REGY
2140 IF REGY=8 THEN 2300
2150 IF REGY=1 THEN N1=N1+1:JMPV(N1+NU2)=2:Q(N1+NU2)=0:GOTO 2230
2160 IF REGY=2 THEN N1=N1+1:JMPV(N1+NU2)=1:Q(N1+NU2)=0:GOTO 2230
2170 IF REGY=3 THEN NU2=NU2+1:JMPV(N1+NU2)=4:REGY=1:T=4:GOTO 2240
2180 IF REGY=4 THEN NU2=NU2+1:JMPV(N1+NU2)=3:REGY=2:T=4:GOTO 2240
2190 IF REGY=5 THEN NU2=NU2+1:JMPV(N1+NU2)=5:REGY=3:T=4:GOTO 2240
2200 IF REGY=6 THEN NU2=NU2+1:NZ=NZ+1:JMPV(N1+NU2)=6:GOTO 2250
2210 IF REGY=7 THEN NU2=NU2+1:NZ=NZ+1:JMPV(N1+NU2)=7:GOTO 2270
2220 GOTO 2040
2230 PRINT"ENTER THE CUTOFF FREQUENCY IN "HZ\$;:INPUT FO(N1+NU2):GOTO 2040
2240 PRINT"ENTER THE CUTOFF FREQUENCY IN "HZ\$", AND Q";:INPUT FO(N1+NU2),Q(N1+NU2)
2245 GOTO 2040
2250 PRINT"ENTER THE REAL POLE PAIR FREQUENCY(FO) IN "HZ\$",Q, ZERO FREQUENCY(FZ) ";
2255 PRINT"IN "HZ\$" AND ZERO Q(QZ):"
2260 INPUT FO(N1+NU2),Q(N1+NU2),FZ(NU2),QZ(NU2):GOTO 2040
2270 PRINT"ENTER THE REAL POLE PAIR FREQUENCY(FO) IN "HZ\$",Q AND ";
2275 PRINT"ZERO FREQUENCY(FZ) IN "HZ\$":"
2280 INPUT FO(N1+NU2),Q(N1+NU2),FZ(NU2)
2290 GOTO 2040
2300 FOR N=1 TO N1+NU2
2310 IF JMPV(N)=7 THEN 2340
2320 NEXT N
2330 GOTO 2400
2340 PRINT"What is the overall response type of this elliptic ";
2345 INPUT"(Enter N-otch, L-owpass, H-ighpass, B-andpass" ;REGY\$
2350 IF REGY\$="N" OR REGY\$="n" THEN REGY=4:GOTO 2400
2360 IF REGY\$="L" OR REGY\$="l" THEN REGY=2:GOTO 2400
2370 IF REGY\$="H" OR REGY\$="h" THEN REGY=2:GOTO 2400
2380 IF REGY\$="B" OR REGY\$="n" THEN REGY=3:GOTO 2400
2390 GOTO 2340
2400 T=3
2410 PRINT"SECTION"TAB( 10)"ORDER"TAB( 20)"TYPE"TAB( 30)"Fo"TAB( 40)"Q"TAB( 50);
2415 PRINT"Fz"TAB( 60)"Qz"
2420 IF N1>0 THEN 2430 ELSE GOTO 2460
2430 FOR I=1 TO N1
2440 PRINT TAB( 4) I TAB( 11) "1" TAB( 15) FIL\$(JMPV(I)) TAB( 29) FO(I) HZ\$
2450 NEXT I
2460 IF NU2>0 THEN 2470 ELSE GOTO 2520
2470 FOR I=N1+1 TO N1+NU2
2480 IF JMPV(I)=7 THEN FIL\$(8)="ELLIPTIC":N=8:GOTO 2500
2490 N=JMPV(I)
2500 PRINT TAB( 4) I TAB( 11) "2" TAB( 18) FIL\$(N) TAB( 29) FO(I) HZ\$ TAB( 39) ;
2505 PRINT Q(I) TAB( 49) FZ(I-N1) HZ\$ TAB( 59) QZ(I-N1)
2510 NEXT I
2520 RETURN
2530 IF FS>1000 OR FE>1000 THEN GOTO 2630
2540 FOR N=1 TO NU2+N1
2550 IF FO(N)>1000 OR FZ(N)>1000 GOTO 2630
2560 NEXT N
2570 IF KHZ=0 THEN HZ\$=" Hz":GOTO 2620
2580 IF KHZ=1 THEN HZ\$="KHz":GOTO 2620
2590 IF KHZ=2 THEN HZ\$="MHz":GOTO 2620
2600 IF KHZ=3 THEN HZ\$="GHz":GOTO 2620
2610 IF KHZ>=4 THEN PRINT "INPUT FREQUENCY(S) ARE TO GREAT!!!":GOTO 560
2620 RETURN
2630 KHZ=KHZ+1
2640 FS=FS/1000:FE=FE/1000:NORM=NORM/1000
2650 FOR N=1 TO NU2+N1
2660 FO(N)=FO(N)/1000:FZ(N)=FZ(N)/1000
2670 NEXT N
2680 GOTO 2530


### 3 Responses to “Category : Science and EducationArchive   : FILTDES.ZIPFilename : FILPLT.BAS”

1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/