Encode (ENCO)
The Encode instruction encodes the bit position in the
DS5
Used
accumulator having a value of 1, and returns the appropriate
HPP
Used
binary representation. If the most significant bit is set to 1 (Bit
31), the Encode instruction would place the value HEX 1F
(decimal 31) in the accumulator. If the value to be encoded
is 0000 or 0001, the instruction will place a zero in the
accumulator. If the value to be encoded has more than one bit
position set to a "1", the least significant "1" will be encoded
and SP53 will be set on.
Discrete Bit Flags
SP63
SP70
NOTE: The status flags are only valid until another instruction that uses the same flags is executed.
In the following example, when X1 is on, The value in V2000 is loaded into the accumulator
using the Load instruction. The bit position set to a "1" in the accumulator is encoded to the
corresponding 5 bit binary value using the Encode instruction. The value in the lower 16 bits
of the accumulator is copied to V2010 using the Out instruction.
DirectSOFT 5
Direct SOFT32
X1
LD
Load the value in V2000 into
the lower 16 bits of the
accumulator
ENCO
Encode the bit position set
to "1" in the accumulator to a
5 bit binary value
OUT
Copy the value in the lower 16 bits
of the accumulator to V2010
Handheld Programmer Keystrokes
$
B
STR
1
L
D
SHFT
ANDST
3
E
N
SHFT
4
TMR
GX
SHFT
OUT
On when the result of the instruction causes the value in the accumulator to be zero.
On anytime the value in the accumulator is negative.
V2000
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
V2010
ENT
C
A
A
A
2
0
0
0
C
O
ENT
2
INST#
V
C
A
B
A
AND
2
0
1
0
DL05 Micro PLC User Manual, 6th Edition, Rev. D
Chapter 5: Standard RLL Instructions
Description
0
0
ENT
ENT
ENCO
V2000
1
0
0
0
15 14 13 12 11 10 9 8 7 6 5
4 3 2 1 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
Bit postion 12 is
converted
to binary
15 14 13 12 11 10 9 8 7 6 5
4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
0
0
0
C
V2010
Binary value
for 12.
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
A
a
b
B
c
C
D
D
5-85
Need help?
Do you have a question about the DL05 and is the answer not in the manual?