Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

FIR Filters

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

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 [x i, x i – 1, …]. The term tap comes from the process of tapping off of the shift register to form each h k x i 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.

The following figure shows the block diagram of a VI that returns the frequency response of a bandpass equiripple FIR filter.

The VI in the previous figure completes the following steps to compute the frequency response of the filter.

  1. Pass an impulse signal through the filter.
  2. Pass the filtered signal out of the Case structure to the FFT VI. The Case structure specifies the filter type—lowpass, highpass, bandpass, or bandstop. The signal passed out of the Case structure is the impulse response of the filter.
Note  You can use the FFT VI only in the LabVIEW Full and Professional Development Systems.
  1. Use the FFT VI to perform a Fourier transform on the impulse response and to compute the frequency response of the filter, such that the impulse response and the frequency response comprise the Fourier transform pair . h(t) is the impulse response. H(f) is the frequency response.
  2. Use the Array Subset function to reduce the data returned by the FFT VI. Half of the real FFT result is redundant so the VI needs to process only half of the data returned by the FFT VI.
  3. Use the Complex To Polar function to obtain the magnitude-and-phase form of the data returned by the FFT VI. The magnitude-and-phase form of the complex output from the FFT VI is easier to interpret than the rectangular component of the FFT.
  4. Unwrap the phase and convert it to degrees.
  5. Convert the magnitude to decibels.

The following figure shows the magnitude and phase responses returned by the VI in the previous figure.

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. However, the phase response is a linear response because 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 an 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.

Designing Narrowband FIR Filters

Using conventional techniques to design FIR filters with especially narrow bandwidths can result in long filter lengths. FIR filters with long filter lengths often require long design and implementation times and are susceptible to numerical inaccuracy. In some cases, conventional filter design techniques, such as the Parks-McClellan algorithm, might not produce an acceptable narrow bandwidth FIR filter.

The interpolated finite impulse response (IFIR) filter design technique offers an efficient algorithm for designing narrowband FIR filters. Using the IFIR technique produces narrowband filters that require fewer coefficients and computations than filters you design by directly applying the Parks-McClellan algorithm. The FIR Narrowband Coefficients VI uses the IFIR technique to generate narrowband FIR filter coefficients.

Note  You can use the FIR Narrowband Coefficients VI only in the LabVIEW Full and Professional Development Systems.

You must specify the following parameters when developing narrowband filter specifications:

  • Filter type, such as lowpass, highpass, bandpass, or bandstop
  • Passband ripple on a linear scale
  • Sampling frequency
  • Passband frequency, which refers to passband width for bandpass and bandstop filters
  • Stopband frequency, which refers to stopband width for bandpass and bandstop filters
  • Center frequency for bandpass and bandstop filters
  • Stopband attenuation in decibels

The following figure shows the block diagram of a VI that estimates the frequency response of a narrowband FIR bandpass filter by transforming the impulse response into the frequency domain.

The following figure shows the filter response from zero to the Nyquist frequency that the VI in the previous figure returns.

In the previous figure, the narrow passband centers around 1 kHz. The narrow passband center at 1 kHz is the response of the filter specified by the front panel controls in the previous figure.

The following figure shows the filter response in detail.

In the previous figure, the narrow passband clearly centers around 1 kHz and the attenuation of the signal at 60 dB below the passband.

Refer to the works of Vaidyanathan, P. P. and Neuvo, Y. et al. for more information about designing IFIR filters.

Designing Wideband FIR Filters

You also can use the IFIR technique to produce wideband FIR lowpass filters and wideband FIR highpass filters. A wideband FIR lowpass filter has a cut-off frequency near the Nyquist frequency. A wideband FIR highpass filter has a cut-off frequency near zero. You can use the FIR Narrowband Coefficients VI to design wideband FIR lowpass filters and wideband FIR highpass filters. The following figure shows the frequency response that the VI in the previous block diagram returns when you use it to estimate the frequency response of a wideband FIR lowpass filter.

In the previous figure, the front panel controls define a narrow bandwidth between the stopband at 23.9 kHz and the Nyquist frequency at 24 kHz. However, the frequency response of the filter runs from zero to 23.9 kHz, which makes the filter a wideband filter.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit