1910
27 ARITHMETIC OPERATION FUNCTIONS
27.3 Subtraction
27.3
Subtraction
SUB(_E)
These functions output the difference between input values ((s1)-(s2)).
Setting data
■
Description, type, data type
Processing details
■
Operation processing
• These functions perform subtraction between the INT, DINT, REAL, or LREAL data type values input to (s1) and (s2) ((s1)-
(s2)), and output the operation result, in the same data type as (s), from (d).
Ex.
Data type: INT
• Input an INT, DINT, REAL, or LREAL data type value to (s1) and (s2).
• If an underflow or overflow occurs in the operation result, the output from (d) will be as follows.
Ladder, FBD/LD
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: Executed, FALSE: Not executed)
Input variable
BOOL
s1 (IN1), s2 (IN2)
Input
Input variable
ANY_NUM
ENO
Output status (TRUE: Normal, FALSE: Abnormal)
Output variable
BOOL
d
Output
Output variable
ANY_NUM
Data type: INT
Data type: DINT
Data type: REAL/LREAL
• Even if an underflow or overflow occurs, no
operation error is issued. When SUB_E is used,
ENO outputs TRUE.
[Example 1]
32767-(-2)=-32767
(7FFFH)-(FFFEH)=(8001H)
A negative value results because the most
significant bit is 1.
[Example 2]
-32767-2=32766
(8000H)-(0002H)=(7FFEH)
A positive value results because the most
significant bit is 0.
• Even if an underflow or overflow occurs, no
operation error is issued. When SUB_E is used,
ENO outputs TRUE.
[Example 1]
2147483647-(-2)=-2147483647
(7FFFFFFFH)-(0000FFFEH)=(80000001H)
A negative value results because the most
significant bit is 1.
[Example 2]
-2147483648-2=2147483646
(80000000H)-(00000002H)=(7FFFFFFEH)
A positive value results because the most
significant bit is 0.
An operation error occurs and an undefined value
is output.
RnCPU RnENCPU
RnSFCPU RnSFCPU
RnPCPU
RnPCPU
(Standard)
(Safety)
(Redundant)
(Process)
s1
d
s2
EN
ENO
d
s1
s2
(s1)
(s2)
(d)
5556
6789
-
12345
INT
INT
INT
Summary of Contents for MELSEC iQ-R Series
Page 1: ...MELSEC iQ R Programming Manual Instructions Standard Functions Function Blocks ...
Page 2: ......
Page 24: ...22 INDEX 2092 INSTRUCTION INDEX 2093 REVISIONS 2104 WARRANTY 2105 TRADEMARKS 2106 ...
Page 34: ...32 MEMO ...
Page 35: ...33 PART 1 PART 1 OVERVIEW This part consists of the following chapter 1 OVERVIEW ...
Page 68: ...66 1 OVERVIEW 1 5 Precautions on Programming MEMO ...
Page 1448: ...1446 14 REDUNDANT SYSTEM INSTRUCTIONS 14 2 Disabling Enabling System Switching MEMO ...
Page 1972: ...1970 33 TIME DATA TYPE FUNCTIONS 33 4 Division MEMO ...
Page 2067: ...APPX Appendix 5 PID Control Program Examples 2065 A 252 Set PID control data for loop 2 ...
Page 2109: ......