Engee documentation

NCO

Generates real or complex sinusoidal signals.

blockType: NCO

Path in the library:

/Signal Operations/Sources/NCO

Description

The NCO unit generates a multi-channel real or complex sinusoidal signal with independent frequency and phase in each output channel. The amplitude of the generated signal is always 1. All outputs are real, except for exp - the output signal generated in the mode `Complex exponential`which is enabled by selecting the appropriate item in the drop-down list Output signal. For more information on how the unit calculates the output signal, see . Algorithms.

To get a multi-channel output, set the parameters Phase increment and Phase offset as vectors. Both parameters must have the same dimensionality, which determines the number of output channels. Each element of each vector is applied to a different output channel.

Ports

Output

# sin — sinusoidal output
Scalar | Vector | Matrix

Details

A sinusoidal output signal specified as a scalar, vector or matrix. You can specify the signal data type using the parameters Data type.

Dependencies

To use this port, set the Output signal parameters to Sine or Sine and cosine.

Data types

Float32, Float64, Fixed.

Complex numbers support

No

# Qerr — phase quantisation error
scalar | vector | matrix

Details

Phase quantisation error specified as a scalar, vector or matrix.

Dependencies

To use this port, select the checkbox Show phase quantization error port.

Data types

Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64, Fixed

Complex numbers support

No

# cos — cosine output
scalar | vector | matrix

Details

A cosine output signal specified as a scalar, vector or matrix. You can specify the signal data type using the parameters Data type.

Dependencies

To use this port, set the Output signal parameters to the value of Cosine or Sine and cosine.

Data types

Float32, Float64, Fixed.

Complex numbers support

No

# exp — complex exponential output
scalar | vector | matrix

Details

A complex exponential output specified as a scalar, vector or matrix. You can specify the signal data type using the parameters Data type.

Dependencies

To use this port, set Output signal to Complex exponential.

Data types

Float32, Float64, Fixed.

Complex numbers support

Yes

Input

# offset — phase shift
scalar | vector | matrix

Details

A phase shift signal specified as a real scalar, vector or full matrix. The input data must be of integer or fixed-point data type with zero fraction length. The block treats each column of the shift port input data as an independent channel. The number of channels in the phase shift signal must match the number of channels in the input data. For each frame of input data, the block can apply different phase shifts to each sample and channel.

Dependencies

To use this port, set the parameters Phase offset source to Input port.

Data types

Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64, Fixed

Complex numbers support

No

# inc — phase increment
scalar | vector

Details

A phase increment signal specified as a scalar or vector with a real value. The input must have an integer data type or a fixed-point data type with zero fraction length. The size of the phase increment signal depends on how you choose to specify the parameters Phase offset:

  • When you specify Phase offset in the block dialogue box, the parameter Phase increment must be a scalar or vector with the same length as the value Phase offset. The block applies each element of the vector to a different channel, so the length of the vector determines the number of output channels.

  • When you specify Phase offset through an input port, the offset port treats each input column as an independent channel. The length of Phase increment must be equal to the number of columns in the input to the offset port.

Dependencies

To use this port, set the Phase increment source parameters to Input port.

Data types

Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64, Fixed

Complex numbers support

No

Parameters

Phase adder parameters

# Phase increment source — phase increment setting method
Specify via dialog | Input port

Details

Select the phase increment setting method:

  • Input port - the phase increment value will be input to the inc input port;

  • Specify via dialog - the phase increment value can be set in the parameters Phase increment.

Values

Specify via dialog | Input port

Default value

Specify via dialog

Program usage name

PhaseIncrementSource

Tunable

No

Evaluatable

No

# Phase increment — phase increment value

Details

Specify the phase increment as a scalar or vector with an integer value. Only integer data types are allowed, including fixed-point and zero-length fraction data types. The dimensionality of the phase increment depends on the dimensionality of the phase shift:

  • When you specify a phase shift in the block parameters Phase offset, the phase increment must be a scalar or vector with the same dimensionality as the phase shift. The block applies each element of the vector to a different channel, so the length of the vector determines the number of output channels.

  • When you specify a phase shift through the offset input port, the shift port treats each column of the input as an independent channel. The length of the phase increment must be equal to the number of columns in the input of the shift port.

Dependencies

To use this parameter, set the Phase increment source parameter to Specify via dialog.

Default value

100

Program usage name

PhaseIncrement

Tunable

No

Evaluatable

Yes

# Phase offset source — phase shift setting method
Specify via dialog | Input port

Details

Select the phase shift setting method:

  • Input port - The phase shift value will be input to the offset input port;

  • Specify via dialog - the phase shift value can be set in the parameters Phase offset.

Values

Specify via dialog | Input port

Default value

Specify via dialog

Program usage name

PhaseOffsetSource

Tunable

No

Evaluatable

No

# Phase offset — phase shift value

Details

Specify the phase shift as a scalar or vector with an integer value. Only integer data types are allowed, including fixed-point and zero-length fraction data types. When you specify a phase shift with this parameter, it must be a scalar or vector with the same dimensionality as the phase increment. Scalars are expanded into a vector with the same dimensionality as the phase increment. Each element of the phase shift vector is applied to a different input channel, so the length of the vector determines the number of output channels.

Dependencies

To use this parameter, set the Phase offset source parameter to Specify via dialog.

Default value

0

Program usage name

PhaseOffset

Tunable

No

Evaluatable

Yes

# Add internal dither — add internal noise
Logical

Details

Select this checkbox to add smoothing to the NCO algorithm. Smoothing is added using the algorithm applied in the PN Sequence Generator sequence block.

Default value

true (switched on)

Program usage name

AddInternalDither

Tunable

No

Evaluatable

No

# Number of dither bits — number of anti-aliasing bits
Real number

Details

Specify the number of smoothing bits as a positive integer.

Dependencies

To use this port, select the checkbox Add internal dither.

Default value

4

Program usage name

NumDitherBits

Tunable

No

Evaluatable

Yes

# Quantize phase — include quantisation of the accumulated phase
Logical

Details

To enable accumulated phase quantisation, select this check box.

Default value

true (switched on)

Program usage name

QuantizePhase

Tunable

No

Evaluatable

No

# Number of quantized accumulator bits — number of quantised bits of the storage device
Real number

Details

Specify the number of quantised storage bits as an integer scalar that is greater than one and less than the storage word length. This value determines the number of entries in the lookup table.

Dependencies

To use this parameter, select the Quantize phase check box .

Default value

12

Program usage name

NumQuantizeAccBits

Tunable

No

Evaluatable

Yes

# Show phase quantization error port — phase quantisation error output
Logical

Details

Select to output a phase quantisation error. When you select this check box, the Qerr port appears on the block icon.

Dependencies

To enable this parameter, select the check box Quantize phase.

Default value

false (switched off)

Program usage name

ShowErrPort

Tunable

No

Evaluatable

No

Output parameters

# Output signal — output signal
Sine | Cosine | Complex exponential | Sine and cosine

Details

Select which signal the unit outputs: Sine, Cosine, Complex exponential or two signals Sine and cosine. If you select `Sine and cosine`If you select , the signals will be output to different ports.

Values

Sine | Cosine | Complex exponential | Sine and cosine

Default value

Sine

Program usage name

OutputSignal

Tunable

No

Evaluatable

No

# Sample time — sampling period
Real number

Details

If the block acts as a source, specify the sampling period in seconds as a positive scalar.

Dependencies

To use this parameter, both parameters Phase increment source and Phase offset source must be set to Specify via dialog. When a phase increment or phase shift is input through the block input port, the sampling period is inherited and this parameter is not used.

Default value

1

Program usage name

SampleTimeParam

Tunable

No

Evaluatable

Yes

# Samples per frame — counts per frame
Real number

Details

Specify the number of samples per frame as a positive integer. If this value is greater than one, the phase increment and phase shift may vary from channel to channel and frame to frame, but they are constant for each channel in a given frame.

When the phase shift input port offset is used, it has the same frame status as any output port. When the phase increment input port inc is used, frames are not supported.

Dependencies

To use this parameter, set the Phase increment source parameter and/or the Phase offset source parameter to Specify via dialog.

Default value

1

Program usage name

SamplePerFrame

Tunable

No

Evaluatable

Yes

Fixed-point operational parameters

# Rounding mode — rounding method
Floor

Details

This parameter is read-only.

When the input is a fixed-point data type, the NCO block always uses the rounding method Floor.

Values

Floor

Default value

Floor

Program usage name

RM

Tunable

No

Evaluatable

No

# Overflow mode — overflow method
Wrap

Details

This parameter is read-only.

When the input is a fixed-point data type, the NCO block always uses the method on overflow Wrap.

Values

Wrap

Default value

Wrap

Program usage name

OM

Tunable

No

Evaluatable

No

Accumulator

# Data type — drive data type
Binary point scaling

Details

Specifies the data type of the drive.

Values

Binary point scaling

Default value

Binary point scaling

Program usage name

AccDataType

Tunable

No

Evaluatable

No

# Signed — sign type of the drive data
yes

Details

Indicates that the drive data type is a sign data type.

Values

yes

Default value

yes

Program usage name

AccSign

Tunable

No

Evaluatable

No

# World length — storage word length
Real number

Details

Specify the length of the accumulator word as a positive integer from 2 to 128.

Default value

16

Program usage name

AccWorldLen

Tunable

No

Evaluatable

Yes

# Fraction length — drive data fraction length
0

Details

Specifies that the drive data type always has a fractional length equal to 0.

Values

0

Default value

0

Program usage name

AccFracLen

Tunable

No

Evaluatable

No

Output

# Data type — output data type
Binary point scaling | Float64 | Float32

Details

Specify the type of output data:

  • Select Float64 or Float32 for a floating point implementation.

  • When you select Binary point scaling, you can specify the word length and fraction length for the output data, in bits.

*Note.

The lookup table for this block is constructed from double precision floating point values. Thus, the maximum precision you can achieve in the output is 53 bits. Setting the word length of the data type Output to values greater than 53 bits will not improve the accuracy of the output.

Values

Binary point scaling | Float64 | Float32

Default value

Binary point scaling

Program usage name

OutputDataType

Tunable

No

Evaluatable

No

# Signed — sign type of output data
yes

Details

Specifies whether the output data type is a sign type.

Dependencies

To use this parameter, set the Data type parameters to . Binary point scaling.

Values

yes

Default value

yes

Program usage name

OutputSign

Tunable

No

Evaluatable

No

# World length — output word length
Real number

Details

Specify the length of the output data word as a positive integer from 2 to 128.

Dependencies

To use this parameter, set the Data type parameters to the value of Binary point scaling.

Default value

16

Program usage name

OutputWorldLen

Tunable

No

Evaluatable

Yes

# Fraction length — fraction length of the output data
Real number

Details

Specify the length of the fraction of the output data as a scalar integer.

Dependencies

To use this parameter, set the Data type parameters to . Binary point scaling.

Default value

14

Program usage name

OutputFracLen

Tunable

No

Evaluatable

Yes

Algorithms

The diagram below shows the algorithm that implements the block.

nco 1 en

The implementation of a numerically controlled oscillator (NCO) consists of two separate parts. Firstly, the phase accumulator accumulates the phase increment and adds a phase shift. At this stage, an additional internal smoothing signal (noise) can also be added. The output NCO is then calculated by quantising the results of the phase accumulator section and usage to select values from the lookup table. Since the lookup table contains a finite set of entries, in normal operation the NCO block allows the numeric values in the adder to overflow and allows them to close within the available range.

Given the desired output frequency , calculate the parameter value of the Phase increment block as follows:

where is the word length of the drive, and

The frequency resolution of the NCO in Hz is defined as:

Given the desired phase shift (in radians), calculate the block parameter Phase offset as follows:

The spurious free dynamic range (SFDR) for a lookup table with entries, where is the number of quantised bits of the drive, is estimated as follows:

  • dB, noise free;

  • dB, with noise.

The NCO block uses the quarter-wave lookup table method, which stores values from 0 to π/2. The block calculates other values on demand using the storage data type and then translates them into the output data type. This can lead to quantisation effects at the range boundaries of this data type. For example, consider the case where the value of a sine wave is expected to be -1 at the point π. Since the lookup table value at that point must be calculated, the block may give a value other than -1 depending on the accuracy of the drive data types and the output signal type.