⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 firprog.bas

📁 DSP原理及其C编程开发技术的源码 真的很好呀
💻 BAS
📖 第 1 页 / 共 2 页
字号:
2240 REM ================== Bandpass/stop Prompts Routine ======================
2250 REM
2260 TYPE$="BANDPASS":IF TYPE = 4 THEN TYPE$="BANDSTOP"
2270 CLS
2280 LOCATE 1
2290 PRINT "        Specifications:"
2300 PRINT TAB(24);TYPE$
2310 LOCATE 12
2320 INPUT "        Enter the 3-db lower cutoff frequency in Hz --> ",LCUT
2330 LOCATE 12
2340 PRINT "                                                                  "
2350 LOCATE 3:PRINT TAB(24);"Lower Cutoff Frequency =";LCUT;"Hz"
2360 LOCATE 12
2370 INPUT "        Enter the 3-db upper cutoff frequency in Hz --> ",HCUT
2380 IF HCUT <= LCUT THEN GOSUB 4140:GOTO 2360
2390 LOCATE 4:PRINT TAB(24);"Upper Cutoff Frequency =";HCUT;"Hz"
2400 RETURN
2410 REM =======================================================================
2420 REM
2430 REM ========================== Output Routine =============================
2440 REM
2450 REM        This routine allows the user to define the output
2460 REM        path.  These include the terminal, line printer, or
2470 REM        data file, which includes TMS320 data format for simple
2480 REM        merging into a 'blank' filter program.
2490 REM
2500 CLS
2510 LOCATE 8
2520 PRINT "       Send coefficients to:"
2530 PRINT TAB(29);"(S)creen"
2540 PRINT TAB(29);"(P)rinter"
2550 PRINT TAB(29);"(F)ile: contains TMS320 (C25 or C30) data format"
2560 PRINT TAB(29);"(R)eturn to Filter Type Menu"
2570 PRINT TAB(29);"(E)xit to DOS"
2580 PRINT
2590 INPUT "       Enter desired path --> ",PATH$
2600 IF PATH$ = "S" OR PATH$ = "s" THEN GOSUB 2670
2610 IF PATH$ = "P" OR PATH$ = "p" THEN GOSUB 2990
2620 IF PATH$ = "F" OR PATH$ = "f" THEN GOSUB 3400
2630 IF PATH$ = "R" OR PATH$ = "r" THEN GOTO 390
2640 IF PATH$ = "E" OR PATH$ = "e" THEN CLS:SYSTEM
2650 GOTO 2500
2660 REM
2670 REM -------------------- Output Coefficients to Terminal ------------------
2680 REM
2690 CLS
2700 PRINT TAB(13);COEFF;"Coefficient ";TYPE$;" Filter Using the ";WIN$;" Window"
2710 PRINT
2720 PRINT "       Filter Coefficients:"
2730 PRINT
2740 PRINT TAB(20);"C'(n)";TAB(53);"H(n)"
2750 PRINT TAB(20);"-----";TAB(53);"----"
2760 PRINT
2770 PRINT TAB(51);"DECIMAL";TAB(70);"HEX"
2780 PRINT
2790 FOR I=0 TO Q
2800 IF INT(I/11) <> I/11 OR I = 0 THEN 2860
2810 LOCATE 23:PRINT "       Press <Enter> to view";Q-I+1;"remaining coefficients";:INPUT " ",RESPONSE
2820 LOCATE 23
2830 PRINT "                                                                   "
2840 GOSUB 3690    'erase coefficients from screen
2850 REM
2860 GOSUB 3790    'convert coeff. index to char, removing spaces in output
2870 PRINT TAB(8);
2880 PRINT "C'(";C1$;")";
2890 PRINT TAB(15);" = ";
2900 PRINT USING "+#.#####";C(I);:PRINT " = C'(";C2$;")";
2910 PRINT TAB(41);
2920 PRINT "H(";C1$;")";
2930 PRINT TAB(47);" = ";
2940 PRINT USING "+#.#####";H(I);: PRINT " = H(";C2$;")";
2950 PRINT TAB(67);" = ";CHEX$(I)
2960 NEXT I
2970 LOCATE 23:INPUT "       Press <Enter> to return to Output Path Menu ",RET
2980 RETURN
2990 REM --------------------- Output Coefficients to Printer ------------------
3000 REM
3010 REM        This nested routine allows the user to produce hardcopy of the
3020 REM        coefficients.  NOTE: If this option is specified from the
3030 REM        output path menu and the printer is NOT READY, then a
3040 REM        "device timeout" will occur via GWBASIC.  This will cause
3050 REM        exiting to GWBASIC.  To restart the FILTER DEVELOPMENT
3060 REM        PACKAGE type <F2> <Enter>.  This will restart whichever
3070 REM        window module selected previously from Main Menu.  Program
3080 REM        must be re-run to re-develop filter to obtain the hardcopy
3090 REM        initially desired.
3100 REM
3110 LPRINT TAB(26);"*** FIR DEVELOPMENT PACKAGE ***"
3120 LPRINT
3130 LPRINT TAB(14);COEFF;"Coefficient ";TYPE$;" Filter Using the ";WIN$;" Window"
3140 LPRINT
3150 IF TYPE=1 THEN LPRINT TAB(8);"Cutoff frequency =";HCUT;"Hz":GOTO 3190
3160 IF TYPE=2 THEN LPRINT TAB(8);"Cutoff frequency =";LCUT;"Hz":GOTO 3190
3170 LPRINT TAB(8);"Lower Cutoff Frequency =";LCUT;"Hz"
3180 LPRINT TAB(8);"Upper Cutoff Frequency =";HCUT;"Hz"
3190 LPRINT TAB(8);"Sampling Frequency (Fs) =";FSAM;"Hz"
3200 LPRINT TAB(8);"Impulse Duration (D) =";D*1000;"msec"
3210 LPRINT
3220 LPRINT TAB(20);"C'(n)";TAB(53);"H(n)"
3230 LPRINT TAB(20);"-----";TAB(53);"----"
3240 LPRINT
3250 LPRINT TAB(51);"DECIMAL";TAB(70);"HEX"
3260 LPRINT
3270 FOR I=0 TO Q
3280 GOSUB 3790    'convert coeff. index to char, removing spaces in output
3290 LPRINT TAB(8);
3300 LPRINT "C'(";C1$;")";
3310 LPRINT TAB(15);" = ";
3320 LPRINT USING "+#.#####";C(I);:LPRINT " = C'(";C2$;")";
3330 LPRINT TAB(41);
3340 LPRINT "H(";C1$;")";
3350 LPRINT TAB(47);" = ";
3360 LPRINT USING "+#.#####";H(I);:LPRINT " = H(";C2$;")";
3370 LPRINT TAB(67);" = ";CHEX$(I)
3380 NEXT I
3390 RETURN
3400 REM -------------------- Output Coefficients to File ----------------------
3410 REM
3420 REM        This routine writes the coefficients to a file (named by the
3430 REM        user).  The file contains TMS320 (C30 or C25) data format.
3440 REM
3480 REM        This file can then be merged into a 'blank' filter program
3490 REM        via a word processor like PC-WRITE.  NOTE: A directory or
3500 REM        drive specification can be given along with the filename.
3501 LOCATE 17
3502 PRINT "                                                                   "
3503 LOCATE 17
3504 INPUT "      Enter DSP type (C25 or C30):";DSP$
3505 IF DSP$="C30" OR DSP$="c30" THEN GOTO 3660
3506 IF DSP$="C25" OR DSP$="c25" THEN GOTO 3510
3507 GOTO 3501
3510 CLS
3520 LOCATE 12
3530 INPUT "       Enter Filename : ",NAM$
3540 LOCATE 12
3550 PRINT "                                                                   "
3560 LOCATE 12:PRINT TAB(30);"...saving ";NAM$
3570 OPEN NAM$ FOR OUTPUT AS 1
3580 FOR I=0 TO COEFF-1
3590 S$=STR$(I)
3600 IF I>9 AND I<100 THEN PRINT#1,"H";RIGHT$(S$,2);"     DATA    >";CHEX$(I) : GOTO 3630
3610 IF I>99 THEN PRINT#1,"H";RIGHT$(S$,3);"    DATA    >";CHEX$(I):GOTO 3630
3620 PRINT#1,"H";RIGHT$(S$,1);"      DATA    >";CHEX$(I)
3630 NEXT I
3640 CLOSE 1
3650 RETURN
3660 CLS
3661 LOCATE 12
3662 INPUT "       Enter Filename : ",NAM$
3663 LOCATE 12
3664 PRINT "                                                                   "
3665 LOCATE 12:PRINT TAB(30);"...saving ";NAM$
3666 OPEN NAM$ FOR OUTPUT AS 1
3668 PRINT#1, USING "COEFF   .FLOAT  +##.########       ;H(###)  ==>  H(N-1)";H(COEFF-1);COEFF-1
3670 FOR I=COEFF-2 TO 1 STEP -1
3672 PRINT#1, USING "        .FLOAT  +##.########       ;H(###)";H(I);I
3674 NEXT I
3675 PRINT#1, USING "H0      .FLOAT  +##.########       ;H(  0)";H(0)
3677 PRINT#1,"LENGTH  .SET (H0-COEFF)+1          ;LENGTH = # OF COEFFs =";COEFF
3678 CLOSE 1
3679 RETURN
3680 REM =======================================================================
3690 REM ======================== Clear Coefficients ===========================
3700 REM
3710 LOCATE 10
3720 FOR N=1 TO 12
3730 PRINT "                                                                               "
3740 NEXT N
3750 LOCATE 10
3760 RETURN
3770 REM =======================================================================
3780 REM
3790 REM ======================= Integer to Character ==========================
3800 REM
3810 REM        This routine eliminates the spaces produced in the output
3820 REM        when an Integer TYPE is printed.  The spaces before and after
3830 REM        the integer value are set aside in the event that the integer
3840 REM        value is negative.  Since the Coefficient index is always
3850 REM        non-negative, this value is converter to a character type,
3860 REM        and output from this routine as c1$ and c2$.
3870 REM
3880 S1$=STR$(I)
3890 S2$=STR$(COEFF-I-1)      'COEFF-I-1 is the symmetrical alternate of index
3900 C1$=RIGHT$(S1$,1)
3910 C2$=RIGHT$(S2$,1)
3920 IF I > 9 THEN C1$=RIGHT$(S1$,2)
3930 IF I > 99 THEN C1$=RIGHT$(S1$,3)
3940 IF COEFF-I-1 > 9 THEN C2$=RIGHT$(S2$,2)
3950 IF COEFF-I-1 > 99 THEN C2$=RIGHT$(S2$,3)
3960 RETURN
3970 REM =======================================================================
3980 REM
3990 REM ==================== Convert Coefficients to Hex ======================
4000 REM
4010 REM        This routine converts the coefficients to Hexidecimal
4020 REM        via a routine in GWBASIC called HEX$().  The HEX values
4030 REM        are accurate to + or - 1.
4040 REM
4050 FOR M=0 TO COEFF-1
4060 CARY(M)=CINT(H(M)*32768!)    'scale by 2^15
4070 IF CARY(M) >= 0 GOTO 4090
4080 CARY(M)=65536!+CARY(M)
4090 CHEX$(M)=HEX$(CARY(M))
4100 NEXT M
4110 RETURN
4120 REM =======================================================================
4130 REM
4140 REM ====================== Error Message Routine ==========================
4150 REM
4160 FOR BLINK=1 TO 10
4170 IF MES<>1 THEN 4210
4180 LOCATE 20
4190 PRINT TAB(14);"ERROR! : Sampling Frequency (Fs) >= 2*Nyquist - reenter"
4200 GOTO 4230
4210 LOCATE 20
4220 PRINT TAB(15);"ERROR! : Frequency value is inconsistant - reenter"
4230 FOR DELAY=1 TO 100:NEXT DELAY
4240 LOCATE 20
4250 PRINT"                                                                    "
4260 NEXT BLINK
4270 RETURN
4280 REM =======================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -