Finite Impulse Response (Fir) : Objectives

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

DIGITAL SIGNAL PROCESSING

FINITE IMPULSE
CHAPTER 9
RESPONSE (FIR)

Objectives
After completing this chapter, you will be able to:

• Define how finite Impulse Response work


• Examine how FIR is used to improve the quality of a
signal
• Determine how FIR removes noise from signals

DEFINITION

In signal processing, a finite impulse response (FIR) filter is a filter whose impulse
response (or response to any finite length input) is of finite duration, because it settles to
zero in finite time. This is in contrast to infinite impulse response (IIR) filters, which may
have internal feedback and may continue to respond indefinitely (usually decaying).

The impulse response (that is, the output in response to a Kronecker delta input)
of an Nth-order discrete-time FIR filter lasts exactly N + 1 samples (from first nonzero
element through last nonzero element) before it then settles to zero.

FIR filters can be discrete-time or continuous-time, and digital or analog.

For a causal discrete-time FIR filter of order N, each value of the output sequence is a
weighted sum of the most recent input values:

70
DIGITAL SIGNAL PROCESSING

where:

• x [n] is the input signal,


• y [n] is the output signal,
• N is the filter order; an Nth-order filter has (N+ 1) terms on the right-hand side

• 𝑏𝑖 is the value of the impulse response at the i'th instant for 0≤ i ≤ N of an Nth
order FIR filter. If the filter is a direct form FIR filter then is also a coefficient of the
filter.
This computation is also known as discrete convolution.

The x [n – i] in these terms are commonly referred to as taps, based on the structure of
a tapped delay line that in many implementations or block diagrams provides the delayed
inputs to the multiplication operations. One may speak of a 5th order/6-tap filter, for
instance.

The impulse response of the filter as defined is nonzero over a finite duration. Including
zeros, the impulse response is the infinite sequence:

If a FIR filter is non-causal, the range of nonzero values in its impulse response can start
before n = 0, with the defining formula appropriately generalized.

PROPERTIES

A FIR filter has a number of useful properties which sometimes make it preferable to an
infinite impulse response (IIR) filter. FIR filters:

• Require no feedback. This means that any rounding errors are not compounded
by summed iterations. The same relative error occurs in each calculation. This also
makes implementation simpler.
• Are inherently stable, since the output is a sum of a finite number of finite multiples
of the input values, so can be no greater than Σ |𝑏𝑖 | times the largest value
appearing in the input.

71
DIGITAL SIGNAL PROCESSING

• Can easily be designed to be linear phase by making the coefficient sequence


symmetric. This property is sometimes desired for phase-sensitive applications,
for example data communications, seismology, crossover filters, and mastering.

The main disadvantage of FIR filters is that considerably more computation power
in a general-purpose processor is required compared to an IIR filter with similar sharpness
or selectivity, especially when low frequency (relative to the sample rate) cutoffs are
needed. However, many digital signal processors provide specialized hardware features
to make FIR filters approximately as efficient as IIR for many applications.

FREQUENCY RESPONSE

The filter's effect on the sequence x [n] is described in the frequency domain by the
convolution theorem:

and

where the added subscript denotes 2π-periodicity. Here 𝜔 represents frequency in


normalized units (radians/sample). The substitution = 2𝑓 , favored by many filter
designs programs, changes the units of frequency (f) to cycles/sample and the periodicity
to 1. When the x [n] sequence has a known sampling- rate 𝑓𝑠 samples/second, the substitute 𝜔 =
2𝑓/𝑓𝑠 changes the unit’s frequency (f) to cycles/second (hertz) and the periodicity to
𝜔 =  corresponds to a frequency of 𝑓 =
𝑓𝑠 1
𝑓𝑠 . The value 𝐻𝑧 = cycles/sample, which
2 2
is the Nyquist frequency

𝐻2 (𝜔) can also be expressed in terms of z-transform of the filter impulse response:

72
DIGITAL SIGNAL PROCESSING

FILTER DESIGN

A FIR filter is designed by finding the coefficients and filter order that meet certain
specifications, which can be in the time domain (e.g., a matched filter) and/or the
frequency domain (most common). Matched filters perform a cross-correlation between
the input signal and a known pulse shape. The FIR convolution is a cross-correlation
between the input signal and a time-reversed copy of the impulse response. Therefore,
the matched filter's impulse response is "designed" by sampling the known pulse-shape
and using those samples in reverse order as the coefficients of the filter.

When a particular frequency response is desired, several different design methods are
common:

1. Window design method


2. Frequency Sampling method
3. Least MSE (mean square error) method
4. Parks-McClellan method (also known as the Equiripple, Optimal, or Minimax
method). The Remez exchange algorithm is commonly used to find an optimal
equiripple set of coefficients. Here the user specifies a desired frequency
response, a weighting function for errors from this response, and a filter order N.
The algorithm then finds the set of (N+1) coefficients that minimize the maximum
deviation from the ideal. Intuitively, this finds the filter that is as close as possible
to the desired response given that only (N + 1) coefficients can be used. This
method is particularly easy in practice since at least one text includes a program
that takes the desired filter and N, and returns the optimum coefficients.
5. Equiripple FIR filters can be designed using the FFT algorithms as well. The
algorithm is iterative in nature. The DFT of an initial filter design is computed using
the FFT algorithm (if an initial estimate is not available, h[n]=delta[n] can be used).
In the Fourier domain or FFT domain the frequency response is corrected
according to the desired specs, and the inverse FFT is then computed. In the time-
domain, only the first N coefficients are kept (the other coefficients are set to zero).
The process is then repeated iteratively: the FFT is computed once again,
correction applied in the frequency domain and so on.

