Digital Signal Processing/IIR Filter Design

IIR filters are typically designed basing on continuous-time filter functions. Once the transfer function has been chosen, different filter structures allow to implement the filter, be it in hardware or in software.

= Transfer function =

The classical design technique is to start from a well known lowpass filter function and to transform it to a highpass, a bandpass or a bandstop function if required. Classical transfer functions are:
 * Butterworth
 * Chebyshev
 * Elliptic or Cauer

The general form of the transfer function is given by the ratio of 2 polynoms:
 * $$H(z) = \frac{B(z)}{A(z)} = \frac$$

= Filter structures =

The most straightforward digital filter implementation would be done by implementing its difference equation which is given by:
 * $$y\left[k\right] = b_{0} x[k] + b_{1} x[k-1] + \cdots + b_{M} x[k-M] - a_{1} y[k-1] - a_{2} y[k-2] - \cdots - a_{N} y[k-N]$$

The following circuit shows a possible implementation of the difference equation for a 4th order filter:



Nevertheless, this form is not used in practice. Indeed, the first who tried to implement a filter in that way have found out that this circuit is very sensitive to the coefficient values: a small change in one coefficient can have dramatic effects on the shape of the filter's transfer function. So rounding the coefficients to integer or fixed-point values resulted into a design nightmare. Because of this, engineers turned over to one of the following approaches:
 * simulating analog filter structures which had shown not to suffer of this acute sensitivity
 * breaking the total transfer function into a chain of second order sections, with an additional first order section for even-order filters

All-Pole Filters
All-pole filters are limited to lowpass devices. The fact that they do not have zeros makes their structure much simpler. Indeed, their transfer function is written as:

H(z) = \frac{B(z)}{A(z)} = \frac{1} = \frac{1} $$

Some filter structures based on the simulation of analog filters are used for the implementation of all-pole filters.

Butterworth and Chebyshev Type I functions are of all-pole kind.

Chains of Integrators
A Chain of Integrators with Feedback (CIF) allows a straightforward implementation of an all-pole transfer function.



This circuit, with $$U_1$$ to $$U_4$$ being the multiplier ouputs, can be described by the following equations:
 * $$\begin{cases}

st_1 \cdot U_1 = U_{in} - U_{out} \\ st_2 \cdot U_2 = U_1 - U_{out} \\ st_3 \cdot U_3 = U_2 - U_{out} \\ st_4 \cdot U_4 = U_3 - U_{out} \\ U_{out} = U_4 \end{cases}$$

which can be iteratively solved as:
 * $$st_4 \cdot U_{out} = U_3 - U_{out}$$
 * $$st_3 st_4 \cdot U_{out} = U_2 - U_{out} - st_3 \cdot U_{out}$$
 * $$st_2 st_3 st_4 \cdot U_{out} = U_1 - U_{out} - st_2 \cdot U_{out} - st_2 st_3 \cdot U_{out}$$
 * $$st_1 st_2 st_3 st_4 \cdot U_{out} = U_{in} - U_{out} - st_1 U_{out} - st_1 st_2 \cdot U_{out} - st_1 st_2 st_3 \cdot U_{out}$$
 * $$(s^4 t_1 t_2 t_3 t_4 + s^3 t_1 t_2 t_3 + s^2 t_1 t_2 + s t_1 + 1) \cdot U_{out} = U_{in}$$
 * $$\frac{U_{out}}{U_{in}} = \frac{1}{s^4 t_1 t_2 t_3 t_4 + s^3 t_1 t_2 t_3 + s^2 t_1 t_2 + s t_1 + 1}$$

From this, the time constants can be iteratively retrieved from the transfer function's coefficients.

The digital structure corresponding to the analog CIF is given in the following figure:



If the sampling rate is much higher than the time constants, the filter coefficients can be obtained directly from the CIF in the analog domain. Else, they can be found from the sampled system transfer function:


 * $$\frac{y}{x} = \frac{1}{

(z-1)^4 c_4 c_3 c_2 c_1 + (z-1)^3 c_3 c_2 c_1 + (z-1)^2 c_2 c_1 + (z-1) c_1 + 1 }$$ with $$c_i = \frac{t_i}{T}$$.

Leapfrog Filters
A leapfrog filter simulates the functionality of an analog ladder filter and provides a robust implementation of an all-pole transfer function. It can be shown that a large variation of coefficient values only leads to small variations of the transfer function, especially in the passband.

Taking the example of the following 4th order all-pole lowpass ladder filter,



one can write the following equations:
 * $$\begin{cases}

sC_1 \cdot U_1 = \frac{1}{R} \cdot (U_{in} - U_1) - I_2 \\ sL_2 \cdot I_2 = U_1 - U_3 \\ sC_3 \cdot U_3 = I_2 - I_4 \\ sL_4 \cdot I_4 = U_3 - R \cdot I_4 \\ U_{out} = R \cdot I_4 \end{cases}$$

Rewriting these equations in order to have only voltages on the left side gives:
 * $$\begin{cases}

U_1 = \frac{1}{sRC_1} (U_{in} - U_1 - RI_2) \\ R I_2 = \frac{R}{sL_2} (U_1 - U_3) \\ U_3 = \frac{1}{sRC_3} (R I_2 - R I_4) \\ R I_4 = \frac{R}{sL_4} (U_3 - R I_4) \\ U_{out} = R I_4 \end{cases}$$

This new set of equations shows that the filter can be implemented with a chain of 4 integrators with:
 * state variables having the form of $$w_i = U_i$$ or $$w_i = R I_i$$
 * time constants having the form of $$t_i = RC_i$$ or $$t_i = \frac{L_i}{R}$$

The resulting circuit is an integrator chain where each integrator output is brought back to the preceeding integrator input. Hence the name leapfrog.



This analog device can be implemented as a digital circuit by replacing the analog integrators with accumulators:


 * Digital_leapfrog_filter_order_4.svg

The filter coefficients can be derived from tables providing the $$R$$, $$C$$ and $$L$$ values for the selected filter functions and from the sampling period $$T$$. An interesting point is that the relative values of the coefficients set the shape of the transfer function (Butterworth, Chebyshev, …), whereas their amplitudes set the cutoff frequency. Dividing all coefficients by a factor of two shifts the cutoff frequency down by one octave, which corresponds to a factor of two.

Let us note that the replacement of the analog integrators with accumulators corresponds is a very primitive design technique. In terms of signal processing, this corresponds to simplify the Z-transform to $$z = 1 + sT$$, which are the two first terms of the Taylor series of $$z = exp(sT)$$. Nevertheless, this approximation is good enough for filters where the sampling frequency is much higher than the signal bandwidth.

The state space representation of the preceeding filtre can be written as:


 * $$\begin{array}{ccrcccccc}

z \cdot \begin{bmatrix}w_1\\w_2\\w_3\\w_4\end{bmatrix} & = & \begin{bmatrix}1-\frac{T}{t_1} & -\frac{T}{t_1} & 0 & 0\\\frac{T}{t_2} & 1 & -\frac{T}{t_2} & 0\\0 & \frac{T}{t_3} & 1 & -\frac{T}{t_3}\\0 & 0 & \frac{T}{t_4} & 1-\frac{T}{t_4}\end{bmatrix} & \cdot & \begin{bmatrix}w_1\\w_2\\w_3\\w_4\end{bmatrix} & + & \begin{bmatrix}\frac{T}{t_1}\\0\\0\\0\end{bmatrix} & \cdot & U_{in} \\ U_{out} & = & \begin{bmatrix}0 & 0 & 0 & 1\end{bmatrix} & \cdot & \begin{bmatrix}w_1\\w_2\\w_3\\w_4\end{bmatrix} & + & \begin{bmatrix}0\end{bmatrix} & \cdot & U_{in} \end{array}$$

From this equation set, one can write the A, B, C, D matrices as:


 * $$A = \begin{bmatrix}1-\frac{T}{t_1} & -\frac{T}{t_1} & 0 & 0\\\frac{T}{t_2} & 1 & -\frac{T}{t_2} & 0\\0 & \frac{T}{t_3} & 1 & -\frac{T}{t_3}\\0 & 0 & \frac{T}{t_4} & 1-\frac{T}{t_4}\end{bmatrix}$$


 * $$B = \begin{bmatrix}\frac{T}{t_1}\\0\\0\\0\end{bmatrix}$$


 * $$C = \begin{bmatrix}0 & 0 & 0 & 1\end{bmatrix}$$


 * $$D = \begin{bmatrix}0\end{bmatrix}$$

From this representation, signal processing tools such as SciPy, Octave or Matlab allow to plot the filter's frequency response or to examine its zeroes and poles.

A special case is the Butterworth 3rd order filter which has time constants with relative values of 1, 1/2 and 1. Due to that, this filter can be implemented in hardware without any multiplier, but using shifts instead.

Filters with poles and zeroes
Filters with poles and zeroes are best implemented in the form of a chain of biquadratic cells or by the parallel connection of two all-pass filters.

Chain of Second Order Sections
A second order section, often referred as biquad, implements a second order transfer function. The transfer function of a filter can be split into a product of transfer functions each associated to a pair of poles and possibly a pair of zeroes. If the transfer function's order is odd, then a first order section has to be added to the chain. This section is associated to the real pole and to the real zero if there is one.

The second order section's transfer function is given by:
 * $$H(z) = \frac{B(z)}{A(z)} = \frac$$

The most known biquad structures are shown next.

Direct-form 1 biquad
The following figure shows a direct form 1 biquad:

Direct-form 1 transposed biquad
The following figure shows a direct form 1 transposed biquad:

Direct-form 2 biquad
The following figure shows a direct form 2 biquad:

Direct-form 2 transposed biquad
The following figure shows a direct form 2 transposed biquad:

Obviously, the corresponding first order sections are done by removing the multipliers for coefficients $$a_2$$ and $$b_2$$, together with the associated delay element(s).

Parallel connection of allpass filters
Allpass filters are used to modify the phase of a signal's frequency components without altering their amplitude. They can be used to compensate for other undesired phase shifts, as for example in the design of close-to-linear phase IIR filters.

Additionally, the parallel connection of two allpass filters allows to implement any kind of transfer function. Indeed, at frequencies where the two branches show the same phase shift, the output will follow the input, but at the frequencies where the relative phase shift is 180°, the output will be zero. An example of this functionality is given in the family of Wave Digital Filters (WDFs).

- &larr; Digital Signal Processing &rarr;