What am I missing about IIR Filter Design?

Started by August 20, 2014
```Every article I see regarding IIR filter design seems to make the subject
far more complicated than it needs to be.

For example, in this DSPRelated post "IIR Coefficient Calculation -
ger_lough" the discussion goes on in great length about specific formulas
for different protoypes (Butterworth, Chebyshev, etc) sampling rates, Q,
pole locations, etc.

I wrote an IIR Filter design program where I simply started with a 2nd
order H(s) and substituted s with the bilinear transform. I then had a
biquad form for H(z) in terms of the 2nd order analog filter coefficients
and T. See this link for details.

http://www.iowahills.com/A4IIRBilinearTransform.html

These filters seem to work fine, and this method works for any filter type
(i.e. Buterworth, Elliptic, low pass, bandpass, etc). All that's needed are
the 2nd order analog filter coefficients and a cutoff frequency in terms of
Nyquist to calculate T.

This method guarantees stability because the left hand s plane poles are
guaranteed to map to within the unit circle on the z plane. There is no
question of how to match Elliptic (or Inv Chebyshev) zeros with poles. And
this method avoids the biquad partitioning problem on high order filters,
as described in Understanding DSP by Rick Lyons (p. 291).

Is this simple method deficient in some sense? What am I missing?

Thanks,
Dan

_____________________________
Posted through www.DSPRelated.com
```
```On Wed, 20 Aug 2014 09:54:41 -0500, FilterDan wrote:

> Every article I see regarding IIR filter design seems to make the
> subject far more complicated than it needs to be.
>
> For example, in this DSPRelated post "IIR Coefficient Calculation -
> ger_lough" the discussion goes on in great length about specific
> formulas for different protoypes (Butterworth, Chebyshev, etc) sampling
> rates, Q, pole locations, etc.
>
> I wrote an IIR Filter design program where I simply started with a 2nd
> order H(s) and substituted s with the bilinear transform. I then had a
> biquad form for H(z) in terms of the 2nd order analog filter
> coefficients and T. See this link for details.
>
> http://www.iowahills.com/A4IIRBilinearTransform.html
>
> These filters seem to work fine, and this method works for any filter
> type (i.e. Buterworth, Elliptic, low pass, bandpass, etc). All that's
> needed are the 2nd order analog filter coefficients and a cutoff
> frequency in terms of Nyquist to calculate T.
>
> This method guarantees stability because the left hand s plane poles are
> guaranteed to map to within the unit circle on the z plane. There is no
> question of how to match Elliptic (or Inv Chebyshev) zeros with poles.
> And this method avoids the biquad partitioning problem on high order
> filters, as described in Understanding DSP by Rick Lyons (p. 291).
>
> Is this simple method deficient in some sense? What am I missing?

First, you say:

"While it is certainly possible, and mathematically correct, to implement
band pass and notch filters using 4th order sections, you will probably
find that the peak math values generated by them would make it difficult
to implement the filter on a fixed point processor. Consequently, you
will need to factor these into 2nd order sections. If you are using a
floating point processor however, it makes no difference what degree the
polynomials are."

This statement is generally not correct for IEEE single-precision (32-
bit) floating point, which is what's available on a lot of DSP hardware.
At some combination of filter order and pole position, it won't even be
correct for IEEE double-precision (64-bit) floating point, although you
have a lot more room to mess around in.

(Note that this is even the case for a second-order or first-order
filter, but you have to be filtering REALLY low frequencies compared to
the sampling rate before it becomes an issue).

Then, there's something missing:

If you're using the bilinear transform, the frequencies that actually get
worked on are different from the frequencies worked on by the continuous-
time filters.  They're nearly the same at low frequencies, but they get
warped more and more as you design filters to work closer to the sampling
rate.  You fix this by "pre-warping" the design frequencies, making your
continuous-time prototypes, then doing the bilinear transform.

--
www.wescottdesign.com
```
```This statement is generally not correct for IEEE single-precision (32-
bit) floating point, which is what's available on a lot of DSP hardware.
At some combination of filter order and pole position, it won't even be
correct for IEEE double-precision (64-bit) floating point, although you
have a lot more room to mess around in.

(Note that this is even the case for a second-order or first-order
filter, but you have to be filtering REALLY low frequencies compared to
the sampling rate before it becomes an issue).

I'll take a closer look at this, but when I emulate fixed pt in my program,
the filters work fine with just 28 bits, even when the cutoff is as low as
0.01 (Inv Cheby low pass)

_____________________________
Posted through www.DSPRelated.com
```
```On Wed, 20 Aug 2014 11:08:39 -0500, FilterDan wrote:

> This statement is generally not correct for IEEE single-precision (32-
> bit) floating point, which is what's available on a lot of DSP hardware.
> At some combination of filter order and pole position, it won't even be
> correct for IEEE double-precision (64-bit) floating point, although you
> have a lot more room to mess around in.
>
> (Note that this is even the case for a second-order or first-order
> filter, but you have to be filtering REALLY low frequencies compared to
> the sampling rate before it becomes an issue).
>
>
> I'll take a closer look at this, but when I emulate fixed pt in my
> program,
> the filters work fine with just 28 bits, even when the cutoff is as low
> as 0.01 (Inv Cheby low pass)

The two determining factors are coefficient quantization and quantization
noise.

Coefficient quantization is just that: the coefficients can't be
infinitely precise, so when they're calculated their values are rounded
off.  As polynomial order goes up, the sensitivity of the polynomial's
roots to variations in its coefficients goes up.  When you have a low-
frequency filter with poles all bunched up close to z=1, just a little bit
of change in pole position can have a big effect on filter performance.

Part of the reason that you may find what you're doing so simple, and
what's written about so complicated, is that those authors may be trying
to cover all of the "gotchas" that one eventually runs into (and are
recalled with remembered pain), while you are just covering the part that
often -- but not always -- works.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```
```On 8/20/14 10:54 AM, FilterDan wrote:
> Every article I see regarding IIR filter design seems to make the subject
> far more complicated than it needs to be.
>

check out the cookbook.  i am told it needs *more* content, but i am

>
> These filters seem to work fine, and this method works for any filter type
> (i.e. Buterworth, Elliptic, low pass, bandpass, etc). All that's needed are
> the 2nd order analog filter coefficients and a cutoff frequency in terms of
> Nyquist to calculate T.
>
> This method guarantees stability because the left hand s plane poles are
> guaranteed to map to within the unit circle on the z plane. There is no
> question of how to match Elliptic (or Inv Chebyshev) zeros with poles. And
> this method avoids the biquad partitioning problem on high order filters,
> as described in Understanding DSP by Rick Lyons (p. 291).
>
> Is this simple method deficient in some sense? What am I missing?

other than the effects of frequency warping (which can be compensated
for one frequency parameter for each degree of freedom in the design
using what we call "pre-warping") i can't think of a downside to
bilinear transform.

one consequence of frequency warping in the BLT is that for an LPF, if
the analog filter goes to -inf dB gain at f=inf, then the digital filter
will dive to -inf dB gain at Nyquist.  you might like that or you might not.

--

r b-j                  rbj@audioimagination.com

"Imagination is more important than knowledge."

```
```0.01 is not a particularly narrow filter. For example, it's 960 Hz for a 96
kHz audio signal. Scale that down by two orders of magnitude for a DC block
and numeric precision becomes quite a bit more difficult.

_____________________________
Posted through www.DSPRelated.com
```
```BTW, you won't avoid "partitioning" of high order filters if performance
matters.
A series arrangement is not necessarily the most efficient way, there's
more to it.
See slides 25 and 29 here:
http://www.site.uottawa.ca/~mbolic/elg6163/ELG6163_IIR.pdf

_____________________________
Posted through www.DSPRelated.com
```
```>0.01 is not a particularly narrow filter. For example, it's 960 Hz for a
96
>kHz audio signal. Scale that down by two orders of magnitude for a DC
block
>and numeric precision becomes quite a bit more difficult.
>
>_____________________________
>Posted through www.DSPRelated.com
>

I see what you are saying. My lower limit is about 0.001 for 32 bits.

_____________________________
Posted through www.DSPRelated.com
```
```BTW, you won't avoid "partitioning" of high order filters if performance
matters.

High end performance isn't a big concern for me.

I should explain that the material on my web site isn't intended for DSP
experts. As an RF engineer, I have worked with a lot of EE's and software
engineers who want to use a digital filter for something really basic, but
have no idea how to design or implement one.

At my last job for example, we had no DSP expertise in house and the
software guys needed a simple FIR low pass to run on a MSP430. High end
performance was the least of their concerns.

I just want my stuff to be good enough to get guys like that started.

_____________________________
Posted through www.DSPRelated.com
```
```>> High end performance isn't a big concern for me.

Well, I guess that answers the original question ("what am I missing").
If you can afford to cut some corners, fine. A cookbook recipe like
pre-warped bilinear transform will do to design "a" filter for most
problems. It's been a standard textbook chapter for two decades or longer,
no one doubts that it works.
Now, once performance / cost become an issue, there may be more efficient
alternatives.

BTW, first-order noise shaping can help quite a bit. Simply store the LSBs
that rounding drops from the accumulator, and add them in the next cycle
before rounding.

_____________________________
Posted through www.DSPRelated.com
```