1 general rules – Micromod MOD: 30MLTraining Manual User Manual

Page 177

Advertising
background image

Training Manual

Expression Block Lab

11.4.1 General

Rules

For Boolean operators, data of any type is considered TRUE if non-zero. For logical
operations, all operands are scaled to DISCRETE during evaluation.

For comparison or arithmetic operations, all operands are scaled to floating point during
evaluation. DATE operands are expanded to include the century and treated as 4 byte
unsigned integers. Prior to applying the operator(s), if the year is in the range 0–89, 100 is
added to make comparisons work properly across the calendar year 2000 (valid for 1990
to 2089). Thus 3/18/95 (stored internally as $5F0312) is treated as $005F0312, or decimal
6226706, while 7/25/2012, (stored internally as $0C0719) is treated as $00700719, or
decimal 7341849. HEX and ASCII operands are not allowed.

Evaluation Results

The result of an expression evaluation is DISCRETE if the last operator processed was
logical, or FLOATING POINT if it was arithmetic. This result is then scaled to the
configured data types for the result and auxiliary result outputs of the expression block.

The MOMENTARY Operator

The MOMENTARY operator allows a user to embed an ‘edge detection’ in an expression.
The result of the MOMENTARY operation is TRUE only if its operand was FALSE in
the most recent evaluation and is now TRUE. Note that the MOMENTARY operator is
distinct from the MOMENTARY DISCRETE input data type.

The INTEGER Operator

The INTEGER operator removes the decimal portion of a number, leaving only the
integer portion. It does not round the number. For example, INT(12.678) = 12 and
INT(-746.21) = -746.

The Conditional Operators

The conditional operators (IF, THEN, and ELSE) let you specify when operations are
evaluated. The IF expression (between the IF and THEN conditionals) is evaluated first.
This expression may be enclosed in parentheses. When the calculated value of the IF
expression is TRUE (non-zero), the THEN expression is evaluated. When it is FALSE
(zero), the ELSE expression is evaluated. The ELSE expression is optional. When the IF
expression evaluates to FALSE and there is no ELSE, the result is not updated. Brackets
({}) should be used for nesting conditionals. If brackets are not present, an ELSE
expression is paired with the last unpaired IF. Notice how the brackets change the pairing
of the IF and ELSE expressions in the following example.

11 - 5

Advertising
This manual is related to the following products: