Skip to content Skip to navigation

Connexions

You are here: Home » Content » FIR Digital Filters

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of a lens

      Lenses

      A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

      What is in a lens?

      Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

      Who can create a lens?

      Any individual Connexions member, a community, or a respected organization.

    • External bookmarks
  • E-mail the author

Recently Viewed

FIR Digital Filters

Module by: C. Sidney Burrus

There are two types of linear, time-invariant digital filters. We will investigate digital filters with a finite-duration impulse response (FIR) in this section and those with an infinite-duration impulse response (IIR) in another document. FIR filters have characteristics that make them useful in many applications Entry 3, Entry 2.

  1. FIR filters can achieve an exactly linear phase frequency response
  2. FIR filters cannot be unstable.
  3. FIR filters are generally less sensitive to coefficient round-off and finite-precision arithmetic than IIR filters.
  4. FIR filters design methods are generally linear.
  5. FIR filters can be efficiently realized on general or special-purpose hardware.

However, frequency responses that need a rapid transition between bands and do not require linear phase are often more efficiently realized with IIR filters.

It is the purpose of this section to examine and evaluate these characteristics which are important in the design of the four basic types of linear-phase FIR filters.

Because of the usual methods of implementation, the Finite Impulse Response (FIR) filter is also called a nonrecursive filter or a convolution filter. From the time-domain view of this operation, the FIR filter is sometimes called a moving-average or running-average filter. All of these names represent useful interpretations that are discussed in this section; however, the name, FIR, is most commonly seen in filter-design literature and is used in these notes.

The duration or sequence length of the impulse response of these filters is by definition finite; therefore, the output can be written as a finite convolution sum by

y ( n ) = m = 0 N - 1 h ( m ) x ( n - m ) y ( n ) = m = 0 N - 1 h ( m ) x ( n - m ) (1)

where nn and mm are integers, perhaps representing samples in time, and where x(n)x(n) is the input sequence, y(n)y(n) the output sequence, and h(n)h(n) is the length-N impulse response of the filter. With a change of index variables, this can also be written as

y ( n ) = m = n n - N + 1 h ( n - m ) x ( m ) . y ( n ) = m = n n - N + 1 h ( n - m ) x ( m ) . (2)

If the FIR filter is interpreted as an extension of a moving sum or as a weighted moving average, some of its properties can easily be seen. If one has a sequence of numbers, e.g., prices from the daily stock market for a particular stock, and would like to remove the erratic variations in order to discover longer term trends, each number could be replaced by the average of itself and the preceding three numbers, i.e., the variations within a four-day period would be “averaged out" while the longer-term variations would remain. To illustrate how this happens, consider an artificial signal x(n)x(n) containing a linear term, K1nK1n, and an undesired oscillating term added to it, such that

x ( n ) = K 1 n + K 2 cos ( π n ) x ( n ) = K 1 n + K 2 cos ( π n ) (3)

If a length-2 averaging filter is used with

h ( n ) = 1 / 2 for n = 0 , 1 0 otherwise h ( n ) = 1 / 2 for n = 0 , 1 0 otherwise (4)

it can be verified that, after two outputs, the output y(n)y(n) is exactly the linear term x(n)x(n) with a delay of one half sample interval and no oscillation.

This example illustrates the basic FIR filter-design problem: determine N, the number of terms for h(n)h(n), and the values of h(n)h(n) for achieving a desired effect on the signal. The reader should examine simple examples to obtain an intuitive idea of the FIR filter as a moving average; however, this simple time-domain interpretation will not suffice for complicated problems where the concept of frequency becomes more valuable.

Frequency-Domain Description of FIR Filters

The output of a length-N FIR filter can be calculated from the input using convolution.

y ( n ) = k = 0 N - 1 h ( k ) x ( n - k ) y ( n ) = k = 0 N - 1 h ( k ) x ( n - k ) (5)

and the transfer function of an FIR filter is given by the z-transform of the finite length impulse response h(n)h(n) as

H ( z ) = n = 0 N - 1 h ( n ) z - n . H ( z ) = n = 0 N - 1 h ( n ) z - n . (6)

The frequency response of a filter, is found by setting z=ejωz=ejω, which is the same as the discrete-time Fourier transform (DTFT) of h(n)h(n), which gives

H ( ω ) = n = 0 N - 1 h ( n ) e - j ω n H ( ω ) = n = 0 N - 1 h ( n ) e - j ω n (7)

with ωω being frequency in radians per second. Strictly speaking, the exponent should be -jωTn-jωTn where TT is the time interval between the integer steps of nn (the sampling interval). But to simplify notation, it will be assumed that T=1T=1 until later in the notes where the relation between nn and time is more important. Also to simplify notation, H(ω)H(ω) is used to represent the frequency response rather that H(ejω)H(ejω). It should always be clear from the context whether HH is a function of zz or ωω.

