Triangular ​
Triangular waveform generator with configurable amplitude and frequency.
Produces a continuous triangular wave signal that oscillates between -amplitude and +amplitude values. The triangular wave is generated using modulo arithmetic on the time variable, creating a periodic signal with the specified frequency. The component begins generating the waveform only after the start_time is reached; before that point, it outputs the offset value. The period of the wave is automatically calculated as the inverse of the frequency.
This component extends from Signal
Usage ​
BlockComponents.Triangular(start_time=0.0, offset=0.0, amplitude, frequency, period=1 / frequency)
Parameters: ​
| Name | Description | Units | Default value |
|---|---|---|---|
start_time | Time at which the signal starts changing from its offset value | s | 0 |
offset | Constant value added to the signal output | – | 0 |
amplitude | Maximum amplitude of the triangular wave | – | |
frequency | Frequency of the triangular wave | Hz |
Connectors ​
y- This connector represents a real signal as an output from a component (RealOutput)
Behavior ​
Source ​
dyad
"""
Triangular waveform generator with configurable amplitude and frequency.
Produces a continuous triangular wave signal that oscillates between -amplitude and
+amplitude values. The triangular wave is generated using modulo arithmetic on the
time variable, creating a periodic signal with the specified frequency. The component
begins generating the waveform only after the start_time is reached; before that point,
it outputs the offset value. The period of the wave is automatically calculated as the
inverse of the frequency.
"""
component Triangular
extends Signal
"Maximum amplitude of the triangular wave"
parameter amplitude::Real
"Frequency of the triangular wave"
parameter frequency::Frequency
"Period of the triangular wave, calculated as inverse of frequency"
final parameter period::Period = 1 / frequency
relations
y = offset + ifelse(time >= start_time, 4 * amplitude * frequency * abs(abs(mod(time - period / 4 - start_time, period)) - period / 2) - amplitude, 0)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/Triangular.svg"}
}
}
endFlattened Source
dyad
"""
Triangular waveform generator with configurable amplitude and frequency.
Produces a continuous triangular wave signal that oscillates between -amplitude and
+amplitude values. The triangular wave is generated using modulo arithmetic on the
time variable, creating a periodic signal with the specified frequency. The component
begins generating the waveform only after the start_time is reached; before that point,
it outputs the offset value. The period of the wave is automatically calculated as the
inverse of the frequency.
"""
component Triangular
"Real-valued output connector for the component"
y = RealOutput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
"diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
}
}
}
"Time at which the signal starts changing from its offset value"
parameter start_time::Time = 0.0
"Constant value added to the signal output"
parameter offset::Real = 0.0
"Maximum amplitude of the triangular wave"
parameter amplitude::Real
"Frequency of the triangular wave"
parameter frequency::Frequency
"Period of the triangular wave, calculated as inverse of frequency"
final parameter period::Period = 1 / frequency
relations
y = offset + ifelse(time >= start_time, 4 * amplitude * frequency * abs(abs(mod(time - period / 4 - start_time, period)) - period / 2) - amplitude, 0)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/Triangular.svg"}
}
}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses
Tests