When implementing FIR filters the coefficients are all in a linear array so the task of importing the coefficients into an application is relatively straight forward.

Importing IIR coefficients into an application, however, is quite different and there are several traps than can cause the application to fail.

The following diagram shows the flow diagram of a direct form I IIR biquad :

All digital filter design programs will return a single or multi-dimensional array along the lines of the following :

int pIIRCoeffs[NUMBER_OF_FILTER_STAGES * NUMBER_OF_COEFFS_PER_BIQUAD] = {

Coefficients for Biquad #1,

Coefficients for Biquad #2,

Coefficients for Biquad #3

};

- The sign of the feedback coefficients may or may not be negated, in which case you may need to negate the coefficients yourself.
- There is no international standard for which set of coefficients should be notated an or bn. You should check the documentation of your design tools because there are always : 3 feedforward coefficients and 2 feedback coefficients. You may need to re-order the feedforward and feedback coefficients in your array.

Point 1. raises further issues with the implementation :

- Negating the feedback coefficients allows the use of the Multiply-Accumulate (mac) instruction, which is available on all DSPs and many microprocessors and microcontrollers.
- Not negating the feedback coefficients will require a multiply followed by a subtract. Nearly all DSPs and some microprocessors and microcontrollers implement a Multiply-Subtract (msub) instruction. If your chosen device does not implement msub then the multiply and subtract operations will be separated leading to slower performance. In this case it would be better to negate the coefficients and use a code implementation that uses the mac instruction. Many digital filter design programs, including Numerix' Digital Filter Plus (http://www.numerix-dsp.com/dfplus/) provide an option to pre-negate the coefficients, which allows the use of the mac instruction. The SigLib DSP library (http://www.numerix-dsp.com/siglib.html) includes functions to implement either format.

If you have found this solution useful then please do hit the Google (+1) button so that others may be able to find it as well.

Evaluate The Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/

## No comments:

## Post a Comment