0

我正在使用 dsplib 库 dsPIC30F DSP 库在 dsPIC 上实现数字滤波器。

我使用 MATLAB 设计了我的过滤器。

clc; clear all;
filter=designfilt('lowpassiir', 'FilterOrder', 4, 'PassbandFrequency', 3900, 'PassbandRipple', 1, 'SampleRate', 16000);
hd = dfilt.df2tsos(filter.Coefficients);

coef = fi(hd.sosMatrix)

fvtool(coef)

coef = 

    0.3949    0.7897    0.3949    1.0000   -0.0807    0.7538
    0.1279    0.2559    0.1279    1.0000   -0.7783    0.3203

从matlab dofumentation:

 SOS = [ b01 b11 b21  1 a11 a21
         b02 b12 b22  1 a12 a22
         ...
         b0L b1L b2L  1 a1L a2L ]

来自数据表:在有序集合 {b0[s], b1[s], a1[s], b2[s],a2[s]} 中排列的每二阶(双二次)部分有 5 个系数,0 ≤ s < 年代。

我已经按照建议实现了我的系数,见下文

const float filter[10] = {0.3948975, 0.7897339, -0.0807495, 
0.3948975, 0.7538452, 0.1279297, 0.2558594, -0.77825928, 0.1279297,  
0.3203125};

const float filter_float[10] = {0.3948975, 0.7897339, -0.0807495, 
0.3948975, 0.7538452, 0.1279297, 0.2558594, -0.77825928, 0.1279297,  
0.3203125};

fractional filter[10]; // 5

for(i=0; i<10; i++){
    filter[i]=Float2Fract(filter_float[i]);
}

fractional dbIr_1[2], dbIr_2[2];    // Delay-Line-Buffer I-Filte
(Segment 1 and 2)  
IIRTransposedStruct Filter; 
Filter.coeffsBase=filter;       // Sets the filtercoefficients
Filter.numSectionsLess1=1;      // Define number of sections
Filter.finalShift=0;            // Define shift of output (-1 
Filter.delayBase1=dbIr_1;       // Sets the delayline buffer
Filter.delayBase2=dbIr_2;       // --
Filter.coeffsPage=COEFFS_IN_DATA;   // Coefficient are stored in data 
IIRTransposedInit(&Filter);     // Initialize the filter

int blockLength=16;
int iyr[blockLength] = {0};

main{
    IIRTransposed (blockLength, iyl, xl, &Filter);
}

当我通过滤波器发送一个 500hz 信号时,没有信号留下,实际上,所有信号都被衰减为零。

我确实预计 500hz 信号将几乎保持不变。我在设计过滤器时做错了什么?

4

0 回答 0