Documentation Center |
Package: dsp
Digitally downconvert input signal
The DigitalDownConverter object digitally downconverts the input signal.
To digitally downconvert the input signal:
Define and set up your digital down converter. See Construction.
Call step to downconvert the input according to the properties of dsp.DigitalDownConverter. The behavior of step is specific to each object in the toolbox.
h = dsp.DigitalDownConverter returns a digital down-converter (DDC) System object™, h. The object downconverts the input signal by multiplying it with a complex exponential with center frequency equal to the value in the CenterFrequency property. The object downsamples the frequency down-converted signal using a cascade of three decimation filters. When you set the FilterSpecification property to Design parameters, the DDC object designs the decimation filters according to the filter parameters that you set in the filter-related object properties. In this case the filter cascade consists of a CIC decimator, a CIC compensator and a third FIR decimation stage. The following block diagram shows the architecture of the digital down converter.
The scaling section normalizes the CIC gain and the oscillator power. It may also contain a correction factor to achieve the desired ripple specification. When you set the Oscillator property to InputPort, the normalization factor does not include the oscillator power factor. Depending on the setting of the DecimationFactor property, you may be able to bypass the third filter stage. When the arithmetic is double or single precision, the CIC interpolator is implemented as a simple FIR interpolator with a boxcar response. A true CIC interpolator can only operate with fixed-point signals. The CIC filter is emulated with an FIR filter so that you can run simulations with floating-point data.
The following block diagram represents the DDC arithmetic with single or double-precision, floating-point inputs.
The following block diagram represents the DDC arithmetic with signed fixed-point inputs.
WL is the word length of the input, and FL is the fraction length of the input.
The input of each filter is cast to the data type specified in the FiltersInputDataType and CustomFiltersInputDataType properties.
The oscillator output is cast to a word length equal to the input word length plus one. The fraction length is equal to the input word length minus one.
The scaling at the output of the CIC decimator consists of coarse- and fine-gain adjustments. The coarse gain is achieved using the reinterpretcast function on the CIC decimator output. The fine gain is achieved using full-precision multiplication.
The following figure depicts the coarse- and fine-gain operations.
If the normalization gain is G, (where 0<G≦1), then:
WLcic is the word length of the CIC decimator output and FLcic is the fraction length of the CIC decimator output
F1 = abs(nextpow2(G)) , indicating the part of G achieved using bit shifts (coarse gain)
F2 = fraction length specified by the FiltersInputDataType and CustomFiltersInputDataType properties
fg = fi((2^F1)*G, true, 16) , indicating that the remaining gain cannot be achieved with a bit shift (fine gain)
h = dsp.DigitalDownConverter(Name,Value) returns a DDC object, h, with the specified property Name set to the specified Value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).
SampleRate |
Sample rate of input signal Set this property to a positive scalar value, greater than or equal to twice the value of the CenterFrequency property. The default is 30 Megahertz. |
DecimationFactor |
Decimation factor Set this property to a positive, integer scalar, or to a 1-by-2 or 1-by-3 vector of positive integers. When you set this property to a scalar the object automatically chooses the decimation factors for each of the three filtering stages. When you set this property to a 1-by-2 vector, the object bypasses the third filter stage and sets the decimation factor of the first and second filtering stages to the values in the first and second vector elements respectively. When you set the FilterSpecification property to Design parameters, both elements of the DecimationFactor vector must be greater than one. When you set the FilterSpecification property to Coefficients, the first element of the DecimationFactor vector must be greater than 1. When you set this property to a 1-by-3 vector, the i ^{th} element of the vector specifies the decimation factor for the i^{th} filtering stage. When you set the FilterSpecification property to Design parameters, the first and second elements of the DecimationFactor vector must be greater than one and the third element must be 1 or 2. When you set the FilterSpecification property to Coefficients, the first element of the DecimationFactor vector must be greater than 1. When you set the FilterSpecification property to Coefficients, you must set the DecimationFactor property to a 1-by-3 or 1-by-2 vector. The default is 100. |
FilterSpecification |
Filter specification Set the filter specification as one of Design parameters | Coefficients. The default is Design parameters. The DDC object performs decimation using a cascade of three decimation filters. The first filter stage is always a CIC decimator. When you set the FilterSpecification property to Design parameters, the object designs the cascade of decimation filters internally, according to a set of parameters that you specify using the filter-related object properties. In this case, the second and third stages of the cascade consist of a CIC compensator, and a halfband or lowpass FIR decimator respectively. When you set the FilterSpecification property to Coefficients, you specify an arbitrary set of filter coefficients for the second and third filter stages using the SecondFilterCoefficients, and ThirdFilterCoefficients properties respectively. You specify the number of CIC sections using the NumCICSections property. In all cases, the third filter stage can be bypassed by setting the DecimationFactor property appropriately. When the input data type is double or single the object implements an N-section CIC decimation filter as an FIR filter with a response that corresponds to a cascade of N boxcar filters. A true CIC filter with actual comb and integrator sections is implemented when the input data is of a fixed point type. |
MinimumOrderDesign |
Minimum order filter design When you set this property to true the object designs filters with the minimum order that meets the passband ripple, stopband attenuation, passband frequency, and stopband frequency specifications that you set using the PassbandRipple, StopbandAttenuation, Bandwidth, StopbandFrequencySource, and StopbandFrequency properties. When you set this property to false, the object designs filters with orders that you specify in the NumCICSections, SecondFilterOrder, and ThirdFilterOrder properties. The filter designs meet the passband and stopband frequency specifications that you set using the Bandwidth, StopbandFrequencySource, and StopbandFrequency properties. This property applies when you set the FilterSpecification property to Design parameters. The default is true. |
NumCICSections |
Number of sections of CIC decimator Set this property to a positive, integer scalar. This property applies when you set the FilterSpecification property to Design parameters and the MinimumOrderDesign property to false, or when you set the FilterSpecification property to Coefficients. The default is 3. |
SecondFilterCoefficients |
Coefficients of second filter stage Set this property to a double precision row vector of real coefficients that correspond to an FIR filter. Usually, the response of this filter should be that of a CIC compensator since a CIC decimation filter precedes the second filter stage. This property applies when you set the FilterSpecification property to Coefficients. The default is 1. |
ThirdFilterCoefficients |
Coefficients of third filter stage Set this property to a double precision row vector of real coefficients that correspond to an FIR filter. When you set the DecimationFactor property to a 1-by-2 vector, the object ignores the value of the ThirdFilterCoefficients property because the third filter stage is bypassed. This property applies when you set the FilterSpecification property to Coefficients. The default is 1. |
SecondFilterOrder |
Order of CIC compensation filter stage Set this property to a positive, integer scalar. This property applies when you set the FilterSpecification property to Design parameters and the MinimumOrderDesign property to false. The default is 12. |
ThirdFilterOrder |
Order of third filter stage Set this property to a positive, integer, even scalar. When you set the DecimationFactor property to a 1-by-2 vector, the object ignores the ThirdFilterOrder property because the third filter stage is bypassed. This property applies when you set the FilterSpecification property to Design parameters and the MinimumOrderDesign property to false. The default is 10. |
Bandwidth |
Two sided bandwidth of input signal in Hertz Set this property to a positive, integer scalar. The object sets the passband frequency of the cascade of filters to one-half of the value that you specify in the Bandwidth property. This property applies when you set the FilterSpecification property to Design parameters. The default is 200 kilohertz. |
StopbandFrequencySource |
Source of stopband frequency Specify the source of the stopband frequency as one of Auto | Property. The default is Auto. When you set this property to Auto, the object places the cutoff frequency of the cascade filter response at approximately F_{c} = SampleRate/M/2 Hertz, where M is the total decimation factor that you specify in the DecimationFactor property. The object computes the stopband frequency as F_{stop} = F_{c} + TW/2. TW is the transition bandwidth of the cascade response computed as 2*(F_{c}-F_{p}), and the passband frequency, F_{p}, equals Bandwidth/2. This property applies when you set the FilterSpecification property to Design parameters. |
StopbandFrequency |
Stopband frequency in Hertz Set this property to a double precision positive scalar. This property applies when you set the FilterSpecification property to Design parameters and the StopbandFrequencySource property to Property. The default is 150 kilohertz. |
PassbandRipple |
Passband ripple of cascade response in decibels. Set this property to a double precision, positive scalar. When you set the MinimumOrderDesign property to true, the object designs the filters so that the cascade response meets the passband ripple that you specify in the PassbandRipple property. This property applies when you set the FilterSpecification property to Design parameters and the MinimumOrderDesign property to true. The default is 0.1 decibels. |
StopbandAttenuation |
Stopband attenuation of cascade response in decibels Set this property to a double precision, positive scalar. When you set the MinimumOrderDesign property to true, the object designs the filters so that the cascade response meets the stopband attenuation that you specify in the StopbandAttenuation property. This property applies when you set the FilterSpecification property to Design parameters and the MinimumOrderDesign property to true. The default is 60 decibels. |
Oscillator |
Type of oscillator Specify the oscillator as one of Sine wave | NCO | Input port. The default is Sine wave. When you set this property to Sine wave, the object frequency down converts the input signal using a complex exponential obtained from samples of a sinusoidal trigonometric function. When you set this property to NCO the object performs frequency down conversion with a complex exponential obtained using a numerically controlled oscillator (NCO). When you set this property to Input port, the object performs frequency down conversion using the complex signal that you set as an input to the step method. |
CenterFrequency |
Center frequency of input signal in Hertz Specify this property as a double precision positive scalar that is less than or equal to half the value of the SampleRate property. The object down converts the input signal from the passband center frequency you specify in the CenterFrequency property, to 0 Hertz. This property applies when you set the Oscillator property to Sine wave or NCO. The default is 14 Megahertz. |
NumAccumulatorBits |
Number of NCO accumulator bits Specify this property as an integer scalar in the range [1 128]. This property applies when you set the Oscillator property to NCO. The default is 16. |
NumQuantizedAccumulatorBits |
Number of NCO quantized accumulator bits Specify this property as an integer scalar in the range [1 128]. The value you specify in this property must be less than the value you specify in the NumAccumulatorBits property. This property applies when you set the Oscillator property to NCO. The default is 12. |
Dither |
Dither control for NCO When you set this property to true, a number of dither bits specified in the NumDitherBits property will be used to apply dither to the NCO signal. This property applies when you set the Oscillator property to NCO. The default is true. |
NumDitherBits |
Number of NCO dither bits Specify this property as an integer scalar smaller than the number of accumulator bits that you specify in the NumAccumulatorBits property. This property applies when you set the Oscillator property to NCO and the Dither property to true. The default is 4. |
clone | Create digital down converter object with same property values |
fvtool | Visualize response of filter cascade |
getDecimationFactors | Get decimation factors of each filter stage |
getFilterOrders | Get orders of decimation filters |
getFilters | Get handles to decimation filter objects |
getNumInputs | Number of expected inputs to step method |
getNumOutputs | Number of outputs of step method |
groupDelay | Group delay of filter cascade |
isLocked | Locked status for input attributes and non-tunable properties |
release | Allow property value and input characteristics changes |
step | Digitally down convert input signal |
visualizeFilterStages | Display response of filter stages |
Create a digital up converter object that up samples a 1 KHz sinusoidal signal by a factor of 20 and up converts it to 50 KHz. Create a digital down converter object that down converts the signal to 0 Hz and down samples it by a factor of 20.
% Create a sine wave generator to obtain the 1 KHz % sinusoidal signal with a sample rate of 6 KHz. Fs = 6e3; % Sample rate hSig = dsp.SineWave('Frequency',1000,'SampleRate',... Fs,'SamplesPerFrame',1024); x = step(hSig); % generate signal % Create a DUC object. Use minimum order filter designs and set % passband ripple to 0.2 dB and the stopband attenuation to 55 dB. % Set the double sided signal bandwidth to 2 KHz. hDUC = dsp.DigitalUpConverter(... 'InterpolationFactor', 20,... 'SampleRate', Fs,... 'Bandwidth', 2e3,... 'StopbandAttenuation', 55,... 'PassbandRipple',0.2,... 'CenterFrequency',50e3); % Create a DDC object. Use minimum order filter designs and set the % passband ripple to 0.2 dB and the stopband attenuation to 55 dB. hDDC = dsp.DigitalDownConverter(... 'DecimationFactor',20,... 'SampleRate', Fs*20,... 'Bandwidth', 3e3,... 'StopbandAttenuation', 55,... 'PassbandRipple',0.2,... 'CenterFrequency',50e3); % Create a spectrum estimator to visualize the signal spectrum before % up converting, after up converting, and after down converting. window = hamming(floor(length(x)/10)); figure; pwelch(x,window,[],[],Fs,'centered') title('Spectrum of baseband signal x') % Up convert the signal and visualize the spectrum xUp = step(hDUC,x); % up convert window = hamming(floor(length(xUp)/10)); figure; pwelch(xUp,window,[],[],20*Fs,'centered'); title('Spectrum of up converted signal xUp') % Down convert the signal and visualize the spectrum xDown = step(hDDC,xUp); % down convert window = hamming(floor(length(xDown)/10)); figure; pwelch(xDown,window,[],[],Fs,'centered') title('Spectrum of down converted signal xDown') % Visualize the response of the decimation filters visualizeFilterStages(hDDC)
For additional examples using this System object, see the following demos: