Using Data Handling Instructions
9–9
Encode 1 of 16 to 4 (ENC)
When the rung is true, this output instruction searches the source from the lowest to
the highest bit, and looks for the first set bit. The corresponding bit position is
written to the destination as an integer as shown in the table below.
Source
Destination
Bit 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 15–04 03 02 01 00
x x x x x x x x x x x x x x x 1 x 0 0 0 0
x x x x x x x x x x x x x x 1 0 x 0 0 0 1
x x x x x x x x x x x x x 1 0 0 x 0 0 1 0
x x x x x x x x x x x x 1 0 0 0 x 0 0 1 1
x x x x x x x x x x x 1 0 0 0 0 x 0 1 0 0
x x x x x x x x x x 1 0 0 0 0 0 x 0 1 0 1
x x x x x x x x x 1 0 0 0 0 0 0 x 0 1 1 0
x x x x x x x x 1 0 0 0 0 0 0 0 x 0 1 1 1
x x x x x x x 1 0 0 0 0 0 0 0 0 x 1 0 0 0
x x x x x x 1 0 0 0 0 0 0 0 0 0 x 1 0 0 1
x x x x x 1 0 0 0 0 0 0 0 0 0 0 x 1 0 1 0
x x x x 1 0 0 0 0 0 0 0 0 0 0 0 x 1 0 1 1
x x x 1 0 0 0 0 0 0 0 0 0 0 0 0 x 1 1 0 0
x x 1 0 0 0 0 0 0 0 0 0 0 0 0 0 x 1 1 0 1
x 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x 1 1 1 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x 1 1 1 1
Entering Parameters
•
Source is the address of the word to be encoded. Only one bit of this word
should be on at any one time. If more than one bit in the source is set, the
destination bits will be set based on the least significant bit that is set. If a
source of zero is used, all of the destination bits will be reset and the zero bit
will be set.
•
Destination is the address that contains the bit encode information. Bits 4–15
of the destination are reset by the ENC instruction.
Programming
Execution Times
(
µ
sec) when:
True
False
54.80
6.78
ENC
ENCODE 1 of 16 to 4
Source
Dest
efesotomasyon.com - Allen Bradley,Rockwell,plc,servo,drive