Saturday, March 9, 2013

Digital Filter University - Course V: IIR Filters

So, yall ready for IIR filters? I know I am!






While IIR filters can take on any block diagram form that implements the transfer function, they must implement some variant of the transfer function shown in this chart.

Note that various coefficients can be 0. If they are all 0 the transfer function itself is 0. I suppose this could be called a trivial IIR filter!

If all the denominator (a) coefficients are 0, this is an FIR filter. This is why the IIR filter is more general. But we really can't say that FIR filters are specific types of IIR filters, since FIR filters really do have finite impulse responses (that is, the feedback has been turned off since the a coefficients are all 0).

The block diagrams shown are some of the standard forms.







My book gives you a way to design IIR filters without going through all of this, or without using expensive software. But what's really behind the equations in my book, and behind the expensive software, is something like the following approach.

There are those that don't, but a good many digital filters actually begin life in the analog domain. Hopefully that will not shake your new found faith in digital ones.

The typical process is outline below.










Butterworth filters are, well ..., the bread and butter of the filter world (tee-hee). Here is what they look like mathematically when the process begins. These are the definitions of the Butterworth poles which define these filters in the analog domain.

To design a filter, one chooses the appropriate equation depending upon whether an even or odd order is desired.







The Butterworth poles define an analog filter, but it's not a very interesting one for most applications. This is because it is a lowpass filter and has a cut-off frequency of 1 radian per second and. Not very useful if you needed a bandpass filter centered at 83.4 MHz, right?

Fortunately, there are ways to transform this filter into the desired type with the desired critical frequency(ies), as seen below.









For example, the following transforms a 1st order Butterworth lowpass to a highpass with a 10 radian per second cutoff.













Now, to make that into a digital filter with the same characteristics, we do the following. Note that this transform must take into account the sample rate at which the filter will be implemented.





















Notice that there is a very slight deviation at the upper end, but basically we've made a digital filter that, for the specified sample rate, is a very nice replica of the original analog filter.










If you're the kind of person who rebuilds engines, reupholsters furniture, builds houses, and makes cakes from scratch, maybe you'll enjoy going through the above process every time you need a filter.

I do think it's rather fun, but even I just don't do that anymore. Software has made it so that one can just put in parameters and get answers. That's fine. But there are a lot of menus to try to figure out. And that process rather isolates you from what's happening inside.

In my book I took a different tact. I figured you wouldn't mind doing a little math, but that after you'd done it a time or two, you probably also wouldn't mind if I collapsed all those transforms above into a single step for you. So I derived the simplest possible equations for a number of popular filters, from 1st to 4th order.

This way, you can get the digital filter coefficients each from a single equation, just by providing what you know, cutoff frequency and sample rate, for the case of the 2nd order Butterworth lowpass below.

These are the simplest possible equations for designing such filters. Note that the denominators are the same, and that, in this case, b0 and b2 are also the same. So this makes the implementation even simpler. Note also that, besides using these when you want to design a filter, their simplicity makes them attractive for implementing in real-time systems that need to have adjustable filters.









My book constains equations for the following types of IIR filters.









Now, let's think a little bit more about what's happening behind the scenes. Note how the transfer function can be factored into poles and zeros.









Now let's think a bit about what poles and zeros actually do. First, consider one real zero at 0 Hz.









Now, what happens if we put a real zero at Fs/2? (Note that a single zero has to be real. To be complex it has to have a conjugate pair, so there'd be two zeros...)









A pair of zeros could both be real, but could also be a complex conjugate pair as below.






Here are some of the things we can do with complex conjugate pairs of zeros.







Now let's try some of the same things with poles.







And complex conjugate pairs of poles...








And then we can put poles and zeros together to form all sorts of interesting frequency responses. 







And this is really what digital filters are. Combinations of zeros and poles to create a variety of different responses. Of course you're free to create them anyway you like, but the standard forms are useful because, otherwise, it can take some trial and error to get the shapes we need. On the other hand, once we have a standard filter that's almost what we need, we can sometimes add zeros and poles, or jiggle them a bit, to fine tune.


No comments:

Post a Comment