Engee documentation

Signal Edge Tracking Operators

In addition to the operators and indicators from the articles Temporal logic operators and Indicators of changes, on transitions stateflow library transition signal edge tracking operators can be specified.

The signal edge tracking operators are the functions rising, falling and crossing', which return the boolean value `true at the moment the signal changes in a certain way. This allows the state machine to accurately determine the moment of switching: not by the current value of the signal, but by its change over time.

What is the signal change and the front

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

In continuous systems (for example, with analog signals), the values can be any numeric, and the moment when the signal crosses a certain threshold is considered important — especially the value zero.

Signal changes are called edges. There are two main types:

  • Rising edge — signal transition through 0 from a lower value to a higher value (for example, from -1 to 0.5);

  • Falling edge — the transition of the signal through 0 from a higher value to a lower one (for example, from 1 to -0.2).

The logic of operator operation

Each of the operators (rising, falling, crossing) is an expression that returns the value true only when the signal changes in a certain way. The rest of the time is `false'.

Let’s consider the conditions of operation of each operator.

The rising(x) operator

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

This happens 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.

So, 'rising(x)` is a detector for a transition in the positive direction.

For example, let the variable x change from -0'.20.1. The rising(x) operator in this case will return true, since there was a zero crossing from bottom to top. If 'x` changes from 0.1 to -0.1, then the * operator will not work*.

Similarly, rising(x - 0.5) tracks the moment when 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) returns `false'.

The falling(x) operator

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

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

  2. The previous zero value of `x', if the current value has become negative.

So, falling(x) reacts to a transition in a negative direction.

+ Example:

  • 'x` was 0.2, became -0.1falling(x) returns true;

  • 'x` was -0.1', became `0.2 → won’t work.

For falling(x - 0.5), it is the same: the operator will be triggered 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 → triggered;

  • The x changes from 0.4 to 0'.6 → does not work.

The crossing(x) operator

The crossing(x) operator is a universal operator that returns true at any signal crossing through zero (or another specified threshold), regardless of the direction. It is triggered under one of the following conditions:

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

  2. The previous value was zero, and the current value is nonzero.;

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

So, the crossing(x) operator captures any transition through zero — both upward (ascending) and downward (descending). For example:

state machines tracking signal operators 1

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

  • The x changes from 0.4 to 0'.6 → also true;

  • The x remains below 0.5 or higher than 0.5, does not cross the threshold → `false'.


Special attention should be paid to how equality to zero is handled. Unlike the simple condition `x > 0', these operators do not ignore zero, but consider it as a boundary state 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 → this is a falling front;

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