Skip to content

Limiter & Switching Blocks

Blocks that bound a signal or select between signals. Several carry discrete state and so introduce discrete transitions into the model.


Limiter with constant bounds.

lim block diagram

Syntax

& lim
x_i
x_j
{x_min}
{x_max}

x_i is the input, x_j is the (limited) output. x_min and x_max are constant bounds (data names, parameter names, or math expressions).

Internal states: none

Discrete variable: z{1,0,1}z \in \{-1, 0, 1\}

Equations

0={xjxiif z=0xjxmaxif z=1xjxminif z=10 = \begin{cases} x_j - x_i & \text{if } z = 0 \\ x_j - x_{max} & \text{if } z = 1 \\ x_j - x_{min} & \text{if } z = -1 \end{cases}

Discrete transitions

if z = 0:
if x_i > x_max:
z ← 1
else if x_i < x_min:
z ← -1
else if z = 1:
if x_i < x_max:
z ← 0
else: # z = -1
if x_i > x_min:
z ← 0

Initialization

if x_j > x_max:
z ← 1
else if x_j < x_min:
z ← -1
else:
z ← 0

Limiter with variable bounds.

limvb block diagram

Syntax

& limvb
x_i
x_min
x_max
x_j

x_i is the input; x_min and x_max are variable (state) lower and upper bounds; x_j is the (limited) output.

Internal states: none

Discrete variable: z{1,0,1}z \in \{-1, 0, 1\}

Equations

0={xjxiif z=0xjxmaxif z=1xjxminif z=10 = \begin{cases} x_j - x_i & \text{if } z = 0 \\ x_j - x_{max} & \text{if } z = 1 \\ x_j - x_{min} & \text{if } z = -1 \end{cases}

Discrete transitions

if z = 0:
if x_i > x_max:
z ← 1
else if x_i < x_min:
z ← -1
else if z = 1:
if x_i < x_max:
z ← 0
else: # z = -1
if x_i > x_min:
z ← 0

Initialization

if x_i > x_max:
z ← 1
else if x_i < x_min:
z ← -1
else:
z ← 0

Notes

Unlike lim, the bounds xminx_{min} and xmaxx_{max} are model states (variables) rather than fixed parameters, allowing dynamic limit variation during simulation.


Deadband.

db block diagram

Syntax

& db
x_i
x_j
{delta_1}
{s_1}
{a_1}
{delta_2}
{s_2}
{a_2}

x_i is the input, x_j is the output. Parameters δ1\delta_1, s1s_1, a1a_1, δ2\delta_2, s2s_2, a2a_2 are data names, parameter names, or math expressions.

Internal states: none

Discrete variable: z{0,1,1}z \in \{0, 1, -1\}

Equations

0={xjif z=0xjs2a2(xiδ2)if z=1xjs1a1(xiδ1)if z=10 = \begin{cases} x_j & \text{if } z = 0 \\ x_j - s_2 - a_2(x_i - \delta_2) & \text{if } z = 1 \\ x_j - s_1 - a_1(x_i - \delta_1) & \text{if } z = -1 \end{cases}

Discrete transitions

if z ∈ {0, 1}:
if x_i < delta_1:
z ← -1
else if z ∈ {-1, 0}:
if x_i > delta_2:
z ← 1
else if z ∈ {-1, 1}:
if delta_1 < x_i < delta_2:
z ← 0

Initialization

if x_i > delta_2:
z ← 1
else if x_i < delta_1:
z ← -1
else:
z ← 0

Notes

  • The data must satisfy δ1<δ2\delta_1 < \delta_2, a10a_1 \ge 0, and a20a_2 \ge 0.
  • A common special case is s1=s2=0s_1 = s_2 = 0 and a1=a2=1a_1 = a_2 = 1, although all values are permitted.
  • The pwlin4, pwlin5, or pwlin6 blocks can be used as alternatives.

Hysteresis.

hyst block diagram

Syntax

& hyst
x_i
x_j
{x_I}
{y_IB}
{y_IA}
{x_D}
{y_DB}
{y_DA}
{z0}

x_i is the input, x_j is the output. The parameters xIx_I, yIBy_{IB}, yIAy_{IA}, xDx_D, yDBy_{DB}, yDAy_{DA} define the hysteresis shape. z0 specifies the initial discrete state when the input starts in the indeterminate region.

Internal states: none

Discrete variable: z{1,1}z \in \{-1, 1\}

Equations

0={xjyIAyIAyDBxIxD(xixI)if z=1xjyDAyIByDAxIxD(xixD)if z=10 = \begin{cases} \displaystyle x_j - y_{IA} - \frac{y_{IA} - y_{DB}}{x_I - x_D}(x_i - x_I) & \text{if } z = 1 \\[8pt] \displaystyle x_j - y_{DA} - \frac{y_{IB} - y_{DA}}{x_I - x_D}(x_i - x_D) & \text{if } z = -1 \end{cases}

Discrete transitions

if z = -1:
if x_i > x_I:
z ← 1
else: # z = 1
if x_i < x_D:
z ← -1

Initialization

if x_i > x_I:
z ← 1
else if x_i < x_D:
z ← -1
else:
if z0 >= 0:
z ← 1
else:
z ← 0

Notes

At t=0t = 0, if xD<xi(0)<xIx_D < x_i(0) < x_I the initial operating branch is indeterminate. The system could operate on either the (yIA,yDB)(y_{IA}, y_{DB}) line (z=1z = 1) or the (yDA,yIB)(y_{DA}, y_{IB}) line (z=1z = -1). The user must therefore supply z0 to resolve the ambiguity.

If xi(0)<xDx_i(0) < x_D then zz is initialised to 1-1; if xi(0)>xIx_i(0) > x_I then zz is initialised to 11, and z0 is ignored in both cases.

The data must satisfy xD<xIx_D < x_I. The degenerate case xD=xIx_D = x_I is not allowed by this block but can be handled with the pwlin4 block.


Set the output state to one among nn input states, based on the value of a controlling state. Separate blocks exist for n=2,3,4n = 2, 3, 4 and 55.

switch block diagram

Syntax

& switch2
name of variable x_i(1)
name of variable x_i(2)
name of variable x_k (selector)
name of variable x_j (output)

For switch3switch5, prepend additional input variables xi(3)x_i(3) through xi(n)x_i(n) before xkx_k.

Internal States

None.

Discrete Variables

z{1,2,,n}z \in \{1, 2, \ldots, n\}

Equations

0=xjxi(z)0 = x_j - x_i(z)

Discrete Transitions

zmax ⁣(1,min ⁣(n,nint(xk)))z \leftarrow \max\!\left(1,\, \min\!\left(n,\, \text{nint}(x_k)\right)\right)

where nint\text{nint} returns the nearest integer.

Initialization

Same as discrete transitions.


Switch between two input states, based on the sign of a third input state.

swsign block diagram

Syntax

& swsign
name of variable x_i (selected when x_k >= 0)
name of variable x_j (selected when x_k < 0)
name of variable x_k (sign selector)
name of variable x_l (output)

Internal States

None.

Discrete Variables

z{1,2}z \in \{1, 2\}

Equations

0={xlxiif z=1xlxjif z=20 = \begin{cases} x_l - x_i & \text{if } z = 1 \\ x_l - x_j & \text{if } z = 2 \end{cases}

Discrete Transitions

if z = 1:
if x_k < 0: z ← 2
else if z = 2:
if x_k >= 0: z ← 1

Initialization

if x_k < 0: z ← 2
else: z ← 1