Skip to content
SlewRateLimiter.md

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.

dydt=clamp(uytd,falling,rising)

This component extends from SISO

Usage

SlewRateLimiter(rising, falling=-rising, td)

Parameters:

NameDescriptionUnitsDefault value
risingMaximum allowable positive rate of change for the output signals-1
fallingMaximum allowable negative rate of change for the output signals-1-rising
tdTime constant that scales the response speed to input changess

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

dy(t)dt=clamp(u(t)y(t)td,falling,rising)

Source

dyad
# 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
dyad
# 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.

julia
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"