Subtract SUB

Dest = A − B.

TagAfter two scans
Done4
Left6
Target10

How it works

While the rung is true, writes Source A - Source B to the destination each scan. A fault, such as a divide by zero, leaves the destination unchanged.

How it's used

Use SUB to find what is left or how far apart two values are.

TagValue
Target50
Made46
Left4
NearlyDone1

4 are left, so NearlyDone is on.

Operands

OperandData typeRead or write
ADINT, REAL or a numberReads
BDINT, REAL or a numberReads
DestDINT, REALWrites

Common mistakes

  • Reversing the sourcesSubtract computes A minus B.

Learn it in a lesson