# FIR Filters

The FIR filter is a set of filter coefficients that alters the signal spectrum when convolving with the signal. Let Ck, for k = 0, 1, 2, . . ., be the filter coefficients, xN the input signal, and yN the output in the following formula:

when i = 0, 1, . . ., N – 1

LabWindows/CVI implements the formula using the convolution function Convolve. The purpose of an FIR filter is to design the coefficients Ck. Remember that an FIR filter function does not actually perform filtering. You must subsequently call Convolve to perform the filtering. The advantage of this process is that after you obtain the filter coefficients, you can use them repeatedly without redesigning the filter.

If you have never used an FIR filter before, start with a window FIR filter. These filters are easy to design, though other techniques might design a better filter with the same number of coefficients.

Use the windType parameter to choose the window type to use in a window FIR filter. windType determines the amount of attenuation the window filter can achieve. It also determines the transitional bandwidth of the window filter, which is the frequency range from the specified cutoff frequency to the point where the desired attenuation is obtained. A bigger transitional bandwidth usually gives better attenuation. Use a Kaiser window FIR filter to choose windows that are not available from windType.

If you are experienced in using filters and you want to design an optimal FIR filter, use the LabWindows/CVI Advanced Analysis Library Equi_Ripple function. These filters are based on the general Parks-McClellan algorithm, that, in turn, is based on an alternation theorem in the polynomial approximation. As the name suggests, the frequency response of an Equi_Ripple filter has equal ripples within each specified frequency band. The ripples can be different in different bands depending on the weighting factors.

You have to specify more parameters when you use Equi_Ripple filters. For each frequency band, specify the starting and ending points, the amplitude response, and a weighting factor associated with the amplitude response of that band. A weighting factor of one is usually sufficient for all bands, but you can select different weighting factors. A bigger weighting factor results in a smaller ripple in the corresponding frequency band; a smaller weighting factor results in a larger ripple.

If you want to design an optimal FIR multiband filter, such as lowpass, highpass, bandpass, and bandstop, but do not want to specify the weighting factor, use EquiRpl_LPF, EquiRpl_HPF, EquiRpl_BPF, and EquiRpl_BSF. These filters call Equi_Ripple internally but have simplified input parameters.

| Caution The Equi_Ripple filter design does not always converge. In some cases, it will fail and give erroneous results. It is extremely important that you verify the filter design after you obtain the filter coefficients.