14: DATA CONVERSION INSTRUCTIONS« FC4A MICRO SMART USER ’S MANUAL » 14-11ENCO (Encode)Applicable CPU ModulesValid OperandsFor the valid operand number range, see pages 6-1 and 6-2.▲ Internal relays M0 through M1277 can be designated as D1. Special internal relays cannot be designated as D1.Valid values for Bits to designate the quantity of bits searched are 1 through 256. Make sure that the search area designatedby S1 plus Bits is within the valid value range. If the source data is out of the valid range, a user program execution errorwill result, turning on special internal relay M8004 and the ERR LED.Since the ENCO instruction is executed in each scan while input is on, a pulse input from a SOTU or SOTD instructionshould be used as required.Examples: ENCOFC4A-C10R2/C FC4A-C16R2/C FC4A-C24R2/C FC4A-D20K3/S3 FC4A-D20RK1/RS1 & FC4A-D40K3/S3— — — — XOperand Function I Q M R T C D Constant RepeatS1 (Source 1) First bit to start search X X X X — — X — —D1 (Destination 1) Destination to store search results — X ▲ X — — X — —Bits Quantity of bits searched — — — — — — — 1-256 —When input is on, a bit which is on is sought. The search begins at S1 until thefirst point which is set (on) is located. The quantity of points from S1 to the firstset point (offset) is stored to the destination designated by operand D1.If no point is on in the searched area, 65535 is stored to D1.ENCOBits S1*****D1*****D1D100S1M4I0ENCO64M17 M0M37 M20M57 M40M77 M60M97 M80M117 M100When input I0 is on, a bit which is on is sought in 64 bits starting at internalrelay M4 designated by operand S1.Since internal relay M30 is the first point that is on, the offset from the firstsearch point is 20, and 20 is stored to data register D100 designated by oper-and D1.ONSearched area20D100D1D100S1D10I1ENCO64Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0D10D11D12D13D14D15When input I1 is on, a bit which is on is sought in 64 bits starting at bit 0 of dataregister D10 designated by operand S1.Since bit 8 of data register D11 is the first point that is on, the offset from thefirst search point is 24, and 24 is stored to data register D100 designated byoperand D1.ONSearched area24D100