next up previous contents
Next: FIR Filters Up: Digital Filters Previous: Digital Filters   Contents

IIR Filters

IIR filters (aka recursive filter) are typically designed by designing an analog filter and then converting to an equivalent digital filter. This typically works well, with some exceptions. For example, if the cutoff frequency is nearly half the sampling frequency or nearly zero, the filter behavior is usually less than ideal.

Figure 3 shows the problems that can arise with cutoff frequencies very close to the Nyquist frequency. The digital filter deviates significantly from its analog counterpart. This an inherent limitation of the process that is used to convert the analog filter to digital. If you are in this situation, the suggestion is to either design a digital filter directly (instead of converting an analog prototype) or increase the sampling rate.

Figure 4 shows the problems that can arise with cutoff frequencies very close to zero (relative to the sampling rate). For very small cutoff frequencies, the filter becomes numerically unstable.

For those interested in the details of exactly why the low frequency problems happens, we need to understand round-off errors in float point arithmetic. The numerical precision of a floating point operation is usually characterized by the value epsilon, which is roughly defined as the maximum roundoff error when rounding down to 1. This value is stored by matlab in the pre-defined variable eps. For my machine, eps= 2.2204e-16. To see this in action type (1+1e-16)-1 at your matlab prompt. Clearly, the answer should be 1e-16, but my machine returns 0. For another example, try (1+3e-16)-1. The answer should be 3e-16, but matlab returns 2.2204e-16. So basically, if two numbers differ by more than about 16 orders of magnitude, we cannot compute the addition correctly.

With that in mind, let us examination the filter coefficients generated by [b,a] = butter(2, fc/(Fs/2)) in Table 1. Recall that the basic form of a filter is a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-na). In this example, the inputs x are on the order of 1, the outputs y are on the order of 1, and the coefficients a are on the order of 1 - 10. So for the cutoff frequency 0.0002, the worst case would be that we add a value of about 6 to a value of about 9e-15. Try (6+9e-15)-6 at your matlab prompt. I get 8.88e-15. Pretty close, but there is some roundoff error. Now look at cutoff frequency 0.0001. Now we need to try (6+6e-16)-6. I get 8.88e-16. Relative to the expected answer, that's a pretty big error. Since the IIR filter uses feedback, errors like this get fed back into the computation and cause the problems seen in the graph.

If you ever find yourself in this type of situation where you must use a very low cutoff frequency, the best option is to decimate your data. In other words, downsample it to a lower frequency first. That way, the same physical cutoff frequency is a much larger percentage of the sampling frequency and the calculations can proceed. Another option would be to use a lower order IIR filter, or to use an FIR filter.

Figure 3: Comparison of frequency response between an analog lowpass filter and its digitized equivalent (4th order butterworth filters). For low cutoff frequencies (relative to sampling rate) the comparison is good. For high cutoff frequencies, the comparison is poor.
Image analog_vs_digital_freqs

Figure 4: Time domain response of digital butterworth filters very low cutoff frequencies (relative to sampling frequency). At extremely low cutoff frequencies, the filter response becomes numerically unstable and does not give the correct response.
\includegraphics[bb=0bp 195bp 612bp 600bp,clip]{butter_low_freq}


Table: Filter coefficients for the different cutoff frequencies in Figure 3
fc/(Fs/2) a b
0.00113 1.0000 -3.9907 5.9721 -3.9721 0.9907 9.997e-12 3.999e-11 5.998e-11 3.999e-11 9.997e-12
0.0005 1.0000 -3.9958 5.9876 -3.9876 0.9958 3.911e-13 1.564e-12 2.346e-12 1.564e-12 3.911e-13
0.0002 1.0000 -3.9983 5.9950 -3.9950 0.9983 9.732e-15 3.893e-14 5.839e-14 3.893e-14 9.732e-15
0.0001 1.0000 -3.9991 5.9975 -3.9975 0.9991 6.085e-16 2.434e-15 3.651e-15 2.434e-15 6.085e-16
0.00005 1.0000 -3.9995 5.9987 -3.9987 0.9995 3.804e-17 1.521e-16 2.282e-16 1.521e-16 3.804e-17


There are other design methods for IIR filters that do not involve starting with an analog prototype. See, for example, the yulewalk function in Matlab [9].


next up previous contents
Next: FIR Filters Up: Digital Filters Previous: Digital Filters   Contents " . $row['Name'] . " Posted on " . $row['DateTime']; echo "
"; echo $row['Comment']; echo "

"; } echo "
"; ?> Leave a comment on this page:

Name: (optional)
To prove you are not a robot, what is 2+3?

Creative Commons License
This work by Daniel Kiracofe (daniel dot kiracofe at gmail dot com) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License./' $I