Rockwell Automation 5370-CMPK Color CVIM Module MATH-PAK User Manual

Page 35

Advertising
background image

Chapter 4

Defining Formulas

4–20

Operator Execution Hierarchy

The order and priority of execution of the operations defined in a formula,
where multiple operators are used, follows that of general mathematical
rules. Operators of higher priority are executed first. In cases of equal
priority, the operators are executed from left to right.

For example, multiplication and division have higher priority than addition
or subtraction.

This formula would first divide the results of gage 2 by 3, and then add the
result to the gage 1 result:

GAGE1 + GAGE2 / 3

Add operator

Divide operator

Prioritizing operations: You can place parentheses around an operator and
its operands in order to prioritize that operation – that is, the result of the
operation in parentheses will be used as an operand by another operator.

This formula would first add the result of gage 1 and gage 2, and then divides
the result by 2:

(GAGE1 + GAGE2) / 2

Add operator

Divide operator

In defining formulas, as in general mathematical practice, it is best to use
parentheses in formulas where multiple operators are used, to ensure the
formula is executed as expected, rather than relying on priority rules.

Nesting operations within a formula: “Nesting” of operations within a
formula can be employed, where a parenthetical portion is itself contained
within another parenthetical portion of the formula.

The formula below would first add 2 to the result of gage 2, then multiply
this result by the gage 1 result, and then subtract 2 from the product:

(GAGE1 * (GAGE2 + 2)) 2

Nested operation

Advertising