Main Content

dsp.CICCompensationInterpolator

Compensate for CIC interpolation filter using FIR interpolator

Description

You can compensate for the shortcomings of a CIC interpolator, namely its passband droop and wide transition region, by preceding it with a compensation interpolator. This System object™ lets you design and use such a filter.

To compensate for the shortcomings of a CIC filter using an FIR interpolator:

  1. Create thedsp.CICCompensationInterpolatorobject and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, seeWhat Are System Objects?

Creation

Description

ciccompint= dsp.CICCompensationInterpolatorreturns a System object,ciccompint, that applies an FIR interpolator to each channel of an input signal. Using the properties of the object, the interpolation filter can be designed to compensate for a subsequent CIC filter.

ciccompint= dsp.CICCompensationInterpolator(interp)returns a CIC compensation interpolator System object,ciccompint, with theInterpolationFactorproperty set tointerp.

ciccompint= dsp.CICCompensationInterpolator(cic)returns a CIC compensation interpolator System object,ciccompint, with theCICRateChangeFactor,CICNumSections, andCICDifferentialDelayproperties specified in thedsp.CICInterpolatorSystem objectcic.

ciccompint= dsp.CICCompensationInterpolator(cic,interp)returns a CIC compensation interpolator System object,ciccompint, with theCICRateChangeFactor,CICNumSections, andCICDifferentialDelayproperties specified in thedsp.CICInterpolatorSystem objectcic, and theInterpolationFactorproperty set tointerp.

example

ciccompint= dsp.CICCompensationInterpolator(___,Name,Value)returns a CIC compensation interpolator object with each specified property set to the specified value. Enclose each property name in quotes. You can use this syntax with any previous input argument combinations.

Properties

expand all

Unless otherwise indicated, properties arenontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and thereleasefunction unlocks them.

If a property istunable, you can change its value at any time.

For more information on changing property values, seeSystem Design in MATLAB Using System Objects.

Specify the differential delay of the CIC filter being compensated as a positive integer scalar.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify the number of sections of the CIC filter being compensated as a positive integer scalar.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify the rate-change factor of the CIC filter being compensated as a positive integer scalar. The default is 2.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify whether to design a filter of minimum order or a filter of specified order as a logical scalar. The default istrue, which corresponds to a filter of minimum order.

Specify the order of the interpolation compensator filter as a positive integer scalar.

Dependencies

This property applies only when you set theDesignForMinimumOrderproperty tofalse.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify the interpolation factor of the compensator System object as a positive integer scalar.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify the passband edge frequency as a positive real scalar expressed in hertz.PassbandFrequencymust be less thanFs/2, whereFsis the output sample rate.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify the filter passband ripple as a positive real scalar expressed in decibels.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify the input sample rate as a positive real scalar expressed in hertz.

Data Types:single|double

Specify the filter stopband attenuation as a positive real scalar expressed in decibels.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Specify the stopband edge frequency as a positive real scalar expressed in hertz.StopbandFrequencymust be less thanFs/2, whereFsis the output sample rate.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Fixed-Point Properties

Word and fraction lengths of coefficients, specified as a signed or unsignednumerictypeobject. The default,numerictype(1,16)corresponds to a signed numeric type object with 16-bit coefficients and a fraction length determined based on the coefficient values, to give the best possible precision.

这个属性不是可调。

Word length of the output is same as the word length of the input. Fraction length of the output is computed such that the entire dynamic range of the output can be represented without overflow. For details on how the fraction length of the output is computed, seeFixed-Point Precision Rules for Avoiding Overflow in FIR Filters.

Rounding method for output fixed-point operations, specified as a character vector. For more information on the rounding modes, seePrecision and Range.

Usage

Description

example

y= ciccompint(x)outputs the upsampled and filtered values,y, of the input signal,x.

Input Arguments

expand all

数据输入,指定为一个向量或矩阵。的System object treats aKi×Ninput matrix asNindependent channels, interpolating each channel over the first dimension.

This object does not support complex unsigned fixed-point data.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|fi
Complex Number Support:Yes

Output Arguments

expand all

Upsampled and filtered signal, returned as a vector or matrix. For aKi×Ninput matrix, the result is aKo×Noutput matrix, whereKo=Ki×LandLis the interpolation factor.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|fi
Complex Number Support:Yes

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object namedobj, use this syntax:

release(obj)

expand all

freqz Frequency response of discrete-time filterSystem object
fvtool Visualize frequency response of DSP filters
info Information about filterSystem object
cost Estimate cost of implementing filterSystem object
coeffs Returns the filterSystem objectcoefficients in a structure
polyphase Polyphase decomposition of multirate filter
generatehdl Generate HDL code for quantized DSP filter (requiresFilter Design HDL Coder)
step RunSystem objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object

Examples

collapse all

Design an CIC compensation interpolator. Specify the interpolation factor to be 2, passband frequency to be 200 Hz, stopband frequency to be 500 Hz, and the input sample rate to be 600 Hz.

fs = 600; fPass = 200; fStop = 500; CICCompInterp = dsp.CICCompensationInterpolator(...'InterpolationFactor',2,...'PassbandFrequency',fPass,...'StopbandFrequency',fStop,...'SampleRate',fs);

Plot the impulse response. The zeroth order coefficient is delayed 6 samples, which is equal to the group delay of the filter.

fvtool(CICCompInterp,'Analysis','impulse')

Figure Figure 1: Impulse Response contains an axes object. The axes object with title Impulse Response, xlabel Time (ms), ylabel Amplitude contains an object of type stem.

Plot the magnitude and Phase response.

fvtool(CICCompInterp,'Analysis','freq')

Figure Figure 2: Magnitude Response (dB) and Phase Response contains an axes object. The axes object with title Magnitude Response (dB) and Phase Response, xlabel Frequency (Hz), ylabel Magnitude (dB) contains an object of type line.

Design a compensation interpolator for an existing CIC interpolator having six sections and an interpolation factor of 16.

CICInterp = dsp.CICInterpolator('InterpolationFactor',16,...'NumSections',6);

Construct the compensation interpolator. Specify an interpolation factor of 2, an input sample rate of 600 Hz, a passband frequency of 100 Hz, and a stopband frequency of 250 Hz. Set the minimum attenuation of alias components in the stopband to be at least 80 dB.

fs = 600; fPass = 100; fStop = 250; ast = 80; CICCompInterp = dsp.CICCompensationInterpolator(CICInterp,...'InterpolationFactor',2,'PassbandFrequency',fPass,...'StopbandFrequency',fStop,'StopbandAttenuation',ast,...'SampleRate',fs);

Visualize the frequency response of the cascade. Normalize all magnitude responses to 0 dB.

FC = dsp.FilterCascade(CICCompInterp, CICInterp); f = fvtool(CICCompInterp,CICInterp,FC,...'Fs', [fs*2 fs*16*2 fs*16*2]); f.NormalizeMagnitudeto1 ='on'; legend(f,'CIC Compensation Interpolator','CIC Interpolator',...'Overall Response');

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (kHz), ylabel Magnitude (dB) (normalized to 0 dB) contains 5 objects of type line. These objects represent CIC Compensation Interpolator, CIC Interpolator: Quantized, CIC Interpolator: Reference, Overall Response: Quantized, Overall Response: Reference.

Apply the design to a 1000-sample random input signal.

x = dsp.SignalSource(fi(rand(1000,1),1,16,15),'SamplesPerFrame',100); y = fi(zeros(32000,1),1,32,20);forind = 1:10 x2 = CICCompInterp(x()); y(((ind-1)*3200)+1:ind*3200) = CICInterp(x2);end

Algorithms

的response of a CIC filter is given by:

H c i c ( ω ) = [ sin ( R D ω 2 ) sin ( ω 2 ) ] N

R,D, andNare the rate change factor, the differential delay, and the number of sections in the CIC filter, respectively.

After decimation, the CIC response has the form:

H c i c ( ω ) = [ sin ( D ω 2 ) sin ( ω 2 R ) ] N

的normalized version of this last response is the one that the CIC compensator needs to compensate. Hence, the passband response of the CIC compensator should take the following form:

H c i c c o m p ( ω ) = [ R D sin ( ω 2 R ) sin ( D ω 2 ) ] N for ω ω p < π

whereωpis the passband frequency of the CIC compensation filter.

Notice that whenω/2R≪ π, the previous equation forHciccomp(ω) can be simplified using the fact that sin(x) ≅x:

H c i c c o m p ( ω ) [ ( D ω 2 ) sin ( D ω 2 ) ] N = [ s i n c ( D ω 2 ) ] N for ω ω p < π

This previous equation is the inverse sinc approximation to the true inverse passband response of the CIC filter.

Extended Capabilities

Version History

Introduced in R2014b