SineVariableFrequencyAndAmplitude
Sine voltage source with adjustable frequency and amplitude through external signals.
Generates a sine wave whose amplitude and frequency can be controlled dynamically through input connections. The component integrates the input frequency to compute the phase angle, then uses this phase to produce a sine wave output signal. The output formula is:
where phi evolves according to der(phi) = 2*π*frequency. This allows for creating time-varying oscillating signals with controllable parameters.
amplitude
↓
+-----+
frequency --→ | | --→ y
+-----+Usage
BlockComponents.SineVariableFrequencyAndAmplitude(phi0=0, offset=0)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
phi0 | Initial phase of the sine wave | – | 0 |
offset | Offset of the sine wave | – | 0 |
Connectors
amplitude- This connector represents a real signal as an input to a component (RealInput)frequency- This connector represents a real signal as an input to a component (RealInput)y- This connector represents a real signal as an output from a component (RealOutput)
Variables
| Name | Description | Units |
|---|---|---|
phi | Phase of the sine wave | rad |
Behavior
Source
# Sine voltage source with adjustable frequency and amplitude through external signals.
#
# Generates a sine wave whose amplitude and frequency can be controlled dynamically through
# input connections. The component integrates the input frequency to compute the phase angle,
# then uses this phase to produce a sine wave output signal. The output formula is:
#
# ```math
# y = offset + amplitude*sin(phi)
# ```
# where phi evolves according to `der(phi) = 2*π*frequency`. This allows for creating time-varying
# oscillating signals with controllable parameters.
#
# ```
# amplitude
# ↓
# +-----+
# frequency --→ | | --→ y
# +-----+
# ```
component SineVariableFrequencyAndAmplitude
# Input for controlling the amplitude of the sine wave
amplitude = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0}
}
}
}
# Input for controlling the frequency of the sine wave
frequency = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0}
}
}
}
# Output representing the resulting sine wave signal
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
"icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
}
}
}
# Initial phase of the sine wave
parameter phi0::Real = 0
# Offset of the sine wave
parameter offset::Real = 0
# Phase of the sine wave
variable phi::Angle
relations
initial phi = phi0
der(phi) = 2 * π * frequency
y = offset + amplitude * sin(phi)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/SineVariableFrequencyAndAmplitude.svg"}
}
}
endFlattened Source
# Sine voltage source with adjustable frequency and amplitude through external signals.
#
# Generates a sine wave whose amplitude and frequency can be controlled dynamically through
# input connections. The component integrates the input frequency to compute the phase angle,
# then uses this phase to produce a sine wave output signal. The output formula is:
#
# ```math
# y = offset + amplitude*sin(phi)
# ```
# where phi evolves according to `der(phi) = 2*π*frequency`. This allows for creating time-varying
# oscillating signals with controllable parameters.
#
# ```
# amplitude
# ↓
# +-----+
# frequency --→ | | --→ y
# +-----+
# ```
component SineVariableFrequencyAndAmplitude
# Input for controlling the amplitude of the sine wave
amplitude = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0}
}
}
}
# Input for controlling the frequency of the sine wave
frequency = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0}
}
}
}
# Output representing the resulting sine wave signal
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
"icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
}
}
}
# Initial phase of the sine wave
parameter phi0::Real = 0
# Offset of the sine wave
parameter offset::Real = 0
# Phase of the sine wave
variable phi::Angle
relations
initial phi = phi0
der(phi) = 2 * π * frequency
y = offset + amplitude * sin(phi)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/SineVariableFrequencyAndAmplitude.svg"}
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests