15.3 IIR filters
IIR is the abbreviated notation for the infinite impulse response digital filters. The basic properties of IIR filters are:
- low order,
- nonlinear phase,
- potential instability.
When you are using IIR filters with order > 3, it is important to know that they are vary sensitive to wordlength effects and they can become unstable. IIR filters with order > 3, are normally broken down into smaller sections, typically second and/or first order blocks, which are then connected up in cascade or in parallel. For details refer to : "Signal Processing : Discrete Spectral Analysis, Detection and Estimation" - M.Schwartz and L.Show (publisher MCGraw-Hill). "Digital Signal Processing" - E.C.Ifeachor and B.W.Jervis (publisher Addison-Wesley) Keep in mind that our filter designer tools implements IIR filters in direct canonical form, so you should not use IIR filters with order >3.
Design of an IIR filter starts by selecting Filter Designer Tool from the main menu of the mikroPascal compiler for dsPIC. The option IIR parameters on the left-hand side of the menu is selected. The form shown in Fig. 15-12 appears.
Fig. 15-12 Entering IIR filter parameters
In the part Device setup appear the clock and designation of the used microcontroller.
In the part Input Signal, two parameters, sampling frequency and input channel of the AD converter should be selected. The sampling frequency has to be at least twice as high as the maximum frequency of the input signal. If, e.g. the input signal is in the range 230Hz – 7500Hz, the minimum sampling frequency is 15kHz. Of course, one never selects the minimum frequency, thus in this case the sampling frequency of at least 20kHz should be selected.
In the part Filter settings the type of filter is selected first:
- Lowpass filter,
- Highpass filter,
- Bandpass filter,
- Bandstop filter.
Then, the order of the filter is selected. As the order of the filter increases, the selectivity of the filter will be higher (narrower transition zone), but the complexity of the filter will increase as a consequence of the more memory required for storing the samples and longer processing. The maximum sampling frequency depends on the length of processing (filter order) and selected clock.
After the type of IIR filter is selected, the method of IIR filter design can be selected, as shown in Fig. 15-13.
Fig. 15-13 Selecting IIR filter design method
The basic IIR filter design methods are:
- Butterworth – Maximally flat amplitude characteristic at 0Hz frequency. The amplitude characteristc is a smooth curve.
- Chebyshev I – The minimum uniform ripple of the amplitude characteristc in the passband.
- Chebyshev II – Known as the Inverse Chebyshev filter. The amplitude characteristc is maximally flat at 0Hz (like Butterworth filter). The least variation of the amplitude characteristc in the bandstop range.
Depending on the selected design method and type of IIR filter, it is possible to enter the corresponding parameters, whereas the remaining filter parameters will be calculated automatically in the sourse of filter calculation. If the Bandpass filter and Chebyshev I method are selected, the parameters to be entered are: the maximum attenuation in the bandpass range Ap and bandpass boundary frequencies Wp1 and Wp2.
Fig. 15-14 Entering the bandpass attenuation and boundary frequencies
When all IIR filter parameters have been entered, design of the filter is carried out simply by selecting one of the options on the left-hand side of Filter Designer Tool
(IIR Prototype, IIR Frequency, mikroPascal, mikroBasic, mikroC).
In the part IIR Prototype
one can see the transfer functions of the analogue filter prototype, analogue filter, and digital filter. The analogue prototype filter and analogue filter are the transfer functions obtained in the course of calculations of the characteristcs of the digital filter. For a set of selected parameters, one obtains transfer functions as shown in Fig. 15-15.
Fig. 15-15 Transfer functions of the analogue filter prototype, analogue filter, and obtained digital filter
In the part IIR Frequency
one can see the amplitude characteristic of the obtained IIR filter. The present case is shown in Figs. 15-16 and 15-17.
The final product is the code in Pascal, Basic or C which could be accessed by selecting mikroPascal, mikroBasic or mikroC in the left-hand part of Filter Designer Tool
Fig. 15-16 Amplitude characteristic of the obtained IIR filter in LOG scale
Fig. 15-17 Amplitude characteristic of the obtained IIR filter in LIN scale