7
$\begingroup$

I would like to implement a fourth order fixed point low-pass IIR filter in C (with Q15 arithmetic), and I will prepare this filter by using two stages cascaded direct form-II bi-quad filters.

I have found countless C implementations and example coefficients on the digital signal processing books, but I saw non of them is not reliable during the verification (they create overflows, does not attenuate expected frequency components, etc.).

Which C implementation is suitable for this problem? And also, is there any sample coefficients to verify this implementation?

$\endgroup$
  • 1
    $\begingroup$ If you haven't found any implementations that work for you, what is preventing you from rolling your own? You seem to understand where the ones you have found fall short, so just augment them to fit your requirements. A fourth-order IIR based on second-order sections isn't that complicated to write. $\endgroup$ – Jason R Jan 13 '12 at 19:16
  • $\begingroup$ Is your problem really about design of a filter or have you got the co-efficients already and want to implement it? $\endgroup$ – Dipan Mehta Jan 14 '12 at 10:25
  • $\begingroup$ I have already prepared the filter, and I have coefficients. $\endgroup$ – albin Jan 16 '12 at 16:15
8
$\begingroup$

Although this seems like a remarkably simple questions, it requires a remarkably complicated answer.

I don't think there is a "one-size" fits all solution. The best choice of algorithm will depend on what noise you can tolerate and the type of low pass (steepness & frequency). For example at 44.1 KHz sample rate a 4th order Butterworth at 10 kHz is fairly straight forward, whereas a lowpass at a 100Hz is a royal pain. In essence it depends on how close your poles are to the unit circle.

Quantization and rounding error of IIR filters are usually transfered to the output weighed by the pole-only transfer function. A 4th order Butterworth 10 kHz low pass filter has a worst case noise amplification of only 5dB, so that is not much of a problem.

However at a 100 Hz low pass (again 4th order BW) the noise gets amplified by a whopping 75 dB. If you use Q15 math, your basic noise floor is maybe at -100dB or so. After you the filter your signal to noise ration will only be 25 dB.

That's one of the reasons why fixed point IIR filters are fairly complicated. IF you need low cutoff frequencies and half way decent signal to noise ratio, than the basic algorithms will not work. You need to look into double precision math and/or error spectrum shaping or related methods.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.