This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F2806x 16 Bit Fixed point IIR filter not giving expected performance

Hello! I'm trying to implement a 16 bit fixed point IIR filter on my board, but i'm not getting the expected response. For example, I'm trying to generate a 200Hz wide bandpass filter centered around 1500Hz. All my inputs should be listed in the code below along with my coefficients that i'm generating from the matlab program. I then copy past the coeficients into my code so that I can use the IIR filter, however the magnitude of my signal is not coming out as expected.

#define IIR16_LPF_COEFF {\
    -915,1642,-35,0,35,\
    -971,1636,280,-416,280,\
    -978,1741,14475,-26374,14475,}


#define IIR16_LPF_ISF   45
#define IIR16_LPF_NBIQ  3
#define IIR16_LPF_QFMAT 10


\\Below are the inputs used to create the filter coefficients in matlab
\\Filter Type: Chebyshev(Type 2)
\\Filter Type: Band Pass
\\Sampling Freqency (Hz): 16384
\\Pass band Ripples (dB): 1
\\Stop band Ripples (dB): 36
\\Lower Stop Band Corner Frequency (Hz): 1150
\\Lower Pass Band Corner Frequency (Hz): 1400
\\Upper Pass Band Corner Frequency (Hz): 1600
\\Upper Stop Band Corner Frequency (Hz): 1850

I'm inputing into my ADC a 1500Hz signal with an amplitude of 2.16V. I'm then taking this signal, putting it through my filter, and then outputting the result to the DAC. When using the filter, my output comes out at 1.24V. If I skip over the filter and just output what comes into my ADC, I get the exact same signal out as expected. Does anyone know why i'm only getting a 57% amplitude on this filter when I should be getting 100%? Thanks for any input!

-Greg

  • Greg,

    Sorry again for the delay.  The filter output relative to the input should be scaled by /2.  That's an intended feature of the filter and I believe that's the scaling you are seeing.  It happens because the numeric format at the input is Q15, while that at the output is Q14.  It's mentioned in the filter user's guide on pages 54 & 55.  This is implemented in an ROR instruction at the bottom of the iir5biq16.asm source file together with a comment about the reason why it's done:

    ROR ACC
    MOV *XAR4,AH ; output=Filtered Output in Q14 format
    CLRC OVM
    LRETR ; !!!Do not shift it left to store in Q15 format
    ; If you do so, and if the output is >1, then it will
    ; become negative..instead of the most desirable Saturation

    So: I think you should be seen an inherent /2 (50%) in the input-to-output gain, and it's there to protect against a transient being a little over +/-1 when an input is applied.  I think that extra bit serves as a guard band.  I hope this helps.

    Thanks to Vishal Coelho who dug into this.

    Regards,

    Richard