6.4.2 Subtraction
The SUB instruction calculates the difference between two numerical values (contents of
16-bit or 32-bit devices or constants).The result of the subtraction is written to a third device.
쐃
Minuend (the subtrahend is subtracted from this value)
쐇
Subtrahend (this value is subtracted from the minuend)
쐋
Difference (result of the subtraction)
The data types of the input and output variable of the SUB instruction must be identical.
In the example above the contents of D1 is subtracted from the contents of D0 and the differ
-
enceiswrittentoD2.
Examples
Subtract 100 from the contents of data register D100 and write the result to D101 when relay
M37 is set :
The signs of the values are taken into account by the SUB instruction:
If you want you can also write the result to one of the source devices. However, if you do this
remember that the result will then change in every
program cycle if the SUB instruction is exe
-
cuted cyclically!
6–28 MITSUBISHI ELECTRIC
Math Instructions More Advanced Programming
Ladder Diagram
IEC Instruction List
LD D0
SUB D1
ST D2
247
100
D 100
–
D 101
147
5
-8
D 10
–
D 11
D 12
13