Modulo MOD
Dest = the remainder of A ÷ B.
MODULO
AGlobal.Count77BGlobal.Two2DestGlobal.Remainder1
| Tag | After two scans |
|---|---|
| Count7 | 7 |
| Remainder | 1 |
| Two | 2 |
How it works
While the rung is true, writes what is left over after A ÷ B. It has the sign of A, so -7 MOD 2 is -1. Dividing by 0 is a fault and leaves Dest unchanged.
How it's used
Use MOD to act on every Nth item, such as every second box.
MODULO
AGlobal.BoxCount7B2DestGlobal.Odd1
EQU
AGlobal.Odd1B1
Global.DivertOTE
| Tag | Value |
|---|---|
| BoxCount | 7 |
| Odd | 1 |
| Divert | 1 |
Box 7 leaves a remainder of 1, so Divert is on.
Operands
| Operand | Data type | Read or write |
|---|---|---|
| A | DINT, REAL or a number | Reads |
| B | DINT, REAL or a number | Reads |
| Dest | DINT, REAL | Writes |
Common mistakes
- Expecting a positive remainder for a negative sourceThe remainder takes the sign of A. -7 modulo 2 is -1.