3.11 IIR Filter Design
There are two main categories of IIR filter design: direct and indirect methods. In the latter category, one first designs a continuous-time system function , and in a second step converts into a discrete-time filter . In contrast, the direct methods obtain directly from the specifications.
3.11.1 Direct IIR filter design
The direct methods for IIR design are tightly related to parametric power spectrum estimation. For instance, the Yule-Walker IIR filter design method is related to the techniques discussed in Section 4.8.
The Yule-Walker method is implemented in the Matlab function yulewalk. Its input is a simplified description of the desired discrete-time frequency response magnitude , which can be arbitrary. In other words, is not constrained to be the standard lowpass, highpass, bandpass or bandstop responses, which is an advantage of this method. Yule-Walker basically consists in discretizing the specification of to obtain , finding the inverse DFT of and solving modified Yule-Walker equations to obtain the filter coefficients [FP84]. The phase information cannot be specified. The code below illustrates how Matlab can design a digital filter with two passbands and order 16:
1N = 16; %filter order 2f = [0 0.3 0.3 0.6 0.6 0.8 0.8 1]; %frequencies 3m = [1 1 0 0 1 1 0 0]; %magnitudes (linear scale) 4[B,A] = yulewalk(N,f,m); %get H(z)=B(z)/A(z) 5[h,w] = freqz(B,A,128); %frequency response with 128 points 6plot(w/pi,20*log10(abs(h))) %plot magnitude in dB
3.11.2 Indirect IIR filter design
When the desired filter should have standard lowpass, highpass, bandpass or bandstop responses, indirect design methods are typically adopted. The reason is that there are many well-established recipes for designing analog filters and also methods for mapping into a discrete-time filter.
The indirect IIR filter design has the following steps:
- f 1.
- convert the filter specification from discrete to continuous-time,
- f 2.
- design the continuous-time ,
- f 3.
- convert into .
Some practical analog filter designs (the step that obtains ) are discussed in Example 3.14. The emphasis in the next paragraphs is the last step: conversion of into .
Note that, after is converted into , the frequency response of the former is mapped to . When the goal of is to perform filtering, it is often of interest to compare and . In this case, as discussed in Section 3.5.7.0, the D/S conversion of the discrete-time impulse response corresponding to can be used to obtain in rad/s, which can then be more directly compared with the original that is also in rad/s. In such situation, it may be worth to use subscripts and to identify the original and D/S converted frequency responses, respectively. Given that is periodic, a reasonable goal may be to seek a good approximation over the first Nyquist zone, i. e.
| (3.56) |
Five methods to convert a continuous-time into a discrete-time transfer function are briefly discussed in the sequel with an emphasis on the bilinear method, which is the most used in designing standard filters (lowpass, highpass, etc.).
3.11.3 Methods to convert continuous into discrete-time system functions
Matched Z-transform or pole-zero matching
The matched Z-transform method, also called pole-zero matching method, consists in simply using Eq. (2.59) to map all finite21 poles and zeros of into new poles and zeros, in the z-plane, which then compose . In other words, assuming is the -th zero or pole of , it is mapped into a corresponding zero or pole of given by , where is the sampling interval.
After the mapping is performed, a scaling factor is used such that the magnitude of is the same of for a specific frequency of interest. For example, for lowpass systems, the DC gain is adjusted to have .
Example 3.18. Matched Z-transform of a first-order system. The matched Z-transform of is discussed in this example. The pole at is mapped to a pole at such that . Note that at DC is 1, while at DC is . Now, one can choose a scaling factor to create a new that has .
In this case, the scaling factor is and the new is
| (3.57) |
The extra delay imposed by the numerator of in Eq. (3.57) is often eliminated and the final result is
| (3.58) |
which minimizes the delay in the corresponding difference equation.
When pole-zero matching (matched Z-transform) starts from direct specification of zeros and poles, it is sometimes called pole-zero placement. The following example of designing a notch filter illustrates this situation.
Example 3.19. Using pole-zero placement, design a 2nd-order notch filter to minimize the impact of interference at a given frequency. The value of the frequency used by electrical power systems depends on the country and is typically or 60 Hz. The power line signal can cause strong interference at this specific frequency and its harmonics. For instance, a circuit that digitizes an ECG signal may have to filter out the interference at to obtain better results. Here we are interested in using pole-zero placement to design a notch filter to reduce the power at . Four project guidelines will be used:
- The filter will have two complex-conjugate zeros and and two complex-conjugate poles and .
- The digital frequencies (the angles) of poles and zeros are the same. Given Eq. (1.36), which can be written as , the frequency specified in Hz can be mapped to the digital domain as , in radians.
- The zeros have magnitudes equal to one because they must be located on the unit circle.
-
The poles magnitude depend on , which is the 3 dB filter bandwidth. More specifically, can be obtained from Eq. (3.35) as
or from Eq. (3.36), which leads to
The latter is a good approximation when is in the range .
These guidelines lead to the following pairs of zeros: and , while the poles are and .
Listing 3.19 provides an example of notch filter design assuming Hz.
1f_notch=60.0; % notch frequency in Hz 2BW_3dB=4; % 3 dB bandwidth in Hz 3Fs=400; % sampling frequency in Hz 4Omega_0=2*pi*(f_notch/Fs); % digital angular frequency 5r=exp(-(BW_3dB/Fs)*pi); % poles radius 6notch_zeros = [1*exp(1i*Omega_0) 1*exp(-1i*Omega_0)]; 7notch_poles = [r*exp(1i*Omega_0) r*exp(-1i*Omega_0)]; 8Bz_notch=poly(notch_zeros); % numerator B(z) 9Az_notch=poly(notch_poles); % denominator A(z) 10freqz(Bz_notch, Az_notch) % show frequency response
The frequency response shows that this filter can attenuate the signal by more than 20 dB around the frequency . However, when one decreases to avoid filtering out components other than , the poles get closer to the unit circle, which may lead to unstable filters when implemented in an embedded system. For instance, if Hz, then . If is decreased to Hz, then and the filter attenuation is rather small because the poles are almost canceling the zeros.
Similar to the matched Z-transform, the next filter design techniques assume is available.
Impulse invariance
The impulse invariant transformation method is based on the criterion of sampling the continuous-time impulse response such that , where and are the impulse responses of and , respectively, with
| (3.59) |
and denoting the Z-transform.
The impulse invariant method is restricted to strictly proper (degree of numerator smaller than the denominator’s). Besides, special care must be exercised when has multiple-order poles.22
Example 3.20. Example of to conversion using impulse invariance. Assume that and . Performing a partial fraction expansion leads to
which, assuming a causal system (to define the ROC), corresponds to
The impulse invariance is obtained after a S/D process. Using the simplified notation of Example 1.33, one can write
and then, using a procedure similar to the one in Example 2.23, leads to
Note that the poles and in the s-plane were converted to and in z-plane, respectively, which corresponds to using Eq. (2.59) of the matched Z-transform method. And the numerators of the parcels of are the pole residues scaled by . Listing 3.20 illustrates the use of impinvar in this example. In this specific case, the impulse invariant and matched Z-transform methods lead to the same poles of .
1Ts=0.5; %sampling period 2Bs=4; As=poly([-2 -3]); % Define H(s)=Bs/As 3[Bz,Az] = impinvar(Bs,As,1/Ts);%impulse invariance conversion to H(z) 4t=0:Ts:10; ht=4*(exp(-2*t)-exp(-3*t)); %create h(t) to compare 5hn=impz(Bz,Az,length(ht)); %discrete-time h[n] from H(z)=Bz/Az 6h_Error=Ts*ht(:) - hn(:); %error from column vectors 7disp(['mean square error (MSE) = ' num2str(mean(h_Error.^2))]); 8plot(t,Ts*ht); hold on; plot(t,hn,'rx'); %compare curves
The result of Listing 3.20 is a MSE = 7.7342e-34, which indicates that , as desired.
When has only single-order poles, the impulse invariant transformation method can be summarized as:
- f 1.
- a partial fraction expansion of to obtain the residue of each pole and
- f 2.
- create the parcels of with poles and respective numerators .
Step invariance
The step invariant transformation method is similar to the impulse invariant but uses the step responses in continuous and discrete-time instead of the impulses responses. Similar to the impulse response , which is the system output when the input is , the step response is the system output when the input is . The goal of this transformation is to achieve
| (3.61) |
which can be written as
| (3.62) |
where the S/D process is denoted in the simplified notation of Example 1.33.
Eq. (3.62) used the fact that and are the Laplace and Z transforms of and , respectively. Taking the Z-transform of both sides of Eq. (3.62) leads to
| (3.63) |
The script snip_systems_stepinvariance.m illustrates the step invariance method for a single pole .
Backward difference and forward difference
The backward difference and the forward difference methods consist in substituting by and , respectively. They are motivated by the solution of differential equations using finite differences. For digital filter design these methods are outperformed by others, and have more pedagogical than practical importance.
Bilinear or Tustin’s
In the bilinear transform (also called Tustin’s) method, is substituted by .
Before discussing the bilinear transformation in more details, the next subsection provides an example of each of the major IIR design techniques.
3.11.4 Summary of methods to convert continuous-time system function into discrete-time
In previous sections, several methods to convert into were discussed. Table 3.6 summarizes their application to a first order analog , with . Recall from Figure 3.19, that for , the pole center frequency is , and the natural and cutoff frequencies coincide.
The matched Z-transform in Table 3.6 used Eq. (3.58).
Method |
Mapping |
when |
Matched Z-transform | Map poles or zeros at | |
to | ||
Impulse-invariant | ||
Step-invariant | ||
Backward difference | ||
Bilinear | ||
Due to its importance, the bilinear transformation is further discussed in the next sections. Section 3.12 concerns the definition of the bilinear transformation and its main properties. The discussion in Section 3.12 considers that and have already been chosen and focuses on finding through the bilinear transformation, and understanding this mapping. Section 3.13 complements this discussion by detailing the design of system functions using the bilinear transformation. This includes choosing , designing and finally obtaining .