EasyManua.ls Logo

Mitsubishi MELSEC iQ-F FX5 series

Mitsubishi MELSEC iQ-F FX5 series
888 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
17 ARITHMETIC OPERATION FUNCTIONS
17.3 Subtraction
781
17
17.3 Subtraction
SUB(_E)
These functions output the difference of input values ((s1) - (s2)).
Setting data
Descriptions, types, and data types
Processing details
Operation processing
These functions subtract the INT, DINT, or REAL type data input to (s1) and (s2) ((s1)-(s2)), and output the operation result
from (d) in the same data type as (s).
Ex.
Data type is INT
A value input to (s1) and (s2) is the INT, DINT, or REAL type data value.
If an underflow and an overflow occur in the operation result, the result will be output as follows from (d).
When the operation result is 0, the zero flag (SM8020) turns on.
Ladder diagram Structured text
[Without EN/ENO] [With EN/ENO] [Without EN/ENO]
d:=SUB(s1,s2);
[With EN/ENO]
d:=SUB_E(EN,ENO,s1,s2);
Argument Description Type Data type
EN Execution condition (TRUE: Execution, FALSE: Stop) Input variable BOOL
s1, s2 Input Input variable ANY_NUM
ENO Output status (TRUE: Normal, FALSE: Abnormal) Output variable BOOL
d Output Output variable ANY_NUM
Data type is INT Data type is DINT Data type is REAL
Even if underflow or overflow occurs in the
operation result, it is not regarded as an
operation error. "SUB_E" outputs "TRUE" from
ENO.
[Example 1]
32767-(-2)=1
(7FFFH)-(0002H)=(0001H)
The most significant bit becomes 1, and the carry
flags (SM716 and SM8022) turn on.
[Example 2]
-32768-2=-1
(8000H)-(0002H)=(FFFFH)
The most significant bit becomes 0, and the borrow
flag (SM8021) turns on.
Even if underflow or overflow occurs in the
operation result, it is not regarded as an
operation error. "SUB_E" outputs "TRUE" from
ENO.
[Example 1]
2147483647-(-2)=-2147483647
(7FFFFFFFH)-(FFFEH)=(80000001H)
The most significant bit becomes 1, and a negative
value is output.
[Example 2]
-2147483648-2=2147483646
(80000000H)-(0002H)=(7FFFFFFEH)
The most significant bit becomes 0, and a positive
value is output.
An operation error occurs and an undefined value
is output.
s1 d
s2
EN ENO
ds1
s2
INT
12345 -
INT
6789
INT
5556
(s1) (s2)
(d)

Table of Contents

Related product manuals