Contents

dsp.NCO System object

Package: dsp

Generate real or complex sinusoidal signals

Description

The numerically controlled oscillator, or NCO, 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™. See Construction.

  2. Call step to generate the signals according to the properties of dsp.NCO. The behavior of step is specific to each object in the toolbox.

Construction

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

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

Properties

PhaseIncrementSource

Source of phase increment

Indicate how to specify the phase increment: Property or Input port. The default is Input port.

PhaseIncrement

Phase increment

Specify the phase increment as an integer scalar. This property applies only when you set the PhaseIncrementSource property to Property. The default is 100.

PhaseOffsetSource

Source of phase offset

Specify the phase offset as Property or Input port. The default is Property.

PhaseOffset

Phase offset

Specify the phase offset as an integer scalar. This property applies only when you set the PhaseOffsetSource property to Property. The default is 0.

Dither

Enable adding internal dithering to NCO algorithm

Set this property to true to add internal dithering to the NCO algorithm. Dithering is added using the PN Sequence Generator from the Communications System Toolbox™ product. The default is true.

NumDitherBits

Number of dither bits

Specify the number of dither bits as a positive integer. This property applies only when you set the Dither property to true. The default is 4.

PhaseQuantization

Enable quantization of accumulated phase

Set this property to true to enable quantization of the accumulated phase. The default is true.

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 the PhaseQuantization property to true. The default is 12.

PhaseQuantizationErrorOutputPort

Enable output of phase quantization error

Set this property to true to output the phase quantization error. This property applies only when you set the PhaseQuantization property to true. The default is false.

Waveform

Type of output signal

Specify the type of the output signal: Sine, Cosine, Complex exponential or Sine and cosine. The default is Sine.

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 the PhaseOffsetSource property to Property. The default is 1. When the PhaseOffsetSource property is Input port, and the PhaseIncrementSource property is Property, 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 the PhaseOffsetSource and PhaseIncrementSource properties to Input 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 as one of double, single or Custom. The default is Custom.

 Fixed-Point Properties

Methods

cloneCreate NCO object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
infoCharacteristic information about generated signal
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset accumulator of NCO object
stepGenerate multichannel real or complex sinusoidal signal using NCO (Numerically Controlled Oscillator)

Examples

Design an NCO source according to given specifications:

    F0 = 510; % Output frequency = 510 Hz
    df = 0.05; % Frequency resolution = 0.05 Hz
    minSFDR = 96; % Spurious free dynamic range >= 96 dB
    Ts = 1/8000; % Sample period = 1/8000 sec
    dphi = 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 increment 
    phIncr = round(F0*Ts*2^Nacc);
    % Calculate the phase offset
    phOffset = 2^Nacc*dphi/(2*pi);
 
    hnco = dsp.NCO('PhaseIncrementSource', 'Property', ...
    'PhaseIncrement', phIncr,...
    'PhaseOffset', phOffset,...
    'NumDitherBits', 4, ...
    'NumQuantizerAccumulatorBits', Nqacc,...
    'SamplesPerFrame', 1/Ts, ...
    'CustomAccumulatorDataType', numerictype([],Nacc));
 
    y = step(hnco);
    % Plot the mean-square spectrum of the 510 Hz sinewave 
    % generated by the NCO
    periodogram(double(y),hann(length(y),'periodic'),[],1/Ts,'power');

Algorithms

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

There is no object property that corresponds to the Sample time block parameter. The objects assumes a sample time of one second.

See Also

Was this topic helpful?