5 Applied Instructions and Basic Usage
DVP-20PM Application Manual
5-62
API
Applicable model
20PM
42
ENCO
P
P
Encoder
Bit device Word device
X Y M S K H KnX KnY KnM KnS T C D V Z
S
* * * *
* * * * *
D
* * * * *
n
* *
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)
ENCO
Continuity
instruction
ENCO P
Pulse
instruction
32-bit instruction
- - - -
Flag: None
Explanation
S: Source device D: Device in which an encoding result is stored n: Number of
bits which are encoded
The low 2
n
bits in S are encoded as the low n bits in D.
If there are many bits which are 1 in S, the first bit which is 1 from the left will
be processed.
Generally, the pulse instruction ENCOP is executed.
If S is a bit device, n is in the range of 1 to 8. If S is a word device, n is in the
range of 1 to 4.
Example 1
When S is a bit device, n is in the range of 1 to 8. If n is 0, or greater than 8, an
error will occur.
If n is 8, the maximum number of bits which can be decoded is 2
8
=256.
When X0 is turned from OFF to ON, the instruction ENCOP encodes the 8 bits
in M0~M7 as the low 3 bits in D0, and b15~b3 in D0 become 0.
After the instruction ENCOP is executed, X0 will be OFF, and the data in D will
remain unchanged.
ENCOP M0 K3D0
X0
b15
Bit 15~bit 3 i n D0 become 0.
b0
D0
421
00001000
76543210
M7 M6 M
M4 M3 M2 M1 M0
00000000 000 0 0 110
Example 2
If n is 4, the maximum n
umber of bits which can be decoded is 2
4
=16.
When S is a word device, n is in the range of 1 to 4. If n is 0, or larger than 4,
an error will occur.
When X
0 is turned from OFF to ON, the instruction ENCOP encodes the 8 bits
in D10 as the low 3 bits in D20, and b15~b3 in D20 become 0. (Bit 8~bit 15 in
D10 are invalid data.)
After the instruction ENCOP is executed, X0 will be OFF, and the data in D will
remain unchanged.
ENCOP D10 K3D20
X0