Skip to content
SecondOrder.md

SecondOrder ​

Second-order filter with configurable gain, bandwidth, and damping ratio.

A filter that implements a second-order transfer function with configurable gain k, bandwidth w, and relative damping d. The filter can be configured to achieve different response characteristics by adjusting the damping ratio: critically damped (d=1), under-damped (d<1), or over-damped (d>1). A damping value of d=1/√2 creates a Butterworth filter with maximally flat frequency response. The filter is characterized by the transfer function

Y(s)/U(s)=kâ‹…w2s2+2dâ‹…wâ‹…s+w2

This component extends from SISO

Usage ​

BlockComponents.SecondOrder(k=1.0, w=1.0, d=1.0)

Parameters: ​

NameDescriptionUnitsDefault value
kGain–1
wBandwidth (angular frequency)–1
dRelative damping–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
xState of SecondOrder filter–
xdDerivative state of SecondOrder filter–

Behavior ​

dx(t)dt=xd(t)dxd(t)dt=(−2dxd(t)+(−x(t)+ku(t))w)wy(t)=x(t)

Source ​

dyad
"""
Second-order filter with configurable gain, bandwidth, and damping ratio.

A filter that implements a second-order transfer function with configurable gain k,
bandwidth w, and relative damping d. The filter can be configured to achieve different
response characteristics by adjusting the damping ratio: critically damped (d=1),
under-damped (d<1), or over-damped (d>1). A damping value of d=1/√2 creates a Butterworth
filter with maximally flat frequency response. The filter is characterized by the transfer
function

math Y(s)/U(s) = \frac{k \cdot w^2}{s^2 + 2d \cdot w \cdot s + w^2}

"""
component SecondOrder
  extends SISO
  "State of SecondOrder filter"
  variable x::Real
  "Derivative state of SecondOrder filter"
  variable xd::Real
  "Gain"
  parameter k::Real = 1.0
  "Bandwidth (angular frequency)"
  parameter w::Real = 1.0
  "Relative damping"
  parameter d::Real = 1.0
relations
  der(x) = xd
  der(xd) = w * (w * (k * u - x) - 2 * d * xd)
  y = x
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/SecondOrder.svg"}
  }
}
end
Flattened Source
dyad
"""
Second-order filter with configurable gain, bandwidth, and damping ratio.

A filter that implements a second-order transfer function with configurable gain k,
bandwidth w, and relative damping d. The filter can be configured to achieve different
response characteristics by adjusting the damping ratio: critically damped (d=1),
under-damped (d<1), or over-damped (d>1). A damping value of d=1/√2 creates a Butterworth
filter with maximally flat frequency response. The filter is characterized by the transfer
function

math Y(s)/U(s) = \frac{k \cdot w^2}{s^2 + 2d \cdot w \cdot s + w^2}

"""
component SecondOrder
  "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}
      }
    }
  }
  "State of SecondOrder filter"
  variable x::Real
  "Derivative state of SecondOrder filter"
  variable xd::Real
  "Gain"
  parameter k::Real = 1.0
  "Bandwidth (angular frequency)"
  parameter w::Real = 1.0
  "Relative damping"
  parameter d::Real = 1.0
relations
  der(x) = xd
  der(xd) = w * (w * (k * u - x) - 2 * d * xd)
  y = x
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/SecondOrder.svg"}
  }
}
end


Test Cases ​

No test cases defined.