# FIR Filters

Finite impulse response (FIR) filters are digital filters that have a finite impulse response. FIR filters operate only on current and past input values and are the simplest filters to design. FIR filters also are known as non-recursive filters, convolution filters, and moving average (MA) filters. FIR filters perform a convolution of the filter coefficients with a sequence of input values and produce an equally numbered sequence of output values. Equation A defines the finite convolution an FIR filter performs.

| (A)

where x is the input sequence to filter, y is the filtered sequence, and h is the FIR filter coefficients.

FIR filters have the following characteristics:

- FIR filters can achieve linear phase because of filter coefficient symmetry in the realization.
- FIR filters are always stable.
- FIR filters allow you to filter signals using the convolution. Therefore, you generally can associate a delay with the output sequence, as shown in the following equation:

  delay = (n – 1)/2 | (B)

  where n is the number of FIR filter coefficients.

The following figure shows a typical magnitude and phase response of an FIR filter compared to normalized frequency.

In the previous figure, the discontinuities in the phase response result from the discontinuities introduced when you use the absolute value to compute the magnitude response. The discontinuities in phase are on the order of pi. However, the phase is clearly linear.

## Taps

The terms tap and taps frequently appear in descriptions of FIR filters, FIR filter design, and FIR filtering operations. The following figure illustrates the process of tapping.

The previous figure represents an n-sample shift register containing the input samples [xi, xi – 1, …]. The term tap comes from the process of tapping off of the shift register to form each hkxi – k term in Equation A. Taps usually refers to the number of filter coefficients for an FIR filter.

## Designing FIR Filters

You design FIR filters by approximating the desired frequency response of a discrete-time system. The most common techniques approximate the desired magnitude response while maintaining a linear-phase response. Linear-phase response implies that all frequencies in the system have the same propagation delay.

Because FIR filters have ripple in the magnitude response, designing FIR filters has the following design challenges:

- Designing a filter with a magnitude response as close to the ideal as possible
- Designing a filter that distributes the ripple in a desired fashion

For example, a lowpass filter has an ideal characteristic magnitude response. A particular application might allow some ripple in the passband and more ripple in the stopband. The filter design algorithm must balance the relative ripple requirements while producing the sharpest transition band.

The most common techniques for designing FIR filters are windowing and the Parks-McClellan algorithm, also known as Remez Exchange.

### Designing FIR Filters by Windowing

Windowing is the simplest technique for designing FIR filters because of its conceptual simplicity and ease of implementation. Designing FIR filters by windowing takes the inverse FFT of the desired magnitude response and applies a smoothing window to the result. The smoothing window is a time domain window.

Complete the following steps to design a FIR filter by windowing.

1. Decide on an ideal frequency response.
2. Calculate the impulse response of the ideal frequency response.
3. Truncate the impulse response to produce a finite number of coefficients. To meet the linear-phase constraint, maintain symmetry about the center point of the coefficients.
4. Apply a symmetric smoothing window.

Truncating the ideal impulse response results in the Gibbs phenomenon. The Gibbs phenomenon appears as oscillatory behavior near cut-off frequencies in the FIR filter frequency response. You can reduce the effects of the Gibbs phenomenon by using a smoothing window to smooth the truncation of the ideal impulse response. By tapering the FIR coefficients at each end, you can decrease the height of the side lobes in the frequency response. However, decreasing the side lobe heights causes the main lobe to widen, resulting in a wider transition band at the cut-off frequencies.

Selecting a smoothing window requires a trade-off between the height of the side lobes near the cut-off frequencies and the width of the transition band. Decreasing the height of the side lobes near the cut-off frequencies increases the width of the transition band. Decreasing the width of the transition band increases the height of the side lobes near the cut-off frequencies.

Designing FIR filters by windowing has the following disadvantages:

- Inefficiency
- Windowing results in unequal distribution of ripple
- Windowing results in a wider transition band than other design techniques
- Difficulty in specification
- Windowing increases the difficulty of specifying a cut-off frequency that has a specific attenuation
- Filter designers must specify the ideal cut-off frequency
- Filter designers must specify the sampling frequency
- Filter designers must specify the number of taps
- Filter designers must specify the window type

Designing FIR filters by windowing does not require a large amount of computational resources. Therefore, windowing is the fastest technique for designing FIR filters. However, windowing is not necessarily the best technique for designing FIR filters.

### Designing Optimum FIR Filters Using the Parks-McClellan Algorithm

The Parks-McClellan algorithm, or Remez Exchange, uses an iterative technique based on an error criterion to design FIR filter coefficients. You can use the Parks-McClellan algorithm to design optimum, linear-phase, FIR filter coefficients. Filters you design with the Parks-McClellan algorithm are optimal because they minimize the maximum error between the actual magnitude response of the filter and the ideal magnitude response of the filter.

Designing optimum FIR filters reduces adverse effects at the cut-off frequencies. Designing optimum FIR filters also offers more control over the approximation errors in different frequency bands than other FIR filter design techniques, such as designing FIR filters by windowing, which provides no control over the approximation errors in different frequency bands.

Optimum FIR filters you design using the Parks-McClellan algorithm have the following characteristics:

- A magnitude response with the weighted ripple evenly distributed over the passband and stopband
- A sharp transition band

FIR filters you design using the Parks-McClellan algorithm have an optimal response. However, the design process is complex, requires a large amount of computational resources, and is much longer than designing FIR filters by windowing.

### Designing Equiripple FIR Filters Using the Parks-McClellan Algorithm

You can use the Parks-McClellan algorithm to design equiripple FIR filters. Equiripple design equally weights the passband and stopband ripple and produces filters with a linear phase characteristic.

You must specify the following filter characteristics to design an equiripple FIR filter:

- Cut-off frequency
- Number of taps
- Filter type, such as lowpass, highpass, bandpass, or bandstop
- Pass frequency
- Stop frequency

The cut-off frequency for equiripple filters specifies the edge of the passband, the stopband, or both. The ripple in the passband and stopband of equiripple filters causes the following magnitude responses:

- Passband—A magnitude response greater than or equal to 1
- Stopband—A magnitude response less than or equal to the stopband attenuation

For example, if you specify a lowpass filter, the passband cut-off frequency is the highest frequency for which the passband conditions are true. Similarly, the stopband cut-off frequency is the lowest frequency for which the stopband conditions are true.