Software packages like MATLAB, GNU Octave, Scilab, and SciPy provide convenient
ways to apply these different methods.

73
DIGITAL SIGNAL PROCESSING

WINDOW DESIGN METHOD

In the window design method, one first designs an ideal IIR filter and then truncates
the infinite impulse response by multiplying it with a finite length window function. The
result is a finite impulse response filter whose frequency response is modified from that
of the IIR filter. Multiplying the infinite impulse by the window function in the time domain
results in the frequency response of the IIR being convolved with the Fourier transform
(or DTFT) of the window function. If the window's main lobe is narrow, the composite
frequency response remains close to that of the ideal IIR filter.

The ideal response is usually rectangular, and the corresponding IIR is a sinc
function. The result of the frequency domain convolution is that the edges of the rectangle
are tapered, and ripples appear in the passband and stopband. Working backward, one
can specify the slope (or width) of the tapered region (transition band) and the height of
the ripples, and thereby derive the frequency domain parameters of an appropriate
window function. Continuing backward to an impulse response can be done by iterating
a filter design program to find the minimum filter order. Another method is to restrict the
solution set to the parametric family of Kaiser windows, which provides closed form
relationships between the time-domain and frequency domain parameters. In general,
that method will not achieve the minimum possible filter order, but it is particularly
convenient for automated applications that require dynamic, on-the-fly, filter design.

The window design method is also advantageous for creating efficient half-band
filters, because the corresponding since function is zero at every other sample point
(except the center one). The product with the window function does not alter the zeros,
so almost half of the coefficients of the final impulse response are zero. An appropriate
implementation of the FIR calculations can exploit that property to double the filter's
efficiency.

LEAST MSE (MEAN SQUARE ERROR)


Method
To design FIR filter in the MSE sense, we minimize the mean square error
between the filter we obtained and the desired filter.

74
DIGITAL SIGNAL PROCESSING

Method:
(𝑁−1)
Given a N point FIR filter h[n] and r[n] = h [n + k], k = .
2

Step 1: Suppose h[n] even symmetric. Then, the discrete time Fourier transform r[n] of
is defined as

Step 2: Calculate mean square error.

Step 3: Minimize the mean square error by doing partial derivative of MSE with respect
to s[n]

Step 4: Change s[n] back to the presentation of h[n]

h[k] = s [0], h [ k + n] = s [n] / 2, h [k – n] = s [n] / 2, for n = 1, 2, 3, k, where k = (N – 1)/2

In addition, we can treat the importance of passband and stopband differently according
to our needs by adding a weighted function, W(f) Then, the MSE error becomes

75
DIGITAL SIGNAL PROCESSING

MOVING AVERAGE EXAMPLE

A moving average filter is a very simple FIR filter. It is sometimes called a boxcar
filter, especially when followed by decimation. The filter coefficients 𝑏0, … 𝑏𝑁 are found
via the following equation:

To provide a more specific example, we select the filter order: N = 2; The impulse
response of the resulting filter is:

Fig. (a) Block diagram of a simple FIR filter (2nd-order/3-tap filter in this case, implementing a moving
average)

Fig. (b) Pole–zero diagram of a second-order FIR filter

76
DIGITAL SIGNAL PROCESSING

Fig. (c) Magnitude and phase responses Fig. (d) Amplitude and phase responses

Fig. (a) shows the block diagram of a 2nd-order moving-average filter discussed below.
The transfer function is:

Fig. (b) shows the corresponding pole–zero diagram. Zero frequency (DC) corresponds
to (1, 0), positive frequencies advancing counterclockwise around the circle to the
Nyquist frequency at (−1, 0). Two poles are located at the origin, and two zeros are
located at

The frequency response, in terms of normalized frequency ω, is:

77
DIGITAL SIGNAL PROCESSING

Fig. (c) shows the magnitude and phase components of 𝐻(𝑒 𝑗ω ). But plots like these can
also be generated by doing a discrete Fourier transform (DFT) of the impulse response.
And because of symmetry, filter design or viewing software often displays only the [0, π]
region. The magnitude plot indicates that the moving-average filter passes low
frequencies with a gain near 1 and attenuates high frequencies, and is thus a crude low-
pass filter. The phase plot is linear except for discontinuities at the two frequencies where
the magnitude goes to zero. The size of the discontinuities is π, representing a sign
reversal. They do not affect the property of linear phase. That fact is illustrated in Fig. (d).

Reference:

• https://en.wikipedia.org/wiki/Finite_impulse_response#Window_design_m
ethod
• http://supercdms.tamu.edu/tobackgroup/work/softprojects/triggeractive/fir
mwareplan/fir.html

Video Tutorial Link:


Understanding Finite Impulse Response (FIR) Filters

• https://www.youtube.com/watch?v=jL_1DwUMD2w
Overview of FIR and IIR Filters

• https://www.youtube.com/watch?v=9yNQBWKRSs4

78

You might also like