Engee documentation

Edge tracking operators

In addition to the operators and indicators from the articles Operators of temporal logic and Indicators of change, edge tracking operators can be set on transitions stateflow library transition.

Front tracking operators are functions rising, falling and crossing, which return the logical value true when the signal changes in a certain way. This allows the finite automaton to determine the exact moment of switching: not by the current value of the signal, but by its change in time.

What is a signal change and an edge

In digital systems, signals are often represented by logical values - logic 0 (false) and logic 1 (true). A change in such a case is a transition between these two states.

In continuous systems (e.g. with analogue signals), the values can be any numerical value, and the moment when the signal crosses a certain threshold - especially the value zero - is considered important.

Changes in the signal are called fronts. Two main types are distinguished:

  • Rising edge - the transition of a signal across 0 from a smaller value to a larger one (e.g. from -1 to 0.5);

  • Decreasing front - signal transition through 0 from a larger value to a smaller one (for example, from 1 to -0.2).

Logic of triggering operators

Each of the operators (rising, falling, crossing) is an expression that returns the value true only when the signal changes in a certain way. At all other times it is false.

Let’s consider the triggering conditions of each operator.

Operator rising(x)

The rising(x) operator returns true at the moment when the signal x crosses zero from bottom to top (increasing).

This occurs in two cases:

  1. The previous value of x was negative and the current value has become zero or positive;

  2. The previous value of x was zero and the current value has become positive.

Thus, rising(x) is a detector of a transition in the positive direction.

For example, let the variable x change from -0.20.1. The rising(x) operator will return true in this case, since there has been a zero crossing from bottom to top. If x changes from 0.1 to -0.1, the operator will not work.

Similarly, rising(x - 0.5) tracks the moment x crosses the value 0.5 from bottom to top. For example:

state machines tracking signal operators 3

  • x was 0.4, became 0.6rising(x - 0.5) will return true;

  • x was 0.6, became 0.4rising(x - 0.5) will return false.

The operator falling(x)

The falling(x) operator returns true when the signal x crosses zero from top to bottom. It is triggered when:

  1. A previous positive value of x if the current value is zero or negative;

  2. Previous zero value of x if the current value has become negative.

Thus, falling(x) responds to a transition in the negative direction.

+ Example:

  • x was 0.2, became -0.1falling(x) will return true;

  • x was -0.1, became -0.2 → will not work.

For falling(x - 0.5) is similar: the operator will trigger when x crosses 0.5 from top to bottom. For example:

state machines tracking signal operators 2

  • x changes from 0.6 to 0.4 → triggers;

  • x varies from 0.4 to 0.6 → does not trigger.

Operator crossing(x).

The crossing(x) operator is a general-purpose operator that returns true any time the signal crosses zero (or other specified threshold), regardless of direction. It is triggered under one of the following conditions:

  1. The previous value was positive and the current value was zero or negative;

  2. The previous value was zero and the current value was non-zero;

  3. The previous value was negative and the current value is zero or positive.

Thus, the crossing(x) operator captures any transition through zero - both up (increasing) and down (decreasing). For example:

state machines tracking signal operators 1

  • x changes from 0.6 to 0.4crossing(x - 0.5) will return true;

  • x changes from 0.4 to 0.6 → also true;

  • x remains below 0.5 or above 0.5, does not cross the threshold → false.


Special attention should be paid to how equality to zero is handled. Unlike the simple x > 0 condition, these operators do not ignore zero, but treat it as a boundary condition that plays an important role in the logic of transitions.

For example:

  • If the signal was zero and became positive → this is considered a rising edge;

  • If it was zero and became negative → it is a falling edge;

  • If was zero and became non-zero (any) → it is a crossing trigger.