2-375
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Conversion Instructions
2
Encoder
Size is USINT#4, so 2#1001 (i.e., 9) is stored in the lower 4 bits of Out. FALSE is stored in the upper
four bits of Out.
Use the Decoder instruction (page 2-371) to make one bit TRUE and the other bits FALSE in array ele-
ments that consist of a maximum of 256 bits.
• If the value of Size is 0, all bits in Out change to FALSE.
• An error occurs in the following cases. ENO will be FALSE, and Out will not change.
• The value of Size is outside of the valid range.
• The value of Size exceeds the array area of In[].
• The value of all bits in In[] that are specified by Size change to FALSE.
• In[] is not a BOOL array or an array of bit strings.
• An array without a subscript is passed to In[].
Additional Information
Precautions for Correct Use
def:=Encoder(abc[3], USINT#4);
LD ST
abc[3]
def
USINT#4
Encoder
EN ENO
In
Size
The position of the
TRUE bit is output.
Bit 9 is indicated by
2#1001.
Bit
0
Bit
7
Bit
0
Bit
7
2
Size
= 16 bits
Out=def
In[0]=abc[3]
In[1]=abc[4]
0 0 0 0 1 0 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0
Size=USINT#4FALSE is set.