Iowa Hills Software   Digital and Analog Filters 
FIR Filter Design      Home

This FIR filter design program is free. It uses three separate methods to synthesize filters, Parks McClellan, rectangular window impulse, and frequency domain sampling. It will synthesize linear phase or minimum phase filters and fractional group delay adjustments can also be made. It is available on the Download Page.

The program does not synthesize Hilbert filters or Differentiators. These and other types of specialized band pass filters are available from our Hilbert Filters program (also free).

For a custom magnitude response, the program allows the user to define a filter at several points in the frequency domain in a text file. The program then reads the file and calculates the corresponding FIR coefficients via the Inverse Fourier Transform.

This program has two test benches. The first allows you to test the filter with a square wave or sine wave, but also allows you to read in a signal to be filtered. The program will display both the filtered and unfiltered signal in both the frequency and time domains.

The program also has an audio test bench that allows you to apply the filter to a wav file which allows you to hear the affects of filtering.

If you are more interested in writing your own FIR program, see the Example C Code Page for the Parks McClellan and windowed FIR filter algorithms. C code to implement an FIR filter is also given there.

 

FIR Design Methods
There are numerous methods available for synthesizing an FIR filter, and as we said above, this program utilizes three of them.

Parks McClellan
This algorithm minimizes the error in the pass and stop bands by utilizing the Chebyshev approximation. It is a variation on the Remez exchange algorithm, modified specifically for FIR filter design. See this  Wikipedia article.

It is considered by many to be a standard for FIR filter design, but it is only included in this program for comparison purposes. In other words, it allows you to compare filters from the other methods to this so called standard. You will find that, in general, the simpler methods generate superior filters.

 

Rectangular Window Impulse Response.
This is the canonical method for FIR design in the sense that it is both easy to understand and the simplest to implement. It is first method taught in most textbooks.

The basic idea is to use the Inverse Fourier Transform to obtain the (time domain) impulse response of an ideal frequency domain response (i.e. a rectangular window), as shown here for a low pass filter. This Brunel University article describes the method quite nicely for the various type of filters.

SincDerivation.png

This shows the result of this method for a 50 tap low pass filter with Ωc = 0.2. In general, this method, by itself, does not generate an acceptable filter. In general, a time domain window such as the Kaiser must be applied to the impulse response to reduce the side lobes. This secondary operation is not required of filters generated by the Parks McClellan routine.

This method has the distinct advantage however of utter simplicity. This method, including a window, requires as little as ten lines of code to implement. This is important when a filter must be generated on the fly. By contrast, the Parks McClellan routine requires more than 500 lines of code.

WindowedSincResponse.png

 

Sampled Frequency Domain
An alternative to the method just described is to sample the ideal frequency domain response and then do a Discrete Inverse Fourier Transform. This approach, described here, eliminates the need to carry out the Fourier integral, which may not be simple. As an example, we show the ideal frequency response for a 7 pole Inverse Chebyshev filter. The required integration to obtain this filter's impulse response is nontrivial.

When sampled however, and processed in discrete time, we can generate the FIR filter shown here. Here are the 50 FIR Coefficients for this filter.

FreqSamplingDerivation.png

In general, sampling the frequency domain allows us to generate any filter response imaginable, but this does not mean that all possible filter responses are desirable in a FIR format. To point, the Inv Chebyshev filter shown here is a rather poor FIR filter simply because a much better filter can be achieved with fewer taps if we start with a better prototype such as the rectangle. Butterworth and Chebyshev filters are even worse than this example, again, because of the excessive number of taps required to generate those responses.

To realize this methods clear advantages, we must start by sampling a suitable frequency domain model, such as the Raised Cosine shown here. f(n) = 0.5 + 0.5· cos(2·π·n/( (1-α)·N) ) ).

Raised Cosine Window.png

The advantage to using this model is that it is infinitely adjustable between a rectangle and a raised cosine which allows us to control the amount of distortion caused by the filter. Sharp filters, generated by rectangular windows, have significant amounts of overshoot and ringing in their step response, which is unacceptable in many applications. The Raised Cosine allows us to adjust the amount of distortion inevitably caused by all filters to an acceptable level.

This shows an example of the effect of Alpha on the filter's frequency and time domain responses.RaisedCosineExample.png

 

Kaiser and Sinc Windows
This program has two time domain windows to choose from. The first is the Kaiser, which is well documented, and needs no explanation here. The second is the Sinc window. Strangely, it is difficult to find a discussion of this window in any textbook or on the web.

Intuitively, it would seem that the sinc function ( sin(x) / x ) would be the ideal window for FIR filters, and indeed, the user will find that it performs as good as, or better than the Kaiser in most situations. Of course, what is "better" will depend on the design requirements.

Here are two filter examples, a low pass and a band pass, designed with both windows. In both cases the Kaiser and Sinc windows were adjusted so that the filters would have comparable pass bands. These two plots show a general truth about these windows. The Kaiser gives better close in stop band rejection, and the Sinc does better further out.

24 Tap Sinc Kaiser Comparison

71 Tap BPF Sinc Kaiser Comparison.png

 

Screen shot of the free FIR Filter program.  Available on the Download PageFIR Filter Designer Screen Shot.png
Example coefficients (for the filter shown).

 

Screen shot of the program's test bench.
FIR Test Bench Screen Shot.png

This is essentially the same test bench as the IIR Filter test bench. This screen shot shows how the filter affects a square wave. The program can also read in a user defined signal for filtering. The Center and Span buttons are sliders which allow the user to easily zoom in and move across a signal, much like a digital oscilloscope.

 

Screen shot of the Audio Test Bench.
The Audio Test Bench allows you to filter a wav file, and play the results.

SoundForm Screen Shot.png

 

Copyright 2013  Iowa Hills Software