Documentation

dsp.NCO System object

Generate real or complex sinusoidal signals

Description

The numerically controlled oscillator, orNCO, object generates real or complex sinusoidal signals. The amplitude of the generated signal is always 1.

To generate real or complex sinusoidal signals:

  1. Define and set up your NCO System object™. SeeConstruction.

  2. Callstepto generate the signals according to the properties ofdsp.NCO. The behavior ofstepis specific to each object in the toolbox.

Note

Starting in R2016b, instead of using thestep卫理公会教徒d to perform the operation defined by the System object, you can call the object with arguments, as if it were a function. For example,y = step(obj)andy = obj()perform equivalent operations.

Construction

nco = dsp.NCOreturns an NCO System object,nco, that generates a multichannel real or complex sinusoidal signal, with independent frequency and phase in each output channel.

nco = dsp.NCO('PropertyName',PropertyValue,...)returns anNCOSystem object,nco, with each specified property set to the specified value.

Properties

PhaseIncrementSource

Source of phase increment

Indicate how to specify the phase increment:PropertyorInput port. The default isInput port.

PhaseIncrement

Phase increment

Specify the phase increment as an integer scalar. This property applies only when you set thePhaseIncrementSourceproperty toProperty. The default is100.

PhaseOffsetSource

Source of phase offset

Specify the phase offset asPropertyorInput port. The default isProperty.

PhaseOffset

Phase offset

Specify the phase offset as an integer scalar. This property applies only when you set thePhaseOffsetSourceproperty toProperty. The default is0.

Dither

Enable adding internal dithering to NCO algorithm

Set this property totrueto add internal dithering to the NCO algorithm. Dithering is added using thePN Sequence Generatorfrom the Communications System Toolbox™ product. The default istrue.

NumDitherBits

Number of dither bits

Specify the number of dither bits as a positive integer. This property applies only when you set theDitherproperty totrue. The default is4.

PhaseQuantization

Enable quantization of accumulated phase

Set this property totrueto enable quantization of the accumulated phase. The default istrue.

NumQuantizerAccumulatorBits

Number of quantizer accumulator bits

Specify the number of quantizer accumulator bits as an integer scalar greater than 1 and less than the accumulator word length. This property determines the number of entries in the lookup table of sine values. This property applies only when you set thePhaseQuantizationproperty totrue. The default is12.

PhaseQuantizationErrorOutputPort

Enable output of phase quantization error

Set this property totrueto output the phase quantization error. This property applies only when you set thePhaseQuantizationproperty totrue. The default isfalse.

Waveform

Type of output signal

Specify the type of the output signal:Sine,Cosine,Complex exponentialorSine and cosine. The default isSine.

SamplesPerFrame

Number of output samples per frame

Specify the number of samples per frame of the output signal. This property applies only when you set thePhaseOffsetSourceproperty toProperty. The default is1. When thePhaseOffsetSourceproperty isInput port, and thePhaseIncrementSourceproperty isProperty, the number of rows or frame size of the phase offset input determines the number of samples per frame of the output signal. When you set both thePhaseOffsetSourceandPhaseIncrementSourceproperties toInput port, the number of rows in the inputs must be 1, and the samples per frame of the output signal is 1.

OutputDataType

Output data type

Specify the output data type asdouble,singleorCustom. The default isCustom. When you selectCustomyou must also set theCustomOutputDataType财产。你可以找到的CustomOutputDataTypeproperty described underFixed-Point Propertieson this page.

Fixed-Point Properties

Methods

info Characteristic information about generated signal
reset Reset accumulator of NCO object
step 产生多通道真实的或复杂的正弦ignal using NCO (Numerically Controlled Oscillator)
Common to All System Objects
release

Allow System object property value changes

Examples

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstepsyntax. For example, myObject() becomes step(myObject).

Design an NCO source according to given specifications.

df = 0.05;% Frequency resolution = 0.05 HzminSFDR = 96;% Spurious free dynamic range >= 96 dBTs = 1/8000;% Sample period = 1/8000 secdphi = pi/2;% Desired phase offset = pi/2;

Calculate number of accumulator bits required for the given frequency resolution.

Nacc = ceil(log2(1/(df*Ts)));

Actual frequency resolution achieved.

actdf = 1/(Ts*2^Nacc);

Calculate number of quantized accumulator bits required from the SFDR requirement

Nqacc = ceil((minSFDR-12)/6);

Calculate the phase offset

phOffset = 2^Nacc*dphi/(2*pi);

Design the NCO source.

nco = dsp.NCO('PhaseOffset', phOffset,...'NumDitherBits', 4,...'NumQuantizerAccumulatorBits', Nqacc,...'SamplesPerFrame', 1/Ts,...'CustomAccumulatorDataType', numerictype([],Nacc)); san = dsp.SpectrumAnalyzer('SampleRate', 1/Ts,...'PlotAsTwoSidedSpectrum', false);

View the output of the NCO source on a spectrum analyzer. Change the output frequency in the middle of the simulation from 510 Hz to 1520 Hz.

tic;whiletoc < 10iftoc < 5 F0 = 510;elseF0 = 1520;end% Calculate the phase incrementphIncr = int32(round(F0*Ts*2^Nacc)); y = nco(phIncr); san(y);end

Algorithms

This object implements the algorithm, inputs, and outputs described on theNCOblock reference page. The object properties correspond to the block properties, except:

There is no object property that corresponds to theSample timeblock parameter. The objects assumes a sample time of one second.

Extended Capabilities

See Also

Introduced in R2012a

Was this topic helpful?