Publication 1762-RM001C-EN-P
Conversion Instructions 11-3
ENC - Encode
1-of-16 to 4
Instruction Type: output
The ENC instruction searches the source from the lowest to the highest
bit, looking for the first bit set. The corresponding bit position is written to
the destination as an integer. The ENC instruction converts the values as
shown in the table below:
Updates to Math Status Bits
ENC
Encode 1 of 16 to 4
Source N7:0
0000000000000000<
Dest N7:1
0000h<
ENC
Table 11.4 Execution Time for the ENC Instruction
Controller When Rung Is:
True False
MicroLogix 1200 7.2
µ
s0.0
µ
s
MicroLogix 1500 6.8
µ
s0.0
µ
s
Table 11.5 Encode 1-of-16 to 4
Source Bits Destination Bits
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 15 to 04 03 02 01 00
x x x x x x x x x x x x x x x 1 0 0 0 0 0
x x x x x x x x x x x x x x 1 0 0 0 0 0 1
x x x x x x x x x x x x x 1 0 0 0 0 0 1 0
x x x x x x x x x x x x 1 0 0 0 0 0 0 1 1
xxxxxxxxxxx10000 0 0100
xxxxxxxxxx100000 0 0101
xxxxxxxxx1000000 0 0110
xxxxxxxx10000000 0 0111
x x x x x x x 1 0 0 0 0 0 0 0 0 0 1 0 0 0
x x x x x x 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1
x x x x x 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
x x x x 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1
xxx1000000000000 0 1100
xx10000000000000 0 1101
x100000000000000 0 1110
1000000000000000 0 1111
x = determines the state of the flag
NOTE
If source is zero, the destination is zero and the math
status is zero, the flag is set to 1.
Table 11.6 Math Status Bits
With this Bit: The Controller:
S:0/0 Carry always resets
S:0/1 Overflow sets if more than one bit in the source is set; otherwise resets. The math
overflow bit (S:5/0) is not set.
S:0/2 Zero Bit sets if result is zero, otherwise resets
S:0/3 Sign Bit always resets