Skip to content
LIBRARY
DelayLine.md

DelayLine ​

A tapped delay line for building preview vectors. The output array carries the input together with all of its delays, ordered as the preview inputs of the MPC components expect: y[N] is the current input (the value furthest ahead when the input is a schedule known N - 1 samples in advance), y[i] is the input delayed N - i samples, and y[1] — the most-delayed tap — is the value that applies now. Feeding a disturbance schedule that runs N - 1 samples ahead of real time into u therefore makes y connectable in one step to the d input of an MPC component with disturbance_preview = true and Np = N, while y[1] is the disturbance to apply to the plant.

Usage ​

MPCComponents.DelayLine()

Parameters: ​

NameDescriptionUnitsDefault value
NNumber of taps: the input plus N - 1 unit delays–2
Nm1Number of unit delays (derived)–N - 1
has_delaysWhether the line contains any delays (derived)–N > 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)

Behavior ​

Behavior of this component cannot be rendered because it includes path variables.

Source ​

dyad
"""
A tapped delay line for building preview vectors. The output array carries the input together
with all of its delays, ordered as the preview inputs of the MPC components expect: `y[N]` is the
current input (the value furthest ahead when the input is a schedule known `N - 1` samples in
advance), `y[i]` is the input delayed `N - i` samples, and `y[1]` — the most-delayed tap — is the
value that applies now. Feeding a disturbance schedule that runs `N - 1` samples ahead of real
time into `u` therefore makes `y` connectable in one step to the `d` input of an MPC component
with `disturbance_preview = true` and `Np = N`, while `y[1]` is the disturbance to apply to the
plant.
"""
component DelayLine@[input clk extends Discrete]
  "Input signal; appears undelayed as the last output element"
  u = RealInput@[clk]() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 450, "x2": 0, "y2": 550}}}
  }
  "The taps: y[N] is the current input, y[i] the input delayed N - i samples, y[1] the oldest value"
  y = [RealOutput@[clk]() for i in 1:N] {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 450, "x2": 1100, "y2": 550}}}
  }
  "Number of taps: the input plus N - 1 unit delays"
  structural parameter N::Integer = 2
  "Number of unit delays (derived)"
  final structural parameter Nm1::Integer = N - 1
  "Whether the line contains any delays (derived)"
  final structural parameter has_delays::Boolean = N > 1
  delays = [DiscreteComponents.UnitDelay() for i in 1:Nm1] if has_delays {
    "Dyad": {"placement": {"diagram": {"x1": 450, "x2": 550, "y1": 450, "y2": 550}}}
  }
relations
  if has_delays
    connect(u, delays[1].u, y[N]) {}
    for i in 2:Nm1
      connect(delays[i - 1].y, delays[i].u)
    end
    for i in 1:Nm1
      connect(delays[Nm1 + 1 - i].y, y[i])
    end
  else
    connect(u, y[1]) {}
  end
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MPCComponents/DelayLine.svg"},
    "doc": {"behavior": false}
  }
}
end
Flattened Source
dyad
"""
A tapped delay line for building preview vectors. The output array carries the input together
with all of its delays, ordered as the preview inputs of the MPC components expect: `y[N]` is the
current input (the value furthest ahead when the input is a schedule known `N - 1` samples in
advance), `y[i]` is the input delayed `N - i` samples, and `y[1]` — the most-delayed tap — is the
value that applies now. Feeding a disturbance schedule that runs `N - 1` samples ahead of real
time into `u` therefore makes `y` connectable in one step to the `d` input of an MPC component
with `disturbance_preview = true` and `Np = N`, while `y[1]` is the disturbance to apply to the
plant.
"""
component DelayLine
  "Input signal; appears undelayed as the last output element"
  u = RealInput@[clk]() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 450, "x2": 0, "y2": 550}}}
  }
  "The taps: y[N] is the current input, y[i] the input delayed N - i samples, y[1] the oldest value"
  y = [RealOutput@[clk]() for i in 1:N] {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 450, "x2": 1100, "y2": 550}}}
  }
  "Number of taps: the input plus N - 1 unit delays"
  structural parameter N::Integer = 2
  "Number of unit delays (derived)"
  final structural parameter Nm1::Integer = N - 1
  "Whether the line contains any delays (derived)"
  final structural parameter has_delays::Boolean = N > 1
  delays = [DiscreteComponents.UnitDelay() for i in 1:Nm1] if has_delays {
    "Dyad": {"placement": {"diagram": {"x1": 450, "x2": 550, "y1": 450, "y2": 550}}}
  }
relations
  if has_delays
    connect(u, delays[1].u, y[N]) {}
    for i in 2:Nm1
      connect(delays[i - 1].y, delays[i].u)
    end
    for i in 1:Nm1
      connect(delays[Nm1 + 1 - i].y, y[i])
    end
  else
    connect(u, y[1]) {}
  end
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MPCComponents/DelayLine.svg"},
    "doc": {"behavior": false}
  }
}
end


Test Cases ​

No test cases defined.

  • Examples

  • Experiments

  • Analyses