# FIR Filters using the Fourier Series.

Cuthbert Nyack
This is historically the first approach to FIR filters and can still be used when combined with windows.

First the continuous frequency response A(f) is decided ie LP, HP etc.
Next the Fourier series of this frequency response is found using the equation below. This is a discrete function in the time domain and is the impulse response I(k) of the filter, fs is the sampling frequency. The impulse response I(k) is of infinite length. In order to be able to realize the filter, the impulse response must be truncated. If N is the desired length(also referred to as the number of taps of the filter) of the filter then
-(N - 1)/2 <= k <= ((N - 1)/2. This truncation means that the impulse response of the filter is of finite length and the filter is referred to as an FIR filter.

For verification the frequency response of the system with the impulse response is calculated using the Discrete Time Frequency Transform.
For implementation the impulse response is shifted to the right so it starts from time zero. There are 4 different types of FIR filters described in the literature. In these pages only Type 1, (N is odd and the impulse response is symmetric) is considered. This is the most flexible type.

The result is illustrated below. A(f) is a low pass filter frequency response shown by the yellow line. I(k) is the impulse response shown in pink. The magnitude of the frequency response calculated from I(k) using the DTFT is shown in red(linear scale) and green(log scale). Because the impulse response used contains only a finite number of terms, then the frequency response contains ripples. This is the frequency domain equivalent of the Gibbs phenomemon and limits the attenuation which is achievable in the stop band. The magnitude of the frequency response is symmetric about half the sampling frequency and the impulse response is symmetric about its maximum value. The sharp drops to zero in the stop band indicates that the transfer function has zeros on the unit circle in the stop band. Although the green curve does not look like it, it is in fact nothing more than a logarithmic plot of the Gibbs phenomenon shown by the red curve. The output y(n) from the filter can be calculated from the input x(n) and the impulse response I(m) by the following equation. This is a convolution equation. The block diagram below containing delay elements, multipliers and adders can be used to realize the filter. THis is essentially a circuit for calculating the convolution sum. For a symmetric impulse response, it is possible to reduce the diagram below, so the number of multipliers is reduced by 2. The circuit does not use any feedback, so is described as Non Recursive and is always stable. For long filter lengths it is more efficient to realize the filter in the frequency domain using the FFT. Analytical expressions can be fould for some simple cases. For low pass with cut off frequency a the impulse response is:- For high pass with cut off frequency a the impulse response is:- For band pass with cut off frequencies a and b the impulse response is:- For band stop with cut off frequencies a and b the impulse response is:- FIR filters have 2 important features. They contain only zeros (poles which do not affect the frequency response are included at the origin to make the filter causal) and they are linear phase filters. The latter being a consequence of the symmetric impulse response.
When summing the Fourier series with a finite number of terms, a convergence factor may be added. This factor reduces the contribution of the higher harmonics in order to get a time function where the Gibbs phenomenon is minimised. Here a similar problem arises. In order to get a frequency response which minimises the effect of the Gibbs phenomenon, then a 'convergence' factor has to be added to reduce the effect of the higher terms in the impulse response. This factor is called a window and the shape of this window is the main issue in the design of FIR filters using the Fourier series.

In the following applets, the frequency and impulse respose as well as the phase response and zero locations are shown for the different FIR filter types. The applets are only approximate and are here for illustrative and educational purposes. The filters they produce are not accurate enough for practical applications.