Ramp
Generates a linearly increasing signal from an offset to a target value over a specified duration.
The ramp component produces an output signal that starts at the offset value, then increases linearly to reach offset+height over the specified duration. After the duration elapses, the output remains constant at the final value.
This component extends from Signal
Usage
BlockComponents.Ramp(start_time=0.0, offset=0.0, duration, height)
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 |
duration | Duration of the ramp transition | s | |
height | Total height (amplitude) of the ramp | – |
Connectors
y- This connector represents a real signal as an output from a component (RealOutput)
Behavior
Source
dyad
# Generates a linearly increasing signal from an offset to a target value over a specified duration.
#
# The ramp component produces an output signal that starts at the `offset` value, then increases
# linearly to reach `offset`+`height` over the specified `duration`. After the `duration` elapses, the
# output remains constant at the final value.
#
# ```math
# y = \begin{cases}
# \text{offset}, & \text{if } t < \text{start\_time} \\
# \text{offset} + (t - \text{start\_time}) \cdot \frac{\text{height}}{\text{duration}}, & \text{if } \text{start\_time} \leq t < \text{start\_time} + \text{duration} \\
# \text{offset} + \text{height}, & \text{if } t \geq \text{start\_time} + \text{duration}
# \end{cases}
# ```
component Ramp
extends Signal
# Duration of the ramp transition
parameter duration::Time
# Total height (amplitude) of the ramp
parameter height::Real
relations
y = ifelse(start_time < time, ifelse(time < start_time + duration, offset + (time - start_time) * height / duration, offset + height), offset)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/Ramp.svg"}
}
}
endFlattened Source
dyad
# Generates a linearly increasing signal from an offset to a target value over a specified duration.
#
# The ramp component produces an output signal that starts at the `offset` value, then increases
# linearly to reach `offset`+`height` over the specified `duration`. After the `duration` elapses, the
# output remains constant at the final value.
#
# ```math
# y = \begin{cases}
# \text{offset}, & \text{if } t < \text{start\_time} \\
# \text{offset} + (t - \text{start\_time}) \cdot \frac{\text{height}}{\text{duration}}, & \text{if } \text{start\_time} \leq t < \text{start\_time} + \text{duration} \\
# \text{offset} + \text{height}, & \text{if } t \geq \text{start\_time} + \text{duration}
# \end{cases}
# ```
component Ramp
# 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
# Duration of the ramp transition
parameter duration::Time
# Total height (amplitude) of the ramp
parameter height::Real
relations
y = ifelse(start_time < time, ifelse(time < start_time + duration, offset + (time - start_time) * height / duration, offset + height), offset)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/Ramp.svg"}
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests