Signal Source: Difference between revisions
Jump to navigation
Jump to search
(Actually define Signal shape) |
|||
Line 13: | Line 13: | ||
; Waveform (''R'') | ; Waveform (''R'') | ||
: options: [Constant, Sine, Cosine, Square, Triangle, Saw Tooth] | : options: [Constant, Sine, Cosine, Square, Triangle, Saw Tooth] | ||
:: Constant | |||
::: A constant value as specified by ''Amplitude'' + ''Offset'' | |||
:: Sine | |||
::: Real-valued signal types: ''Amplitude''·sin(2π·''Frequency''/''Sample Rate''·n) + ''Offset'' | |||
::: Complex-valued signal types: ''Amplitude''·[cos(2π·''Frequency''/''Sample Rate''·n) + 1j·sin(2π·''Frequency''/''Sample Rate''·n)] + ''Offset'' | |||
:: Cos | |||
::: Real-valued signal types: ''Amplitude''·cos(2π·''Frequency''/''Sample Rate''·n) + ''Offset'' | |||
::: Complex-valued signal types (identical to Sin): ''Amplitude''·cos(2π·''Frequency''/''Sample Rate''·n) + 1j·sin(2π·''Frequency''/''Sample Rate''·n) + ''Offset'' | |||
:: Square (Phase wraps in [–π,+π], increasing by ''Frequency''/''Sample Rate'' every sample) | |||
::: Real-valued signal types: | |||
:::: phase < 0: ''Amplitude''+''Offset'' | |||
:::: phase ≥ 0: ''Offset'' | |||
::: Complex-valued signal types (Real part: 0-centered π-wide square wave, Imag leads Real by 90°): | |||
:::: phase in [-π, -π/2): ''Amplitude'' + 0j + ''Offset'' | |||
:::: phase in [-π/2, 0): ''Amplitude'' + 1j·''Amplitude'' + ''Offset'' | |||
:::: phase in [ 0, +π/2): 0 + 1j·''Amplitude'' + ''Offset'' | |||
:::: phase in [+π/2, +π): 0 + 0j + ''Offset'' | |||
:: Triangle (Phase wraps in [–π,+π], increasing by ''Frequency''/''Sample Rate'' every sample) | |||
::: Real-valued signal types: | |||
:::: Phase in [-π, 0): Linear ramp from -''Amplitude'' to +''Amplitude'' (both + ''Offset'') | |||
:::: Phase in [0, +π): Linear ramp from +''Amplitude'' to -''Amplitude'' (both + ''Offset'') | |||
::: Complex-valued signal types (Real part: triangle wave, rising in [-π,0), falling [0,+π), Imag leads Real by 90°): | |||
:::: phase in [-π, -π/2): TODO | |||
:::: phase in [-π/2, 0): TODO | |||
:::: phase in [ 0, +π/2): TODO | |||
:::: phase in [+π/2, +π): TODO | |||
:: Sawtooth (Phase wraps in [–π,+π], increasing by ''Frequency''/''Sample Rate'' every sample) | |||
::: Real-valued signal types (Rises from -π to +π, then jumps back to -π): | |||
:::: ''Amplitude''·phase / (2π) + ''Amplitude''/2 + ''Offset'' | |||
::: Complex-valued signal types (TODO) | |||
: For selection with a variable, the following values should be used: | : For selection with a variable, the following values should be used: | ||
:* Constant = | :* Constant = <code>analog.GR_CONST_WAVE</code> | ||
:* Sine = | :* Sine = <code>analog.GR_SIN_WAVE</code> | ||
:* Cosine = | :* Cosine = <code>analog.GR_COS_WAVE</code> | ||
:* Square = | :* Square = <code>analog.GR_SQR_WAVE</code> | ||
:* Triangle = | :* Triangle = <code>analog.GR_TRI_WAVE</code> | ||
:* Sawtooth = | :* Sawtooth = <code>analog.GR_SAW_WAVE</code> | ||
; Frequency (''R'') | ; Frequency (''R'') |
Revision as of 19:03, 8 August 2022
Signal generator: generates a variety of waveforms.
Supports an output of type complex, float, int, and short
Parameters
(R): Run-time adjustable
- Sample Rate (R)
- Default value: samp_rate
- Sample rate (fs) is the average number of samples obtained in one second. Its units are samples per second or hertz e.g. 48,000 sample rate is 48 kHz.
- Waveform (R)
- options: [Constant, Sine, Cosine, Square, Triangle, Saw Tooth]
- Constant
- A constant value as specified by Amplitude + Offset
- Sine
- Real-valued signal types: Amplitude·sin(2π·Frequency/Sample Rate·n) + Offset
- Complex-valued signal types: Amplitude·[cos(2π·Frequency/Sample Rate·n) + 1j·sin(2π·Frequency/Sample Rate·n)] + Offset
- Cos
- Real-valued signal types: Amplitude·cos(2π·Frequency/Sample Rate·n) + Offset
- Complex-valued signal types (identical to Sin): Amplitude·cos(2π·Frequency/Sample Rate·n) + 1j·sin(2π·Frequency/Sample Rate·n) + Offset
- Square (Phase wraps in [–π,+π], increasing by Frequency/Sample Rate every sample)
- Real-valued signal types:
- phase < 0: Amplitude+Offset
- phase ≥ 0: Offset
- Complex-valued signal types (Real part: 0-centered π-wide square wave, Imag leads Real by 90°):
- phase in [-π, -π/2): Amplitude + 0j + Offset
- phase in [-π/2, 0): Amplitude + 1j·Amplitude + Offset
- phase in [ 0, +π/2): 0 + 1j·Amplitude + Offset
- phase in [+π/2, +π): 0 + 0j + Offset
- Real-valued signal types:
- Triangle (Phase wraps in [–π,+π], increasing by Frequency/Sample Rate every sample)
- Real-valued signal types:
- Phase in [-π, 0): Linear ramp from -Amplitude to +Amplitude (both + Offset)
- Phase in [0, +π): Linear ramp from +Amplitude to -Amplitude (both + Offset)
- Complex-valued signal types (Real part: triangle wave, rising in [-π,0), falling [0,+π), Imag leads Real by 90°):
- phase in [-π, -π/2): TODO
- phase in [-π/2, 0): TODO
- phase in [ 0, +π/2): TODO
- phase in [+π/2, +π): TODO
- Real-valued signal types:
- Sawtooth (Phase wraps in [–π,+π], increasing by Frequency/Sample Rate every sample)
- Real-valued signal types (Rises from -π to +π, then jumps back to -π):
- Amplitude·phase / (2π) + Amplitude/2 + Offset
- Complex-valued signal types (TODO)
- Real-valued signal types (Rises from -π to +π, then jumps back to -π):
- Constant
- For selection with a variable, the following values should be used:
- Constant =
analog.GR_CONST_WAVE
- Sine =
analog.GR_SIN_WAVE
- Cosine =
analog.GR_COS_WAVE
- Square =
analog.GR_SQR_WAVE
- Triangle =
analog.GR_TRI_WAVE
- Sawtooth =
analog.GR_SAW_WAVE
- Constant =
- Frequency (R)
- Frequency of the waveform (default: 1000)
- Amplitude (R)
- Amplitude of the output (default: 1)
- Offset (R)
- Offset from zero (default: 0)
- Initial Phase (Radians) (R)
- Default: 0
Message Ports
- cmd
- The 'cmd' message port accepts message pairs.
- 'freq' . float value
- 'ampl' . float value
- 'phase' . float value
- 'offset' . float value
- For GNU Radio 3.8, the messages dont work correctly with pairs, but they do work fine with a dictionary. This issue is explained here.
- The amplitude of the signal source can be changed to 0.5 by adding the following PMT to the message strobe block.
pmt.dict_add(pmt.make_dict(), pmt.intern("ampl"), pmt.from_double(0.5))
- The above command creates a dictionary and adds a pmt pair of ("ampl", 0.5) to the dictionary.
- freq
- The value of frequency in the signal source can be changed by connecting a message strobe. The Message PMT parameter can be set to pmt.from_float(new_freq). In this way, the frequency of the signal source will be changed to new_freq value after the specified period in the message strobe.
- The 'freq' message port has been
deprecated in 3.9
in favor of the 'cmd' message port.
Example Flowgraph
This flowgraph is for version 3.9+.
Example Output
Types of Waveforms:
Cosine (complex):
Constant:
Square:
Triangle:
Sawtooth:
Source Files
- C++ files
- sig_source_impl.cc
- Header files
- sig_source_impl.h
- Block definition
- analog_sig_source_x.block.yml