SUB Subtract

Also called: subtraction, difference, minus, −

OUT := IN1 − IN2 when the rung is 1.

What it does

The SUB block subtracts the second value from the first and writes the result into OUT.

When to use it

To compute a deviation, a remaining quantity, a time difference.

Operands

European mnemonicAmerican mnemonicNameData typeDirectionRequiredMeaning
ENENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
IN1IN1Source AINT, DINT, REAL, TIME / DINTInputYesFirst operand.
IN2IN2Source BINT, DINT, REAL, TIME / DINTInputYesSecond operand.
OUTOUTDestinationINT, DINT, REAL, TIME / DINTOutputNoResult (variable). Not changed while the rung is 0.
ENOENOEnable outBOOLOutputNo1 when the computation ran without error.
MnemonicNameData typeDirectionRequiredMeaning
ENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
IN1Source AINT, DINT, REAL, TIMEInputYesFirst operand.
IN2Source BINT, DINT, REAL, TIMEInputYesSecond operand.
OUTDestinationINT, DINT, REAL, TIMEOutputNoResult (variable). Not changed while the rung is 0.
ENOEnable outBOOLOutputNo1 when the computation ran without error.
MnemonicNameData typeDirectionRequiredMeaning
ENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
IN1Source AINT, DINT, REALInputYesFirst operand.
IN2Source BINT, DINT, REALInputYesSecond operand.
OUTDestinationINT, DINT, REALOutputNoResult (variable). Not changed while the rung is 0.
ENOEnable outBOOLOutputNo1 when the computation ran without error.

Example

European style
American style

When S1 is 1, V3 := V1 − V2.

Try it in the simulatorThe example opens in the free simulator; your own program stays as it was.

Behaviour in detail

See also