DVP-ES2/EX2/EC5/SS2/SA2/SX2/SE&TP Operation Manual - Programming
API
Mnemonic Operands Function
170 D
GRY P
BIN → Gray Code
Type
OP
Bit Devices Word devices Program Steps
X Y M S K H KnX
KnY
KnM
KnS
T C D E F
GRY, GRYP: 5 steps
DGRY, DGRYP: 9 steps
SS2
SX2
SS2
SX2
SS2
SX2
Operands:
S: Source device D: Operation result (Gray code)
Explanations:
1. GRY instruction converts the BIN value in S to Gray Code and stores the converted result in
specified register D.
2. Available range of S:
16-bit instruction: 0~32,767
32-bit instruction: 0~2,147,483,647
3. If operand S exceeds the available range, operation error occurs and M1067 = ON, M1068 =
ON. D1067 stores the error code 0E1A (HEX)
4. If operands S and D use device F, only 16-bit instruction is applicable.
Program Example:
When X0 = ON, GRY instruction executes and converts K6513 to Gray Code. The operation result
is stored in K4Y20, i.e. Y20 ~ Y37.
0 0 0 1 1 10 0 0 1 1 1 10 0 0
b15
b0
K6513=H1971
0 0 0 0 0 0 0 0 0 1111111
K4Y20
Y37 Y20
GRAY 6513