MOD
Function Name |
MOD (Modulo) |
---|---|
ST Operator |
MOD |
Description |
The output is the modulo result of a division (the remainder of a division). For the MOD function, Input 1 is divided by Input 2 and the remainder is the output. In Function Block Diagrams, Input 1 is the top input and Input 2 is the bottom input. |
Arguments |
Input 1 {ANY_INT} Input 2 {ANY_INT} For more information on the data types for the inputs and outputs, see Data Type Hierarchy. |
Returns |
Output {INT} The Output = The remainder of Input 1 / Input 2 |
Example:
Function Block Diagram - MOD:
Input 1 is 5 and Input 2 is 2. This means that the MOD function provides an output of 1 as 5/2 = 2 with 1 remaining.
ST Program - MOD:
The MOD function outputs the remainder from Input 1 divided by Input 2.
- Output := MOD (Input 1, Input 2);
Where Output, Input 1 and Input 2 are defined as variables earlier in the ST program. In this case, let's assume Input 1 is 10 and Input 2 is 3. The MOD function returns 1 as 10/3=3 with 1 remaining.