EasyManua.ls Logo

Delta VP3000 Series - Page 327

Delta VP3000 Series
714 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...
Chapter 7 Second Development Platform VP3000
318
API
Instruction
code
Operand Function
29 D NEG P D 2’s complement (negative)
Type
Operand
Bit devices Word devices
16-bit instruction (3 steps)
NEG
Continuous
execution
type
NEGP
Pulse
execution
type
32-bit instruction (5 steps)
DNEG
Continuous
execution
type
DNEGP
Pulse
execution
type
Associated flag: none
X Y M K H KnX KnY KnM T C D
D
Caution for using operand: none
Description
Device to store 2’s complement
Each bit in D is reverse (0 1, 1 0) at first, and then the least significant bit plus 1 and is
stored in the original register. This instruction can be used for converting a negative BIN value
into an absolute value.
This instruction adopts pulse execution instructions (NEGP, DNEGP).
Operand D uses device F, and they can only use 16-bit instructions.
Example
Example 1
When X0 goes from OFF ON, each bit in D10 is reverse (0 1, 1 0) at first, and then the
least significant bit plus 1 and is stored in D10.
X0
NEGP
D10
Example 2
To obtain the absolute value of a negative value:
1. When the 15
th
bit of D0 is “1”, M0 = ON. (D0 is a negative value).
2. When M0 = ON, the absolute value of D0 can be obtained by NEG instruction.
M1000
BON D0 K15M0
M0
NEGP D0
Example 3
Obtain the absolute value of the difference of the subtraction. When X0 = ON:
1. If D0 > D2, M0 = ON.
2. If D0 = D2, M1 = ON.
3. If D0 < D2, M2 = ON.
4. D4 is then able to remain positive.
X
0
CMP D0 D2 M0
M0
SUB D0 D2 D4
M2
SUB D2 D0 D4
M1

Table of Contents

Related product manuals