10 GOSUB 770 20 PI=3.14159 30 UP$=CHR$(27)+"M" 40 N$="No-Name Filter" 50 PRINT " Digital FIR filter response program" 60 PRINT " ----------------------------------- 70 PRINT:PRINT:PRINT 80 INPUT " Clock frequency";F 90 PRINT " (Hz,kHz or MHz?) 100 INPUT " ";A$ 110 A$=LEFT$(A$,1) 120 IF ASC(A$)>90 THEN A$=CHR$(ASC(A$)-32) 130 IF A$="K" THEN F=1000*F 140 IF A$="M" THEN F=1E+06*F 150 IF A$="K" OR A$="H" OR A$="M" THEN GOTO 180 160 PRINT UP$; 170 GOTO 100 180 INPUT " Number of coefficients";N 190 DIM C(N),D(N),R(50) 200 FOR I=1 TO N 210 PRINT "coefficient ";I;TAB(40); 220 INPUT C(I) 230 PRINT "delay ";I;" (clocks)";TAB(40); 240 INPUT D(I) 250 NEXT 260 INPUT "starting frequency for plot (Hz)";F0 270 INPUT "ending frequency for plot (Hz) ";F1 280 PRINT "Do you want to give the filter a name? (y/n)" 290 INPUT Q$ 300 IF Q$="N" OR Q$="n" THEN GOTO 350 310 IF Q$="Y" OR Q$="y" THEN GOTO 340 320 PRINT UP$; 330 GOTO 290 340 INPUT "Name";N$ 350 FOR I=1 TO 50 360 W=2*PI*(((F1-F0)*I/49)+F0) 370 RR=0 380 FOR J=1 TO N 390 RR=RR+C(J)*COS(W*(D(J)-D(1))/F) 400 NEXT 410 R(I)=ABS(RR) 420 NEXT 430 GOSUB 770 440 PRINT " What would you like to do now?" 450 PRINT:PRINT:PRINT 460 PRINT" Plot the response........[1]" 470 PRINT" Change the input data....[2]" 480 PRINT" Exit the program.........[3]" 490 PRINT:PRINT: 500 INPUT Q 510 IF Q=1 OR Q=2 OR Q=3 THEN GOTO 540 520 PRINT UP$; 530 GOTO 500 540 ON Q GOTO 550,800,1080 550 MAX=R(1) 560 FOR I=1 TO 50 570 IF MAX5 OR Q<>INT(Q) THEN GOTO 1060 1050 ON Q GOTO 1090,1130,1220,1310,350 1060 PRINT UP$; 1070 GOTO 1030 1080 SYSTEM 1090 PRINT 1100 PRINT "The current clock frequency is ";F;"Hz" 1110 INPUT "New frequency";F 1120 GOTO 800 1130 PRINT 1140 PRINT "Which tap do you want to move?" 1150 INPUT Q 1160 IF Q<1 OR Q>N OR Q<>INT(Q) THEN GOTO 1200 1170 PRINT "Current position for tap ";Q;" is ";D(Q);" clocks." 1180 INPUT "New position";D(Q) 1190 GOTO 800 1200 PRINT UP$; 1210 GOTO 1150 1220 PRINT 1230 PRINT "which tap do you want to change the weighting coefficient of?" 1240 INPUT Q 1250 IF Q<1 OR Q>N OR Q<>INT(Q) THEN GOTO 1290 1260 PRINT "Current weight for tap ";Q;" is ";C(Q) 1270 INPUT "New weight";C(Q) 1280 GOTO 800 1290 PRINT UP$; 1300 GOTO 1240 1310 PRINT 1320 PRINT "What would you like to rename the filter to?" 1330 INPUT N$ 1340 GOTO 800 INT UP$; 1300 GOTO 1240 1310 PRINT 1320 PRINT "What would you like to rename the filter to?" 1330