Fernhill SCADA supports these arithmetic functions and operators:
Function | Operator | Parameter Type | Parameters | Description |
---|---|---|---|---|
ADD | + | ANY_MAGNITUDE | 2-N | Addition |
MUL | * | ANY_MAGNITUDE | 2-N | Multiplication |
SUB | - | ANY_MAGNITUDE | 2 | Subtraction |
DIV | / | ANY_MAGNITUDE, ANY_NUM | 2 | Division |
MOD | ANY_INT | 2 | Modulo | |
EXPT | ** | ANY_NUM | 2 | Raise to power |
MOVE | := | ANY | 1 | Assignment |
Arithmetic functions ADD, and MUL accept a variable number of parameters. For example:
ADD( A, B, C ) is equivalent to A + B + C.
Division of integers, using the DIV function or the / operator, truncates towards zero. For example:
DIV( -11, 4 ) returns -3, and 11 / 4 returns 3.
The MOD function returns 0 (zero) when the second parameter is 0 (zero). The MOD function is equivalent to this code fragment:
IF In2 = 0 THEN OUT := 0; ELSE OUT := IN1 - (IN1 / IN2) * IN2; END_IF;
Example | Return Value |
---|---|
ADD(10, 15, 20) | DINT#45 |
MUL(2, 3, 4) | DINT#24 |
SUB(20, 7) | DINT#13 |
Table 24 - IEC 61131-3 Second Edition.
Table 29 - IEC 61131-3 Third Edition.
To learn about generic data types such as ANY_INT, ANY_NUM, ANY_MAGNITUDE.
To learn about arithmetic operations on date and time types.
To learn about other language Common Elements.
For the meaning of terms used in Fernhill SCADA.