The ENCO/ENCOP instructions encode values. The value in S1 is encoded and saved in D1. Among the 32 bits of S1, the position of the ON bit is output to D1 as a binary value. When multiple bits are ON in S1, the uppermost bit position is output. The ENCO/ENCOP instructions always pass power.
When using ENCO/ENCOP instructions, an error will occur if the variables specified in operands S1 and D1 are not the same type. Designate the same variable type in all operands S1 and D1.
Refer to the following for specifying a constant.
When operand D1 is an integer variable
When operand D1 is an integer variable and you want to input hexadecimal values in operand S1.
When 0x (zero and lower case "x") is input, the following values become hexadecimal values.
When Converting Data in a Specified Array (Integer Variable Array)
you can either specify the entire array with operands S1 and D1, or specify the array elements individually.
When you define an entire array in the operand settings, encoding starts from array element [0]. If an error arises partway through encoding, the remaining array elements are not encoded.