SlewRateLimiter
Limits the rate of change of a signal between specified rising and falling rates.
A slew rate limiter that constrains how quickly the output signal can change in response to input variations. It ensures the derivative of the output remains between the specified maximum rising and falling rates. The output initially equals the input, and thereafter changes at a rate determined by the difference between input and output, scaled by the time derivative constant, and limited by the rising
and falling
rate parameters.
This component extends from SISO
Usage
SlewRateLimiter(rising, falling=-rising, td)
Parameters:
Name | Description | Units | Default value |
---|---|---|---|
rising | Maximum allowable positive rate of change for the output signal | s-1 | |
falling | Maximum allowable negative rate of change for the output signal | s-1 | -rising |
td | Time constant that scales the response speed to input changes | s |
Connectors
u
- 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
)
Behavior
Source
# Limits the rate of change of a signal between specified rising and falling rates.
#
# A slew rate limiter that constrains how quickly the output signal can change in response
# to input variations. It ensures the derivative of the output remains between the specified
# maximum rising and falling rates. The output initially equals the input, and thereafter
# changes at a rate determined by the difference between input and output, scaled by the time
# derivative constant, and limited by the `rising` and `falling` rate parameters.
#
# ```math
# \frac{dy}{dt} = \text{clamp}\left(\frac{u-y}{td}, \text{falling}, \text{rising}\right)
# ```
component SlewRateLimiter
extends SISO
# Maximum allowable positive rate of change for the output signal
parameter rising::DecayConstant
# Maximum allowable negative rate of change for the output signal
parameter falling::DecayConstant = -rising
# Time constant that scales the response speed to input changes
parameter td::Time
relations
initial y = u
der(y) = clamp((u-y)/td, falling, rising)
end
Flattened Source
# Limits the rate of change of a signal between specified rising and falling rates.
#
# A slew rate limiter that constrains how quickly the output signal can change in response
# to input variations. It ensures the derivative of the output remains between the specified
# maximum rising and falling rates. The output initially equals the input, and thereafter
# changes at a rate determined by the difference between input and output, scaled by the time
# derivative constant, and limited by the `rising` and `falling` rate parameters.
#
# ```math
# \frac{dy}{dt} = \text{clamp}\left(\frac{u-y}{td}, \text{falling}, \text{rising}\right)
# ```
component SlewRateLimiter
# Input signal port
u = RealInput() [{
"Dyad": {
"placement": {"icon": {"iconName": "input", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
}
}]
# Output signal port
y = RealOutput() [{
"Dyad": {
"placement": {"icon": {"iconName": "output", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
}
}]
# Maximum allowable positive rate of change for the output signal
parameter rising::DecayConstant
# Maximum allowable negative rate of change for the output signal
parameter falling::DecayConstant = -rising
# Time constant that scales the response speed to input changes
parameter td::Time
relations
initial y = u
der(y) = clamp((u-y)/td, falling, rising)
metadata {}
end
Test Cases
This is setup code, that must be run before each test case.
using BlockComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames
snapshotsdir = joinpath(dirname(dirname(pathof(BlockComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/BlockComponents/77kIK/test/snapshots"
Related
Examples
Experiments
Analyses
Tests