FX Series Positioning Controllers Program format 5
5-59
5.10.19 FNC29 (NEG): Complement
Obtaining the absolute value of a negative value
FNC 29
NEG
Applicable models
Series name
Remarks
K,H KnX KnY KnM D V,Z
Applicable
devices
and basic
format
Word
devices
FNC 29
NEG
FX
2N
-10GM
FX
2N
-20GM
BINARY
NEG
[D]NEG
Complement
Each bit of data in the device specified by
is inverted (0
→
1,1
→
0), "1" is added to the
inverted bits, then the result is saved in the
same device.
Drive
input
D·
D·
D·
16-bit operation
3 steps
32-bit operation
5 steps
FNC 29
NEG
D 10
X00
This instruction yields the absolute value of a
negative binary value.
(D10)+1
→
(D10)
·
1000000000000000
0010000000000000
0100000000000000
0000000000000000
1111111111111111
1010000000000000
1100000000000000
(D 10) + 1 = -32,768
(D 10) = 2
(D 10) = 1
(D 10) = 0
(D 10) + 1 = 1
(D 10) + 1 = 2
(D 10) + 1 = 3
(D 10) + 1 = 32,766
(D 10) + 1 = 32,767
(D 10) = -32,768
(D 10) = -32,767
(D 10) = -32,766
(D 10) = -3
(D 10) = -2
(D 10) = -1
The miximum absolte value is 32,767 for 16-bit operation.
1011111111111111
1001111111111111
0100000000000000
0010000000000000
0110000000000000
0011111111111111
0111111111111111
1000000000000000
The positioning unit expresses negative values in the
form of twos complement as shown on the left.
If the most significant bit is 1, the number is negative
and its absolute value can be obtained using the NEG
instruction.