Documentation |
Package: dsp
Digitally upconvert input signal
The DigitalUpConverter object digitally upconverts the input signal.
To digitally up convert the input signal:
Define and set up your digital up converter. See Construction.
Call step to upconvert the input according to the properties of dsp.DigitalUpConverter. The behavior of step is specific to each object in the toolbox.
h = dsp.DigitalUpConverter returns a digital up-converter (DDC) System object™, h. The object up samples the input signal using a cascade of three interpolation filters. This object frequency upconverts the up sampled signal by multiplying it with a complex exponential with center frequency equal to the value in the CenterFrequency property. When you set the FilterSpecification property to 'Design parameters', the DUC object designs the interpolation filters according to the filter specifications that you set in the filter-related object properties. In this case the filter cascade consists of a first FIR interpolation stage, a CIC compensator, and a CIC interpolator. The following block diagram shows the architecture of the digital up 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. Depending on the setting of the InterpolationFactor property, you may be able to bypass the first 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 diagram represents the DUC arithmetic with single or double-precision, floating-point inputs.
The following block diagram represents the DUC arithmetic with signed fixed-point inputs.
WL is the word length of the input, and FL is the fraction length of the input.
The output of each filter is cast to the data type specified in the FiltersOutputDataType and CustomFiltersOutputDataType properties. The casting of the CIC output occurs after the scaling factor is applied.
The oscillator output is cast to a word length equal to the FiltersOutputDataType word length plus one. The fraction length is equal to the FiltersOutputDataType word length minus one.
The scaling at the output of the CIC interpolator consists of coarse- and fine-gain adjustments. The coarse gain is achieved using the reinterpretcast function on the CIC interpolator 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 interpolator output and FLcic is the fraction length of the CIC interpolator output
F1 = abs(nextpow2(G)) , indicating the part of G achieved using bit shifts (coarse gain)
F2 = fraction length specified by the FiltersOutputDataType and CustomFiltersOutputDataType properties
fg = fi((2^F1)*G, true, 16) , indicating that the remaining gain cannot be achieved with a bit shift (fine gain)
h = dsp.DigitalUpConverter('PropertyName','PropertyValue') returns a DUC object, h, with each specified property 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. The value of this property multiplied by the total interpolation factor must be greater than or equal to twice the value of the CenterFrequency property. The default is 30e6. |
InterpolationFactor |
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 interpolation factors for each of the three filtering stages. When you set this property to a 1-by-2 vector, the object bypasses the first filter stage and sets the interpolation factor of the second and third 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 InterpolationFactor vector must be greater than one. When you set the FilterSpecification property to Coefficients, InterpolationFactor 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 interpolation factor for the i^{th} filtering stage. When you set the FilterSpecification property to Design parameters, the second and third elements of the InterpolationFactor vector must be greater than one and the first element must be 1 or 2. When you set the FilterSpecification property to Coefficients, the third element of the InterpolationFactor vector must be greater than 1. When you set the InterpolationFactor property to Coefficients, you must set the InterpolationFactor property to a 1-by-3 or 1-by-2 vector . The default is 100. |
FilterSpecification |
Set the filter specification as one of Design parameters |Coefficients. The default is Design parameters. The DUC object performs interpolation using a cascade of three interpolation filters. The third filter stage is always a CIC interpolator. When you set this property to Design parameters, the object designs the cascade of interpolation filters internally, according to a set of parameters that you specify using the filter-related object properties. In this case, the first and second stages of the cascade consist of a halfband or lowpass FIR interpolator, and a CIC compensator respectively. When you set this property to Coefficients, you specify an arbitrary set of filter coefficients for the first and second stages using the FirstFilterCoefficients, and SecondFilterCoefficients properties respectively. You specify the number of CIC sections using the NumCICSections property. In all cases, the first filter stage can be bypassed by setting the InterpolationFactor property appropriately. When the input data type is double or single the object implements an N-section CIC interpolation 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 FirstFilterOrder, SecondFilterOrder, and NumCICSections 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. |
FirstFilterCoefficients |
Coefficients of first filter stage. Set this property to a double precision row vector of real coefficients that correspond to an FIR filter. When you set the InterpolationFactor property to a 1-by-2 vector, the object ignores the value of the FirstFilterCoefficients property because the first 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. |
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 interpolation filter follows the second filter stage. This property applies when you set the FilterSpecification property to Coefficients. The default is 1. |
FirstFilterOrder |
Order of first filter stage Set this property to a positive, integer, even scalar. When you set the InterpolationFactor property to a 1-by-2 vector, the object ignores the FirstFilterOrder property because the first 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. |
NumCICSections |
Number of sections of CIC interpolator 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. |
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 200e3 Hertz. |
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/2 Hertz, and 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 150e3 Hertz. |
PassbandRipple |
Passband ripple of cascade response in dB. 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 dB. |
StopbandAttenuation |
Stopband attenuation of cascade response in dB. 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 dB. |
Oscillator |
Type of oscillator. Specify the oscillator as one of Sine wave | NCO. The default is Sine wave. When you set this property to Sine wave, the object frequency up converts the output of the interpolation filter cascade using a complex exponential signal obtained from samples of a sinusoidal trigonometric function. When you set this property to NCO the object performs frequency up conversion with a complex exponential obtained using a numerically controlled oscillator (NCO). |
CenterFrequency |
Center frequency of output signal in Hertz . Specify this property as a double precision, positive scalar. The value of this property must be less than or equal to half the product of the SampleRate property times the total interpolation factor. The object up converts the input signal so that the output spectrum centers at the frequency you specify in the CenterFrequency property. The default is 14e6 Hertz. |
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. See also dsp.NCO. |
NumQuantizedAccumulatorBits |
Number of NCO quantized accumulator bits. Specify this property as an integer scalar in the range[1 128]. The value you specify for 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. See also dsp.NCO. |
Dither |
Dither control for NCO . When you set this property to true, the object uses the number of dither bits specified in the NumDitherBits property when applying dither to the NCO signal. This property applies when you set the Oscillator property to NCO. The default is true. See also dsp.NCO. |
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. See also dsp.NCO. |
clone | Create digital up converter object with same property values |
fvtool | Visualize response of filter cascade |
getFilterOrders | Get orders of interpolation filters |
getFilters | Get handles to interpolation filter objects |
getInterpolationFactors | Get interpolation factors of each filter stage |
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 | Process inputs using the digital up converter |
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 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 the % 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 spectrum estimator to visualize the signal spectrum before % and after up 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') % Visualize the response of the interpolation filters visualizeFilterStages(hDUC)
For additional examples using this System object, see the following demos: