MOD

The IEC operator is used for modulo division.

The result of the function is the integer remainder of the division.

Permitted data types: BYTE, WORD, DWORD, LWORD, SINT, USINT, INT, UINT, DINT, UDINT, LINT, ULINT

MOD 1:

In TwinCAT, division by zero always leads to an exception and the corresponding task is stopped.
However, the result of Mod 0 is 0.

Samples:

Result: nVar is 1.

ST:

nVar := 9 MOD 2;

FBD:

MOD 2: