Component: Frequency Generator (DSP)

From Flowcode Help
Jump to navigationJump to search


Author Matrix Ltd
Version 1.2 (Release)
Category DSP


Image Frequency Generator component

A frequency generator component designed to plug into the DSP system component and allow several discreet waveforms to be generated. Functions available include: Sine, Square, Pulse, Triangle, Sawtooth, Noise, Custom

Examples

Basic Sine Wave Generator

FC6 Icon.png FreqGen The frequency is controlled by adjusting the potentiometer on the panel.

FreqGen.jpg


The frequency generator period is controlled using the Period Offset property and/or the SetOffset component macro. The Offset value is the LUT index multiplier so a offset of 3.0 will only read every 3 values of the waveform to provide 1/3 of the period and generate 3 x the frequency. As the waveform period is being reduced there is potential for the signal to start to become less defined and more stepped.


Multi Wave Signal Generator

Switch-able mode frequency generator example file generating different waveforms depending on the value on pins RB0 and RB1.

0 = Sine, 1 = Square, 2 = Triangle, 3 = SawTooth FC6 Icon.png FreqGenMulti The frequency is controlled by adjusting the potentiometer on the panel, the waveform is controlled by adjusting the switches on the panel.

FreqGenMulti.jpg

Downloadable macro reference

GenerateTick

Assigns a single value to the specified buffer from the selected waveform data. Each call will read the next value from the waveform and will wrap correctly at the end of the data period.

Parameters

This macro has no parameters


Return value

This call does not return a value


Generate

Fills the specified buffer with the selected waveform data. If the buffer is smaller or larger then the waveform data period then the data passed will follow on correctly for subsequest cycles.

Parameters

This macro has no parameters


Return value

This call does not return a value


SetOffset

Sets the period offset to a new value to alter the waveform output rate.

Parameters

FLOAT OffsetRate
0.2=F/5 0.5=F/2 1.0=F 1.5=F*1.5 2.0=F*2


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

Buffer Manager

This property is of type Fixed list of ints and can be referenced with the variable name buffer_manager.

Selects the DSP buffer manager component

Output

This property is of type Fixed list of ints and can be referenced with the variable name input_a.

Selects the buffer to assign the waveform data to

Type

This property is of type Fixed list of ints and can be referenced with the variable name wave_type.

Waveform type selection

Amplitude

This property is of type Signed integer and can be referenced with the variable name wave_amplitude.

Waveform amplitude or volume

Offset

This property is of type Signed integer and can be referenced with the variable name wave_offset.

Waveform DC offset

Period

This property is of type Signed integer and can be referenced with the variable name wave_period.

Waveform period, the number of samples in the cyclic wave

Phase

This property is of type Fixed list of ints and can be referenced with the variable name wave_phase.

Waveform phase, the point in the wave to start streaming from

Data

This property is of type Line of text and can be referenced with the variable name wave_data.

The raw waveform data

Period Offset

This property is of type Floating point and can be referenced with the variable name PeriodOffset.

The initial amount that the index increments through the LUT data when reading the stored waveform.

0.2 = Frequency / 5

0.5 = Frequency / 2

1.0 = Original Frequency

1.5 = Frequency * 1.5

2.0 = Frequency * 2

Sample Rate (hz)

This property is of type Floating point and can be referenced with the variable name sample_rate.

Allows the sample rate to be entered to allow some basic calculations

Period (s)

This property is of type Floating point and can be referenced with the variable name calc_period.

The length of time in seconds that the wave period will cover at the specified sample rate

Frequency (hz)

This property is of type Floating point and can be referenced with the variable name calc_freq.

The repeat frequency of the wave at the specified sample rate