Skip to content
Derivative.md

Derivative ​

Filtered derivative approximation with configurable time constant and gain.

Implements a filtered derivative that approximates the differentiation operation while avoiding noise amplification. The derivative approximation is implemented using a first-order filter with configurable time constant and gain parameters.

G(s)=Y(s)U(s)=kssT+1

The smaller the time constant T, the closer the approximation to an ideal derivative, though this increases sensitivity to noise.

This component extends from SISO

Usage ​

BlockComponents.Derivative(x0=0, T, k=1.0)

Parameters: ​

NameDescriptionUnitsDefault value
x0Initial value of the derivative-filter state–0
TTime constant of the filter (smaller values give better derivative approximation but more noise sensitivity)–
kGain factor applied to the derivative approximation–1

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)

Variables ​

NameDescriptionUnits
xInternal state variable of the first-order filter–

Behavior ​

dx(t)dt=u(t)−x(t)Ty(t)=k(u(t)−x(t))T

Source ​

dyad
"""
Filtered derivative approximation with configurable time constant and gain.

Implements a filtered derivative that approximates the differentiation operation while avoiding
noise amplification. The derivative approximation is implemented using a first-order filter with
configurable time constant and gain parameters.

math G(s) = \frac{Y(s)}{U(s)} = \frac{ks}


The smaller the time constant T, the closer the approximation to an ideal derivative, though this
increases sensitivity to noise.
"""
component Derivative
  extends SISO
  "Internal state variable of the first-order filter"
  variable x::Real
  "Initial value of the derivative-filter state"
  parameter x0::Real = 0
  "Time constant of the filter (smaller values give better derivative approximation but more noise sensitivity)"
  parameter T::Real
  "Gain factor applied to the derivative approximation"
  parameter k::Real = 1.0
relations
  initial x = x0
  der(x) = (u - x) / T
  y = (k / T) * (u - x)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Derivative.svg"}
  }
}
end
Flattened Source
dyad
"""
Filtered derivative approximation with configurable time constant and gain.

Implements a filtered derivative that approximates the differentiation operation while avoiding
noise amplification. The derivative approximation is implemented using a first-order filter with
configurable time constant and gain parameters.

math G(s) = \frac{Y(s)}{U(s)} = \frac{ks}


The smaller the time constant T, the closer the approximation to an ideal derivative, though this
increases sensitivity to noise.
"""
component Derivative
  "Input signal port"
  u = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0},
        "diagram": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      }
    }
  }
  "Output signal port"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Internal state variable of the first-order filter"
  variable x::Real
  "Initial value of the derivative-filter state"
  parameter x0::Real = 0
  "Time constant of the filter (smaller values give better derivative approximation but more noise sensitivity)"
  parameter T::Real
  "Gain factor applied to the derivative approximation"
  parameter k::Real = 1.0
relations
  initial x = x0
  der(x) = (u - x) / T
  y = (k / T) * (u - x)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Derivative.svg"}
  }
}
end


Test Cases ​

No test cases defined.