EasyManua.ls Logo

Delta DVP-20PM

Delta DVP-20PM
580 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...
5 Applied Instructions and Basic Usage
DVP-20PM Application Manual
5-46
API
W
W
Applicable model
20PM
29
D
D
NEG
P
P
Taking the two’s complement of a value
Bit device Word device
X Y M S K H KnX KnY KnM KnS T C D V Z
D
Note: The instruction supports V devices and Z devices. (If the 16-bit
instruction is used, Z devices can not be used. If the 32-bit
instruction is used, V devices can not be used.)
Please refer to specifications for more information about device
ranges.
16-bit instruction (7 steps)
NEG
Continuity
instruction
NEGP
Pulse
instruction
32-bit instruction (9 steps)
DNEG
Continuity
instruction
DNEGP
Pulse
instruction
Flag: None
Explanation
The instructions can be
used to convert a negative binary value into an
absolute value.
D: Device in which the two’s complement of the value in the device is stored
Generally, the pulse instructions NEGP and DNEGP are used.
Example 1
When X0 is turned from OFF to ON, all the bits in D0 are inverted (0 becomes
1, and 1 becomes 0), 1 is added to the result, and the final value is stored in
the original register D10.
X0
NEGP D10
Example 2
Getting the aboluste value of a negative value
1. When bit 15 in D0 is 1, M0 is ON. (The value in D0 is a negative value.)
2. When M0 is ON, the instruction NEG is used to take the two’s complement
of the negative value in D0.
M1000
BON D0 M0 K15
NEGP D0
M0
Example 3
Getting the absolute value of the difference between two values
Suppose X0 is ON.
1. When the value in D0 is greater than that in D2, M0 is ON.
2. When the value in D0 is equal to that in D2, M1 is ON.
3. When the value in D0 is less than that in D2, M2 is ON.
4. The value in D4 is a positive value.
X0
CMP D0 D2 M0
M0
SUB D0 D2 D4
M2
SUB D2 D0 D4
M1

Table of Contents

Other manuals for Delta DVP-20PM

Related product manuals