Math
Math instructions copy values and compute: add, subtract, multiply, divide.
What it does
They run when the rung is true and write the result into a destination variable. MOVE copies a value; ADD, SUB, MUL, DIV and MOD work on two values; CPT computes a whole expression. Watch the result type: an integer division drops the decimals.
When to use it
Scale a measurement, compute a flow, change a preset, convert units, total a production.
In this category
- MOVEEUMOVUSMOVEMOVMove (MOVE)Copies IN into OUT when the rung is 1.
- ADDAddOUT := IN1 + IN2 when the rung is 1.
- SUBSubtractOUT := IN1 − IN2 when the rung is 1.
- MULMultiplyOUT := IN1 × IN2 when the rung is 1.
- DIVDivideOUT := IN1 / IN2; division by zero: ENO = 0.
- MODModulo (MOD)OUT := remainder of IN1 divided by IN2.
- CPTCompute an expression (CPT)OUT := an expression written as text (+ − * / MOD, parentheses).