Compute/Math Instructions

The compute/math instructions evaluate arithmetic operations using an expression or a specific arithmetic instruction.
Available Instructions
Ladder Diagram
Function Block Diagram
FBD Block
FBD Function
Structured Text
If you want to:
Use this instruction:
evaluate an expression
CPT
add two values
ADD
subtract two values
SUB
multiply two values
MUL
divide two values
DIV
determine the remainder after one value is divided by another
MOD
calculate the square root of a value
SQRT
take the opposite sign of a value
NEG
take the absolute value of a value
ABS
You can mix data types, but loss of accuracy and rounding error might occur and the instruction takes more time to execute. Check the S:V bit to see whether the result was truncated.
The bold data types indicate optimal data types. An instruction executes faster and requires less memory if all the operands of the instruction use the same optimal data type, typically DINT or REAL.
A compute/math instruction executes once each time the instruction is scanned as long as the rung-condition-in is true. If you want the expression evaluated only once, use any one-shot instruction to trigger the instruction.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.