7 Calculations | 121
Boolean Workaround
false !1
true !0
Example:
When delaying a boolean signal by one sample, it is necessary to specify the ini-
tial value as a boolean:
State_Register(voltage > 0, !1)
Signals
A signal is a sequence of samples each having a value. The signal's values can be
accessed in a formula by adding the signal to the formula. It will be displayed as a
box with the name of the signal.
Implicitly each signal also has a timestamp for each sample. Some operations like
the Integral use the timestamps to react to the passing of time. To explicitly
access the time in a formula use the Master() function.
Examples:
Delta(signal) calculates the difference of consecutive signal values.
Delta(Master()) calculates the difference of consecutive signal
timestamps, e.g. Delta(Master())+0*signal.
Operators
Operators are a compact way of specifying frequently used calculation oper-
ations like addition or multiplication. When multiple operators are used the order
in which they are evaluated needs to be defined. The order can be explicitly spe-
cified by using parentheses. If there are no parentheses, the order is determined
implicitly using the precedence of the operators. Higher precedence operators
are evaluated first, followed by lower precedence. Within the same precedence
group, operations are evaluated from left to right or from right to left depending
on the operator.
Examples:
a + b + c = (a + b) + c
a + b * c = a + (b * c)
- - a = -(-a)
cond1? val1: cond2? val2: val3 = cond1? val1: (cond2?
val2: val3)
The following table shows the precedence of operators. The operators on the
first line have the highest precedence. Operators on the same line have the same
precedence and the evaluation direction is specified as left-to-right or right-to-
left.
MDA V8 | User Guide