• Not Answered

IIR and FIR filter library questions

I am using the F28335 chip. I looked for iir and fir filters and found some for the C2000 but they are written for integer math. My questions are:

1) Is there a library for the C2000 chips with floating point support?

2) If not and I need to use the integer versions, for iir32, do I need to scale the input to Q15 (ie x 32768) before feeding it to the filter function?

3) Why isn't there a 32 bit version of the FIR? Or is there?

Thanks

34 Replies

  • In reply to Yu Cai58368:

    With the old filter i mean the implementation in version 0.9c (sprc082 from 12.Jan 2005).

    There the iir32-Filter has an integer (Q15) as input value. In the new implementation of iir5biq32 there is a long (Q31) as input value.

    In the filterfunction the inputvalue is first multiplied by the 'Input scaling factor'(ISF), to avoid overflow, as you already mentioned.

    But on the other side there is a lost in resolution of the inputsignal. 

    For example in your IIR5BIQ32-Testcoefficients there following defination for a LP-Filter.

     

     

     

     

     

     

     

     

     

     

     

     

    #define IIR32_LPF_ISF

     

     

    #define IIR32_LPF_QFMAT

     

     

    28
    134086103

    This means for me that the inputvalue is multiplied by 0.0312 (134086103/(2^32)). So the lower 5 bit of the inputvalue get lost.

    So there is also a tradeoff of resolution. (with the old implementaion this was only a matter if ISF would by <1/(2^16))

    As far as I see the parameter Ni is the number of samples of the impulse response for the 'norm' of each biquad.

    But how long has this at least to be?

    I'd like to have no overflow inside the filtersection, but also the smallest ISF to have good resolution...

    So my question how the value of 500 (for Ni) is choosen...

    /Stefan

  • In reply to stefan.noehammer:

    /* LPF co-efficients for IIR32 module */
    #define IIR32_LPF_COEFF {\
                0,248624377,0,20118017,20118017,\
                -141524868,517372703,43749199,87498398,43749199,\
                -228291242,583544331,35450657,70901314,35450657,\
                -401770939,715847129,875854244,1751708488,875854244}

    #define IIR32_LPF_ISF   288246535
    #define IIR32_LPF_NBIQ  4
    #define IIR32_LPF_QFMAT 29

    I am not sure if the example code that you are talking is the same as what I am tallking. There  are two example codes for IIR. One is 2833x_FixedPoint_IIR32 and one is 2833x_FxiedPoint_IIR16. One is for 32 bit IIR filter implementation and one is for 16 bit IIR filter implementation.

    For the 32 bit version, the input has to be in 32 bit format input (Q31) and for the 16 bit implementation the input should be Q15. I am not sure if the old version has some bug in it. It was developed long time ago and that's why I cleaned up. The new example code had been tested and the results were compared with matlab scripts.

    In IIR filter, lost resolution is unavoidable by fixed point implementation. If you want to change the ISF value, please check the matlab script either eziir32.m or FixedPointIIR32.m. You can change the Ni and see if the matlab simulation result overflow. If that Matlab simulation is good, then CCS result should be good also. If that one is not good, so you have to sacrifice you resolution.

    Please focus on the example code that I provided and don't pay too much attention to the old version. The old version might have some bug even though it is a release version.

    -Yu Cai

  • In reply to Yu Cai58368:

    Yu Cai,

    I am currently using the c28346 for control purposes in an embedded design. I would like to add DSP FIR and IIR filtering functionality to my project using floating point and optionally fixed point math in either 16-bit or 32-bit. I am new to DSP on the floating point Delfino and would benefit greatly by using the libraries mentioned in this forum. Is there officially released fixed and floating point libraries available on the TI site? Also, can you point me in the right direction in regards to c28346 DSP FIR and IIR filtering reference material, example c28346 DSP FIR and IIR filtering code and etc? Thanks for your help.

    Best regards,

    Guilford

  • In reply to Guilford Cantave61944:

    I think the latest FIR and IIR library was uploaded with the newest controlSUITE.  It was associated with example project from which you can know how to call those functions. By the way, the matlab script is also attached which can be used as reference guide and very useful in debugging.

    For testing any kinda IIR or FIR filter, you have to verify your algorithm at first in Matlab, which means before matlab code is working, you'd better not porting to your CCS. After it works, then it's a good reference as you debug in CCS or any real-mode. Good luck.

    Y. Cai