Skip to main content

6.1.3.4.6 MOD

Function

To find the modulo (return the remainder of division), divide the value of input IN1 by the value of input IN2, and query the remainder through output OUT

LD Graphics

alt text

Parameter description

Interface variableDeclarationData typeDescription
IN1Var_InputANY_INTDividend
IN2Var_InputANY_INTDivisor
OUTVar_OutputANY_INTRemainder

Example

Through the MOD instruction, variable a is divided by variable b to obtain variable c, as shown in the following figure: three INT type variables are defined, and the MOD instruction is executed by compiling, downloading, and realizing that variable c is the remainder of variables a and b

alt text

warning
  • The result of evaluating the MOD function shall be equivalent to the execution of the following ST statement:
IF(IN2 = 0) THEN
OUT := 0;
ELSE
OUT := IN1 - (IN1 / IN2) * IN2;
END_IF