MOD Modulo (MOD)
Also called: modulus, remainder, MOD
OUT := remainder of IN1 divided by IN2.
What it does
The MOD block computes the remainder of the integer division of the first value by the second.
When to use it
To know whether a number is even (MOD 2), make a repeating cycle (counter MOD 4).
Operands
| European mnemonic | American mnemonic | Name | Data type | Direction | Required | Meaning |
|---|---|---|---|---|---|---|
| EN | EN | Enable | BOOL | Input | Yes | Rung condition: the computation runs only when power flow is 1. |
| IN1 | IN1 | Source A | INT, DINT | Input | Yes | First operand. |
| IN2 | IN2 | Source B | INT, DINT | Input | Yes | Second operand. |
| OUT | OUT | Destination | INT, DINT | Output | No | Result (variable). Not changed while the rung is 0. |
| ENO | ENO | Enable out | BOOL | Output | No | 0 when the divisor is zero (OUT is not changed). |
| Mnemonic | Name | Data type | Direction | Required | Meaning |
|---|---|---|---|---|---|
| EN | Enable | BOOL | Input | Yes | Rung condition: the computation runs only when power flow is 1. |
| IN1 | Source A | INT, DINT | Input | Yes | First operand. |
| IN2 | Source B | INT, DINT | Input | Yes | Second operand. |
| OUT | Destination | INT, DINT | Output | No | Result (variable). Not changed while the rung is 0. |
| ENO | Enable out | BOOL | Output | No | 0 when the divisor is zero (OUT is not changed). |
| Mnemonic | Name | Data type | Direction | Required | Meaning |
|---|---|---|---|---|---|
| EN | Enable | BOOL | Input | Yes | Rung condition: the computation runs only when power flow is 1. |
| IN1 | Source A | INT, DINT | Input | Yes | First operand. |
| IN2 | Source B | INT, DINT | Input | Yes | Second operand. |
| OUT | Destination | INT, DINT | Output | No | Result (variable). Not changed while the rung is 0. |
| ENO | Enable out | BOOL | Output | No | 0 when the divisor is zero (OUT is not changed). |
Example
When S1 is 1, V3 := V1 MOD V2.
Try it in the simulatorThe example opens in the free simulator; your own program stays as it was.
Behaviour in detail
- Integers only (INT, DINT).
- The remainder has the sign of the dividend: −7 MOD 3 = −1.
- Zero divisor: ENO = 0 and OUT does not change.