EasyManuals Logo

Mitsubishi FX3G Series Programming Manual

Mitsubishi FX3G Series
944 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
Page #270 background imageLoading...
Page #270 background image
268
FX3G/FX3U/FX3GC/FX3UC Series
Programming Manual - Basic & Applied Instruction Edition
10 Arithmetic and Logical Operation (
+
,
,
×
,
÷
) – FNC 20 to FNC 29
10.2 FNC 21 – SUB / Subtraction
Related devices
1. Relationship between the flag operation and the sign (positive or negative) of a numeric value
For the flag operations, refer to Subsection 6.5.2.
Cautions
1. When using a 32-bit operation instruction (DSUB or DSUBP)
When specifying word devices, a 16-bit word device on the low-order side is specified first, and then a word device
with the subsequent device number is automatically set for the high-order 16 bits.
To prevent number overlap, it is recommended to always specify an even number, for example.
2. When specifying the same device in the source and destination
The same device number can be specified for both the source and the destination.
In this case, note that the addition result changes in every operation cycle if a continuous operation type instruction
(SUB or DSUB) is used.
Program example
1. Difference between the SUB instruction and the DEC instruction used by a program for
subtracting "1"
When SUB[P] is executed, "1" is subtracted from the contents of D0 every time X001 turns from OFF to ON.
SUB[P] instruction is similar to DECP instruction described later except the contents shown in the table below:
Device Name Description
M8020 Zero
ON : When the operation result is 0
OFF : When the operation result is other than 0
M8021 Borrow
ON : When the operation result is less than 32768 (in 16-bit operation) or 2,147,483,648 (in 32-bit operation)
OFF :
When the operation result is not less than
32768 (in 16-bit operation) or
2,147,483,648 (in 32-bit operation)
M8022 Carry
ON : When the operation result is more than 32767 (in 16-bit operation) or 2,147,483,647 (in 32-bit operation)
OFF :
When the operation result is not more than 32767 (in 16-bit operation) or 2,147,483,647 (in 32-bit operation)
[D] SUB [P] instruction [D] DEC [P] instruction
Flag (zero, borrow or carry) Operates Does not operate
Operation result
16-bit
operation
(+1)=
←−2←−10←−32768 32,768+32,767+32,766
(1)=
+327670+1+2→⎯
32-bit
operation
(+1)=
←−2←−10←−2,147,483,648 2,147,483,648+2,147,483,647+2,147,483,646
(1)=
+2,147,483,6470+1+2→⎯
Zero flag
2,
1, 0,
32768
Borrow flag
Zero flag
2,
1, 0,
2,147,483,648
Borrow flag
The most
significant bit of
data becomes
"1".
Zero flag
32767, 0, 1, 2
Carry flag
Zero flag
2,147,483,647, 0, 1, 2
Carry flag
Zero flag
1, 0, 1
Zero flag
1, 0, 1
The most
significant bit
of data
becomes "0".
FNC 21
SUB
D 0 K 25 D 0
X001
(D 0)
25
(D 0)
S
D
S D
S D
S D
FNC 21
SUBP
D 0 K 1 D 0
X001
(D 0)
1
(D 0)
FNC 25
DECP
D 0
X001
(D 0)
1
(D 0)
S
1
S
2
D

Table of Contents

Other manuals for Mitsubishi FX3G Series

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Mitsubishi FX3G Series and is the answer not in the manual?

Mitsubishi FX3G Series Specifications

General IconGeneral
ModelFX3G Series
Power SupplyAC 100-240V or DC 24V
Program Capacity32, 000 steps
Execution Speed0.21 µs/basic instruction
Communication OptionsRS-422, USB, Ethernet
Expansion ModulesAnalog, digital, communication
Programming LanguageLadder Logic, Instruction List
Built-in FunctionsHigh-speed counters, pulse output
Analog I/OAvailable via expansion modules

Related product manuals