This frequency-response function is complex-valued and consists of a magnitude and a phase. Even though the impulse response is a function of the discrete variable nn, the frequency response is a function of the continuous-frequency variable ωω and is periodic with period 2π2π. This periodicity is easily shown by

H ( w + 2 π ) = n = 0 N - 1 h ( n ) e - j ( w + 2 π ) n = n = 0 N - 1 h ( n ) e - j ω n e - j 2 π n = H ( ω ) H ( w + 2 π ) = n = 0 N - 1 h ( n ) e - j ( w + 2 π ) n = n = 0 N - 1 h ( n ) e - j ω n e - j 2 π n = H ( ω ) (8)

with frequency denoted by ωω in radians per second or by ff in Hz (hertz or cycles per second). These are related by

ω = 2 π f ω = 2 π f (9)

An example of a length-5 filter might be

h ( n ) = 2 , 3 , 4 , 3 , 2 h ( n ) = 2 , 3 , 4 , 3 , 2 (10)

with a frequency-response plot shown over the base frequency band (0<ω<π0<ω<π or 0<f<10<f<1 in Figure 1. To illustrate the periodic nature of the total frequency response, Figure 2 shows the response over a wider set of frequencies.

Figure 1: Frequency Response of Example Filter
fig51.png
Figure 2: Frequency Response of Example Filter over a wide band of frequencies
fig51a.png

The Discrete Fourier Transform (DFT) can be used to evaluate the frequency response at certain frequencies. The DFT Entry 1 of the length-N impulse response h(n)h(n) is defined as

C ( k ) = n = 0 N - 1 h ( n ) e - j 2 π n k / N k = 0 , 1 , . . . , N - 1 C ( k ) = n = 0 N - 1 h ( n ) e - j 2 π n k / N k = 0 , 1 , . . . , N - 1 (11)

which, when compared to (Equation 7), gives

C ( k ) = H ( ω k ) = H ( 2 π k / N ) k = 0 , 1 , . . . , N - 1 C ( k ) = H ( ω k ) = H ( 2 π k / N ) k = 0 , 1 , . . . , N - 1 (12)

for ωk=2πk/Nωk=2πk/N.

This states that the DFT of h(n)h(n) gives NN samples of the frequency-response function H(ω)H(ω). This sampling at NN points may not give enough detail, and, therefore, more samples are needed. Any number of equally spaced samples can be found with the DFT by simply appending L-NL-N zeros to h(n)h(n) and taking an L-length DFT. This is often useful when an accurate picture of all of H(ω)H(ω) is required. Indeed, when the number of appended zeros goes to infinity, the DFT becomes the discrete-time Fourier transform of h(n)h(n).

The fact that the DFT of h(n)h(n) is a set of NN samples of the frequency response suggests a method of designing FIR filters in which the inverse DFT of NN samples of a desired frequency response gives the filter coefficients h(n)h(n). That approach is called frequency sampling and is developed in another section.

Linear-Phase FIR Filters

A particular property of FIR filters that has proven to be very powerful is that a linear phase shift for the frequency response is possible. This is especially important to time domain details of a signal. The spectrum of a signal contains the individual frequency domain components separated in frequency. The process of filtering usually involves passing some of these components and rejecting others. This is done by multiplying the desired ones by one and the undesired ones by zero. When they are recombined, it is important that the components have the same time domain alignment as they originally did. That is exactly what linear phase insures. A phase response that is linear with frequency keeps all of the frequency components properly registered with each other. That is especially important in seismic, radar, and sonar signal analysis as well as for many medical signals where the relative time locations of events contains the information of interest.

To develop the theory for linear phase FIR filters, a careful definition of phase shift is necessary. If the real and imaginary parts of H(ω)H(ω) are given by

H ( ω ) = R ( ω ) + j I ( ω ) H ( ω ) = R ( ω ) + j I ( ω ) (13)

where j=-1j=-1 and the magnitude is defined by

| H ( ω ) | = R 2 + I 2 | H ( ω ) | = R 2 + I 2 (14)

and the phase by

Φ ( ω ) = arctan ( I / R ) Φ ( ω ) = arctan ( I / R ) (15)

which gives

H ( ω ) = | H ( ω ) | e j Φ ( ω ) H ( ω ) = | H ( ω ) | e j Φ ( ω ) (16)

in terms of the magnitude and phase. Using the real and imaginary parts is using a rectangular coordinate system and using the magnitude and phase is using a polar coordinate system. Often, the polar system is easier to interpret.

Mathematical problems arise from using |H(ω)||H(ω)| and Φ(ω)Φ(ω), because |H(ω)||H(ω)| is not analytic and Φ(ω)Φ(ω) not continuous. This problem is solved by introducing an amplitude function A(ω)A(ω) that is real valued and may be positive or negative. The frequency response is written as

H ( ω ) = A ( ω ) e j Θ ( ω ) H ( ω ) = A ( ω ) e j Θ ( ω ) (17)

where A(ω)A(ω) is called the amplitude in order to distinguish it from the magnitude |H(ω)||H(ω)|, and Θ(ω)Θ(ω) is the continuous version of Φ(ω)Φ(ω). A(ω)A(ω) is a real, analytic function that is related to the magnitude by

A ( ω ) = ± | H ( ω ) | A ( ω ) = ± | H ( ω ) | (18)

or

| A ( ω ) | = | H ( ω ) | | A ( ω ) | = | H ( ω ) | (19)

With this definition, A(ω)A(ω) can be made analytic and Θ(ω)Θ(ω) continuous. These are much easier to work with than |H(ω)||H(ω)| and Φ(ω)Φ(ω). The relationship of A(ω)A(ω) and |H(ω)||H(ω)|, and of Θ(ω)Θ(ω) and Φ(ω)Φ(ω) are shown in Figure 3.

Figure 3: Magnitude and Amplitude Frequency Responses and Corresponding Phase Frequency Response of Example Filter
fig52.png

To develop the characteristics and properties of linear-phase filters, assume a general linear plus constant form for the phase function as

Θ ( ω ) = K 1 + K 2 ω Θ ( ω ) = K 1 + K 2 ω (20)

This gives the frequency response function of a length-N FIR filter as

H ( ω ) = n = 0 N - 1 h ( n ) e - j ω n = e - j ω M n = 0 N - 1 h ( n ) e j ω ( M - n ) H ( ω ) = n = 0 N - 1 h ( n ) e - j ω n = e - j ω M n = 0 N - 1 h ( n ) e j ω ( M - n ) (21)

and

H ( ω ) = e - j ω M [ h 0 e j ω M + h 1 e j ω ( M - 1 ) + + h N - 1 e j ω ( M - N + 1 ) ] H ( ω ) = e - j ω M [ h 0 e j ω M + h 1 e j ω ( M - 1 ) + + h N - 1 e j ω ( M - N + 1 ) ] (22)

Equation 22 can be put in the form of

H ( ω ) = A ( ω ) e j ( K 1 + K 2 ω ) H ( ω ) = A ( ω ) e j ( K 1 + K 2 ω ) (23)

if MM (not necessarily an integer) is defined by

M = N - 1 2 M = N - 1 2 (24)

or equivalently,

M = N - M - 1 M = N - M - 1 (25)

Equation 22 then becomes

H ( ω ) = e - j ω M [ ( h 0 + h N - 1 ) cos ( ω M ) + j ( h 0 - h N - 1 ) sin ( ω M ) + ( h 1 + h N - 2 ) cos ( ω ( M - 1 ) ) + j ( h 1 - h N - 2 ) sin ( w ( M - 1 ) ) + ] H ( ω ) = e - j ω M [ ( h 0 + h N - 1 ) cos ( ω M ) + j ( h 0 - h N - 1 ) sin ( ω M ) + ( h 1 + h N - 2 ) cos ( ω ( M - 1 ) ) + j ( h 1 - h N - 2 ) sin ( w ( M - 1 ) ) + ] (26)

There are two possibilities for putting this in the form of (Equation 23) where A(ω)A(ω) is real: K1=0K1=0 or K1=π/2K1=π/2. The first case requires a special even symmetry in h(n)h(n) of the form

h ( n ) = h ( N - n - 1 ) h ( n ) = h ( N - n - 1 ) (27)

which gives

H ( ω ) = A ( ω ) e - j M ω H ( ω ) = A ( ω ) e - j M ω (28)

where A(ω)A(ω) is the amplitude, a real-valued function of ωω and e-jMωe-jMω gives the linear phase with MM being the group delay. For the case where NN is odd, using (Equation 26), (Equation 27), and (Equation 28), we have

A ( ω ) = n = 0 M - 1 2 h ( n ) cos ω ( M - n ) + h ( M ) A ( ω ) = n = 0 M - 1 2 h ( n ) cos ω ( M - n ) + h ( M ) (29)

or with a change of variables,

A ( ω ) = n = 1 M 2 h ( M - n ) cos ( ω n ) + h ( M ) A ( ω ) = n = 1 M 2 h ( M - n ) cos ( ω n ) + h ( M ) (30)

which becomes

A ( ω ) = n = 1 M 2 h ^ ( n ) cos ( ω n ) + h ( M ) A ( ω ) = n = 1 M 2 h ^ ( n ) cos ( ω n ) + h ( M ) (31)

where h^(n)=h(M-n)