Skip to content

Automata & Timer Blocks

Blocks driven by discrete logic rather than differential equations: automata that switch on signal conditions, and timers that fire after a delay.


Finite State Automaton.

fsa block diagram

This block forces a set of nn algebraic equations. There are ss possible sets, each corresponding to a value of the discrete state zz. Transitions between sets occur when Boolean expressions evaluate to true.

Syntax

The block is specified via an inline example. For s=3s = 3 states and n=2n = 2 algebraic constraints per state:

& fsa
initial_state
# 1
algebraic constraint No. 1
algebraic constraint No. 2
-> 2
boolean expression C1
# 2
algebraic constraint No. 3
algebraic constraint No. 4
-> 1
boolean expression C2
-> 3
boolean expression C3
-> 3
boolean expression C4
# 3
algebraic constraint No. 5
algebraic constraint No. 6
-> 1
boolean expression C5
##

Internal states: none

Discrete variable: zz. The index of the currently active state

Syntax rules

TokenMeaning
# NBegins the section for state NN. States must be numbered consecutively from 1 to ss in increasing order.
##Marks the end of the state list.
-> NDeclares a transition to state NN. The following line is the Boolean expression that triggers the transition.
Second lineInteger specifying the initial state of the automaton.

Notes

  • The number nn of algebraic constraints must be identical across all states.
  • Multiple transitions from the same state to the same target state are permitted (e.g., two separate conditions C3 and C4 both targeting state 3 in the example). Alternatively a single transition with the combined condition C3 or C4 may be used.
  • Transitions and algebraic constraints may involve any model states and parameters.

Two-state automaton with transitions based on signs of two inputs.

tsa block diagram

The output state xkx_k can take two values: v1v_1 or v2v_2. When xk=v1x_k = v_1, a positive x1x_1 triggers the transition to v2v_2; when xk=v2x_k = v_2, a positive x2x_2 triggers the return to v1v_1.

Syntax

& 2sa
name of variable x_1 (trigger for transition to v_2)
name of variable x_2 (trigger for transition to v_1)
name of variable x_k (output)
data/parameter/expression for v_1
data/parameter/expression for v_2

Internal States

None.

Discrete Variables

z{1,2}z \in \{1, 2\} represents the automaton state.

Equations

0={xkv1if z=1xkv2if z=20 = \begin{cases} x_k - v_1 & \text{if } z = 1 \\ x_k - v_2 & \text{if } z = 2 \end{cases}

Discrete Transitions

if z = 1 and x_1 > 0: z ← 2
else if z = 2 and x_2 > 0: z ← 1

Initialization

z1(xk=v1 is assumed initially)z \leftarrow 1 \quad (x_k = v_1 \text{ is assumed initially})


Timer with varying delay. The delay is a piecewise linear function of the monitored variable. Separate blocks exist for n=1,2,3,4,5n = 1, 2, 3, 4, 5 and 1111 characteristic points, named timer1 to timer5 and timer11.

timer block diagram

If xix_i is smaller than a threshold v1v_1, the output xjx_j is zero. Otherwise, xjx_j changes from zero to one at time t+τ(xi)t^\star + \tau(x_i), where tt^\star is the time at which xix_i first exceeded v1v_1 and τ(xi)\tau(x_i) is a piecewise linear function of xix_i defined by the (vk,Tk)(v_k, T_k) pairs.

Syntax

& timer1
name of variable x_i
name of variable x_j
data/parameter/expression for v_1
data/parameter/expression for T_1

For timer2 to timer5, append additional (vk,Tk)(v_k, T_k) pairs up to the required nn. timer11 takes 11 pairs (22 parameters).

Internal States

x1x_1 (elapsed time counter)

Discrete Variables

z{1,0,1}z \in \{-1, 0, 1\}

Equations

0={xjif z{1,0}xj1if z=10 = \begin{cases} x_j & \text{if } z \in \{-1, 0\} \\ x_j - 1 & \text{if } z = 1 \end{cases} {0=x1if z=1x˙1=1if z=0x˙1=0if z=1\begin{cases} 0 = x_1 & \text{if } z = -1 \\ \dot{x}_1 = 1 & \text{if } z = 0 \\ \dot{x}_1 = 0 & \text{if } z = 1 \end{cases}

Discrete Transitions

if z = -1:
if x_i >= v_1: z ← 0
else (z = 0 or 1):
if x_i < v_1: z ← -1
if z = 0:
if x_1 >= τ(x_i): z ← 1

Initialization

x10,z1x_1 \leftarrow 0, \qquad z \leftarrow -1

Notes

  • The viv_i values must be non-decreasing: v1v2vnv_1 \le v_2 \le \cdots \le v_n.
  • Typical use: approximating an inverse-time characteristic with T1T2TnT_1 \ge T_2 \ge \cdots \ge T_n.
  • Non-decreasing TT values are also allowed (i.e., T1T2T_1 \le T_2 is permitted).
  • If xi>v1x_i > v_1 at t=0t = 0, xjx_j will trip to one after τ(xi)\tau(x_i) unless xix_i drops below v1v_1 first.

Timer with varying delay. The delay is a staircase function of the monitored variable. Separate blocks exist for n=1,2,3,4,5n = 1, 2, 3, 4, 5 and 66 characteristic points.

timersc block diagram

Identical behaviour to timer except that the delay function τ(xi)\tau(x_i) is a staircase (step) function instead of a piecewise linear interpolation.

Syntax

& timersc1
name of variable x_i
name of variable x_j
data/parameter/expression for v_1
data/parameter/expression for T_1

For timersc2timersc6, append additional (vk,Tk)(v_k, T_k) pairs up to the required nn.

Internal States

x1x_1 (elapsed time counter)

Discrete Variables

z{1,0,1}z \in \{-1, 0, 1\}

Equations

0={xjif z{1,0}xj1if z=10 = \begin{cases} x_j & \text{if } z \in \{-1, 0\} \\ x_j - 1 & \text{if } z = 1 \end{cases} {0=x1if z=1x˙1=1if z=0x˙1=0if z=1\begin{cases} 0 = x_1 & \text{if } z = -1 \\ \dot{x}_1 = 1 & \text{if } z = 0 \\ \dot{x}_1 = 0 & \text{if } z = 1 \end{cases}

Discrete Transitions

if z = -1:
if x_i >= v_1: z ← 0
else (z = 0 or 1):
if x_i < v_1: z ← -1
if z = 0:
if x_1 >= τ(x_i): z ← 1

Initialization

x10,z1x_1 \leftarrow 0, \qquad z \leftarrow -1

Notes

  • The viv_i values must be non-decreasing: v1v2vnv_1 \le v_2 \le \cdots \le v_n.
  • The staircase characteristic is typically used to approximate an inverse-time protection curve.
  • Non-decreasing TT values are also allowed.
  • If xi>v1x_i > v_1 at t=0t = 0, xjx_j trips to one after τ(xi)\tau(x_i) unless xix_i drops below v1v_1 first.