AH500 Programming Manual 
6-266 
API 
Instruction code  Operand  Function 
1203    ENCO  P 
S, D, n 
Encoder 
Device
X  Y  M  S  T  C  HC  D  L  SM  SR  E  PR  K  16#  “$”  DF 
16-bit instruction (7 steps) 
Symbol: 
 
S
:
Source device  Bit/Word 
D
:
Device in which the encoded values 
are stored 
Word 
n
:
Number of bits whose values are 
encoded 
Word 
Explanation: 
1.  The values of the lower 2
n
 bits in the source device specified by S are encoded as the values 
of the lower n bits in D. 
2.  If there are many bits whose values are 1 in the source device specified by S, the first bit with 
the value 1 from the left is processed. 
3.  When S is a bit device, n is within the range between 1 and 8. When n is 8, the values of the 
256 bits is encoded as the values of the 8 bits. 
4.  When S is a word device, n is within the range between 1 and 4. When n is 4, the values of the 
16 bits is encoded as the values of the 4 bits. 
5.  Generally, the pulse instruction ENCOP is used. 
Example 1: 
1.  When X0.0 is switched from OFF to ON, the instruction ENCO encodes the values of the 8 bits 
in M0~M7 as the values of the lower 3 bits in D0, and the values of b15~b3 in D0 become 0. 
2.  After the instruction ENCO is executed and X0.0 is switched OFF, the data in D is unchanged. 
 
b15
The values of b15~b3 in D0 become 0.
b0
D0
4 2 1
0 0 0 0 1 0 0 0
7 6 5 4 3 2 1 0
M7 M6 M5 M4 M3 M2 M1 M0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 10