The FIR Digital Filter Design applet designs an FIR (Finite Impulse Response) digital filter, based on the following settings chosen by the user:
A sampling rate of 8000 samples/s is assumed, corresponding to maximum signal frequency of 4000 Hz.
To design a filter, choose appropriate settings for each of the parameters listed above (or use the default settings) and click the Design button. The applet determines the coefficients of the required filter, and displays estimated values for the transition bandwidth and stopband attenuation achieved by the filter.
Click the Frequency response button to plot the gain frequency response curve for the filter.
The frequency (horizontal) scale is linear and extends from 0 to 4000 Hz. The filter gain is plotted on the vertical axis on a logarithmic (decibel) scale. The filter gain is normalised to a maximum of 0 dB (unity gain), and this is the gain value at the top of the frequency response plot. The Minimum plot gain can be set to -10, -50, -100 or -200 dB (default is -100 dB) to allow varying levels of detail in the frequency response plot to be examined. The scale interval on the gain axis varies from 1 dB per division on the -10 dB setting to 20 dB per division on the -200 dB setting.
Click the Coefficients button to display the values of the filter coefficients. If you want to save the coefficient values to disc (in text form), you can select the text and copy and paste to any text editor, then save the text to disc. (You have to do this manually because a Java applet isn't allowed read/write access to your drive).
A filter is usually specified in terms of its frequency response. The commonest requirement is that the filter should pass frequency components of the input signal lying within a certain band (the passband), and stop, or at least attenuate, components within the stopband(s).
The three filter types which can be designed by the applet are as follows.
The design specification for an FIR filter may fix parameters such as the stopband attenuation (the minimum tolerable amount of attenuation within the stopband, expressed in dB) and the transition bandwidth (the maximum tolerable width of the transition band - the frequency band separating the passband from the stopband - expressed in Hz).
In the Window design method for an FIR filter, there are two main variables which can be chosen to try to meet the filter specification:
The choice of window function is determined mainly by the stopband attenuation requirement. The middle column in the table below indicates the minimum amount of stopband attenuation which can be attained when the filter is designed using various window functions.
| Window Function | Minimum Stopband Attenuation (dB) |
Transition Bandwidth |
|---|---|---|
| Rectangular | 21 | 1·84 fN / N |
| Hanning | 44 | 6·22 fN / N |
| Hamming | 54 | 6·64 fN / N |
| Blackman | 74 | 11·13 fN / N |
Thus, for example, if the filter is required to give an attenuation of at least 50 dB throughout the stopband, a Hamming window function could be used. (A Blackman window would more than satisfy the specification, but would need a much higher order filter to meet the transition bandwidth requirement).
The filter order primarily determines the width of the transition band: the higher the order, the narrower is the transition between the passband and stopband, giving a sharper cutoff in the frequency response.
The last column of the table above shows the transition bandwidth obtained for each window function for a given filter order N with a maximum system frequency fN (in this case, fN = 4000 Hz).
The table shows that for a given filter order, the transition bandwidth of a filter based on the Blackman window, for example, is nearly twice that of a filter based on the Hamming window.
The transition bandwidth (and hence the sharpness of the filter cutoff) can be improved by increasing the order of the filter. In practice, however, there is an upper limit to the filter order that can be implemented, dictated by the amount of program and data memory available and the speed of the processor in relation to the rate at which the input signal is sampled.
The applet uses the window or Fourier transform method, a widely-used approach to FIR filter design. The theoretical basis of the method is simple and elegant. If the discrete Fourier transform (DFT) is applied to a function representing the required filter frequency response, we obtain the impulse response of the required filter. Since the sampled impulse response values for an FIR filter correspond to the sequence of filter coefficients, we therefore obtain the required filter coefficients directly.
Unfortunately, the filter obtained by this technique suffers from two main drawbacks:
A "non-causal" filter is one which requires not only the current and previous input values (xn, xn-1, xn-2, xn-3, ...) but also future input values (xn+1, xn+2, xn+3, ...). Non-causal filters can be used where a complete record of the sampled input signal is available, but if the filter is operating in real time, future input values are unknown.
To make the filter causal, so that it uses only the current and previous input values, the filter coefficients must be "time-shifted". This effectively means delaying the input samples by a sufficient number of sampling intervals; as a result, the filter output is delayed by the same length of time. In most cases, this is not a serious problem.
The fact that the order of the filter is infinite is, however, rather more of a difficulty. An infinite order means that an infinite number of terms must be calculated to obtain the filter output; clearly this is not practical. If the filter is to operate in real time, the maximum order is usually limited by the need for the processor to perform the filtering calculations within a specified time to allow it to keep up with the signal data coming in every sampling interval.
To restrict the order of the filter to a finite value, we must again make some adjustments to the filter coefficients. The technique used is to multiply the sequence of filter coefficients by a tapered window function of a finite width. The simplest window function is the rectangular window. Multiplying the sequence of filter coefficients by a rectangular window corresponds to truncating (chopping off) the sequence after a certain number of terms.
The drawback of truncating the filter coefficients to produce a "cut-down" finite-order version of the filter is that it no longer has the ideal frequency response originally used as the basis for designing the filter. Instead of a perfectly flat passband in the gain frequency response curve, ripples tend to appear; instead of an infinitely sharp cutoff at the design cutoff frequency, there is a more gradual transition between the passband and stopband. In the stopband itself, the filter gain is no longer exactly zero, but has small nonzero values following an oscillating curve, with peaks in the gain at certain points in the stopband. To make the filter frequency response approximate more closely to the ideal, the width of the window must be increased to include more coefficients, i.e. the order of the filter has to be increased.
Various window functions can be used in the design of FIR filters. Each window function has its good and bad points. As indicated earlier, the choice of window function determines the minimum amount of attenuation provided in the stopband; the rectangular window, for example, has rather poor stopband performance, while the Blackman window gives much better stopband attenuation. The other side of the coin is that the Blackman filter has rather poor transition band performance, while the rectangular window gives a sharp cutoff (narrow transition band). To achieve a given transition band performance with a Blackman window, for example, a much higher filter order is needed than would be the case with the rectangular window. These points can be demonstrated clearly using the applet.
Suppose we need to design an FIR filter to meet the following specification, based on a sampling rate of 8000 samples/s.
The specification requires a low pass filter with a passband from 0 to 1000 Hz.
Referring to the table of window functions above, we see that a Hamming window function would meet the requirement for at least 50 dB attenuation in the stopband.
The transition band extends from the passband edge at 1000 Hz to the stopband edge at 1500 Hz and so is 500 Hz wide. For the Hamming window, the required filter order N can be found from the formula
Transition bandwidth = 6·64 fN / N
(see table above). With a transition bandwidth of 500 Hz, we get N = 53·12. Rounding this up to the next even number gives the required order N = 54.
Try designing a filter based on these settings and display the frequency response (with the minimum plot gain set to -100 dB) to confirm that it meets the specification.
Back to FIR filter design applet: Java 1.02 version | Java 1.1 version