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 mnemonicAmerican mnemonicNameData typeDirectionRequiredMeaning
ENENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
IN1IN1Source AINT, DINTInputYesFirst operand.
IN2IN2Source BINT, DINTInputYesSecond operand.
OUTOUTDestinationINT, DINTOutputNoResult (variable). Not changed while the rung is 0.
ENOENOEnable outBOOLOutputNo0 when the divisor is zero (OUT is not changed).
MnemonicNameData typeDirectionRequiredMeaning
ENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
IN1Source AINT, DINTInputYesFirst operand.
IN2Source BINT, DINTInputYesSecond operand.
OUTDestinationINT, DINTOutputNoResult (variable). Not changed while the rung is 0.
ENOEnable outBOOLOutputNo0 when the divisor is zero (OUT is not changed).
MnemonicNameData typeDirectionRequiredMeaning
ENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
IN1Source AINT, DINTInputYesFirst operand.
IN2Source BINT, DINTInputYesSecond operand.
OUTDestinationINT, DINTOutputNoResult (variable). Not changed while the rung is 0.
ENOEnable outBOOLOutputNo0 when the divisor is zero (OUT is not changed).

Example

European style
American style

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

See also