FX Series Programmable Controlers Applied Instructions 5
5-25
5.3.1 ADD (FNC 20)
Operation 1:
(Applicable to all units)
The data contained within the source devices
(S
1
,S
2
) is combined and the total is stored at the
specified destination device (D).
Points to note:
a) All calculations are al
ebraicall
processed, i.e. 5 + (-8)= -3.
b) The same device ma
be used as a source (S
1
or S
2
) and as the destination (D). If this is
the case then the ADD instruction would actuall
operate continuousl
. This means on
ever
scan the instruction would add the result of the last scan to the second source device.
To prevent this from happenin
the pulse modifier should be used or an interlock should be
pro
rammed.
c) If the result of a calculation is “0" then a special auxiliar
fla
, M8020 is set ON.
d) If the result of an operation exceeds 32,767 (16 bit limit) or 2,147,483,647 (32 bit limit) the
carr
fla
, M8022 is set ON. If the result of an operation exceeds -32,768 or -2,147,483,648
the borrow fla
, M8021 is set ON. When a result exceeds either of the number limits, the
appropriate fla
is set ON (M8021 or M8022) and a portion of the carr
/borrow is stored in
the destination device. The mathematical si
n of this stored data is reflective of the number
limit which has been exceeded, i.e. when -32,768 is exceeded ne
ative numbers are stored
in the destination device but if 32,767 was exceeded positive numbers would be stored at
D.
e) If the destination location is smaller than the obtained result, then onl
the portion of the
result which directl
maps to the destination area will be written, i.e if 25 (decimal) was the
result, and it was to be stored at K1Y4 then onl
Y4 and Y7 would be active. In binar
terms
this is equivalent to a decimal value of 9 a lon
wa
short of the real result of 25!
Continued over the pa
e....
Mnemonic Function
Operands
Program steps
S1 S2 D
ADD
FNC 20
(
Addition
The value of the
two source
devices is added
and the result
stored in the desti-
nation device
K, H, KnX, KnY, KnM, KnS,
T, C, D, V, Z
KnY, KnM, KnS,
T, C, D, V, Z
ADD, ADDP:
7 steps
DADD,
DADDP:
13 steps
When usin
M8023 to add floatin
point data,
onl
double word (32 bit) data re
isters (D) or
constants (K/H) ma
be used. See pa
e 4-46
for more details re
ardin
floatin
point format.
X0
ADD D 10 D 12
[ S1 ] [ D ]
D 14
[ S2 ]