Admin Production ni-theme
Current Publication

Parks_McClellanCoef

LabWindows/CVI

Parks_McClellanCoef

Advanced Analysis Library Only

AnalysisLibErrType Parks_McClellanCoef (int numberOfCoefficients, double samplingFrequency, BandParameter bandParameters[], ssize_t numberOfParameters, int filterType, double coefficients[], double *ripple);

Purpose

Designs a set of linear-phase FIR multiband digital filter coefficients. Parks_McClellanCoef generates only the filter coefficients; it does not actually perform data filtering. To filter a sequence X using the set of FIR filter coefficients coefficients, call ConvolveEx with X and coefficients as the input sequences. The equi-ripple filters use a similar technique to filter the data.

For more information, refer to Discrete-Time Signal Processing by Oppenheim and Schafer, cited in the Bibliography.

Example Code

/* Design a 55-point linear-phase FIR multiband digital filter using Parks-McClellan algorithm. Filter the incoming signal with the designed filter. */

Parameters

Input
Name Type Description
numberOfCoefficients int The total number of coefficients in coefficients. A coefficient corresponds to a multiplication and an addition. If there are n coefficients, every filtered sample requires n multiplications and n additions. This value must be greater than 2.
samplingFrequency double Sampling frequency in Hertz. This value must be greater than zero.
bandParameters BandParameter [] Pointer to the band parameters structure that contains the necessary information associated with each band for the FIR design. The definition of the filter structure is as follows:

typedef struct {

double amplitude; /* appropriate magnitude response, or gain, of the filter between fLow and fHigh */
double fLow; /* frequency at which the band begins */
double fHigh; /* frequency at which the band ends */
double wRipple; /* weighted ripple error that this function minimizes */
} BandParam, *BandParamPtr;



amplitude—The appropriate magnitude response, or gain, of the filter between fLow and fHigh.
fLow—The frequency at which the band begins.
fHigh—frequency at which the band ends.
wRipple—The weighted ripple error that this function minimizes. The higher the weight, the smaller the error in the band. For each band, fHigh must be greater than fLow, as shown by the following relationship.

fhi < fli

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

where fhi is the higher frequency in the ith band, fli is the lower frequency in the ith band, and m is the number of bands.

For adjacent bands, the lower frequency in the higher band must be greater than the higher frequency 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 frequency in the higher of the adjacent bands, fhi – 1 is the higher frequency in the lower of the adjacent bands, and m is the number of bands.

The higher frequency in the last band must be equal to or less than half of samplingFrequency.
numberOfParameters ssize_t Size of bandParameters.
filterType int Filter type. filterType must be one of the following values.

Constant Value Description
PM_MULTIBAND 0 Specifies a multiband filter. If numberOfCoefficients is an odd number, this function does not place restrictions on the value of the amplitude. If numberOfCoefficients is an even number, the amplitude of the last band at half of the sampling frequency must be 0.
PM_DIFFERENTIATOR 1 Specifies a differentiator. If numberOfCoefficients is an even number, this function does not place restrictions on the last band. If numberOfCoefficients is an odd number, the value of higher frequency in the last band must be less than half of the sampling freq. For example, a typical normalized band {0, 0.49} leaves a 0.01 transitional band at half of the sampling frequency, 0.5.
PM_HILBERT 2 Specifies a Hilbert transformer. The value of lower frequency in the first band must be greater than 0. A typical normalized lower frequency in the first band is 0.03. If numberOfCoefficients is an even number, this function does not place restrictions on the last band. If numberOfCoefficients is an odd number, the value of higher frequency in the last band must be less than half of the sampling frequency. A typical normalized higher frequency in the last band is 0.49.
Output
Name Type Description
coefficients double [] Array of FIR filter coefficients using the Parks-McClellan algorithm with the Remes exchange technique.
ripple double Optimal ripple that is a measure of deviation from the ideal filter specifications.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 2012 and later