7. APPLICATION INSTRUCTIONS
7 − 47
MELSEC-A
ENCO
256 → 8 bit decode
(1) A binary value corresponding to the bit, which is 1 in 2n bit data of (S), is stored in (D).
7
0
8 6543210
0 1000000
110
S
D
(Binary value=6)
(2) For "n", 0 to 8 can be specified.
(3) When "n" is 0, no processing is performed and the contents of (D) do not
change.
(4) The bit device is treated as one bit and the word device as 16 bits.
(5) When multiple bits are 1, processing is performed for the last bit position.
Execution Conditions
Operation Errors In the following case, operation error occurs and the error flag turns on.
• "n" in other than 0 to 8.
• 0 exists in all devices from S to 2n when the encode instruction is used.
Program Examples DECO
OFF
ON
Executed
per scan
Executed
per scan
Executed
only once
Executed
only once
Decode Encode command
P
M0
0
P K
DECO X000 M10 3
• Coding
0 LD M0
1 DECOP X000 M10 K3
10 END
When 3 is specified a
X0 to 2
When 8 is specified at effective bits,
256 points are occupied.
Decode result
When 3 is specified as effective bits,
8 points are occupied.
Data
M13 at the third position from M10 turns on.