Parks-McClellan VI

Owning Palette: Advanced FIR Filtering VIs

Requires: Full Development System

Generates a set of linear-phase FIR multiband digital filter coefficients using the # of taps, sampling frequency: fs, Band Parameters, and filter type.

Details  Example

 Add to the block diagram  Find on the palette
# of taps contains the total number of coefficients in h. The default is 32. A tap corresponds to a multiplication and an addition. If there are n taps, every filtered sample requires n multiplications and n additions. # of taps must be greater than 2. If # of taps is less than or equal to 2, the VI sets h to an empty array, sets ripple to NaN, and returns an error.
sampling freq: fs is the sampling frequency in Hz and must be greater than zero. The default is 1.0 Hz. If sampling freq: fs is less than or equal to zero, the VI sets h to an empty array and returns an error.
Band Parameters is an array of clusters. Each cluster element contains the necessary information associated with each band for the FIR design. The Band Parameters cluster array must contain at least one element, that is, one band. The default is an empty array. If Band Parameters does not contain any elements, the VI sets h to an empty array, sets ripple to NaN, and returns an error.
Amplitude is the appropriate magnitude response, or gain, of the filter between Lower Freq and Higher Freq. A value of 1.0 corresponds to a passband, and a value of 0.0 corresponds to a stopband. If you set filter type to Differentiator, the Amplitude of a band is the slope of the frequency response in that band.
Lower Freq is the frequency at which the band begins.
Higher Freq is the frequency at which the band ends.
Weighted Ripple is the weighted ripple error that this VI minimizes. The higher the weight, the smaller the error in the band. For each band, Higher Freq must be greater than Lower Freq, as shown by the following relationship.

fhi > fli

for i = 0, 1, 2, …, m –1

where fhi is the Higher Freq in the ith band, fli is the Lower Freq in the ith band, and m is the number of bands.

For adjacent bands, the Lower Freq in the higher band must be greater than the Higher Freq in the adjacent lower band, as shown by the following relationship.

fli > fhi – 1

for i = 1, 2, …, m –1

where fli is the Lower Freq in the higher of the adjacent bands, fhi – 1 is the Higher Freq in the lower of the adjacent bands, and m is the number of bands.

The Higher Freq in the last band must be equal to or less than half of sampling freq: fs.

If any of the preceding frequency conditions are violated, the VI sets h to an empty array, sets ripple to NaN, and returns an error.
filter type can be the following values.

0Multiband (default)—Specifies a multiband filter. If # of taps is an odd number, this VI does not place restrictions on the value of the Amplitude. If # of taps is an even number, the Amplitude of the last band at half of sampling freq: fs must be 0.
1Differentiator—Specifies a differentiator. If # of taps is an even number, this VI does not place restrictions on the last band. If # of taps is an odd number, the value of Higher Freq in the last band must be less than half of sampling freq: fs. For example, a typical normalized band {0, 0.49} leaves a 0.01 transitional band at half of the sampling frequency, 0.5.
2Hilbert—Specifies a Hilbert transformer. The value of Lower Freq in the first band must be greater than 0. A typical normalized Lower Freq in the first band is 0.03. If # of taps is an even number, this VI does not place restrictions on the last band. If # of taps is an odd number, the value of Higher Freq in the last band must be less than half of sampling freq: fs. A typical normalized Higher Freq in the last band is 0.49.
h is an array of FIR filter coefficients, which the VI computes using the Parks-McClellan algorithm with the Remes exchange technique.
ripple is the optimal ripple the VI computes and is a measure of deviation from the ideal filter specifications.
error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster.

Parks-McClellan Details

Note  The Parks-McClellan VI finds the coefficients using iterative techniques based upon an error criterion. Although you specify valid filter parameters, the algorithm may fail to converge.

The Parks-McClellan VI generates only the filter coefficients. It does not perform the filtering function. To filter a sequence X using the set of FIR filter coefficients h, use the Convolution VI with X and h as the input sequences, as shown in the following illustration.

The equi-ripple filters use a similar technique to filter the data.

Example

Refer to the Optimal FIR Filter VI in the labview\examples\Mathematics\Optimization directory for an example of using the Parks-McClellan VI.

 Open example  Find related examples