Two-Way Radio User Manual

3. Instruction Set
3-389
API Mnemonic Operands Function
170
D GRY P
BIN Gray Code
Controllers
ES2/EX2 SS2 SA2
SE
SX2
Bit Devices Word devices Program Steps Type
OP
X Y M S K H KnX KnY KnM KnS T C D E F
S * * * * * * * * ***
D * * * * * ***
GRY, GRYP: 5 steps
DGRY, DGRYP: 9 steps
PULSE 16-bit 32-bit
ES2/EX2 SS2
SA2
SE
SX2 ES2/EX2 SS2
SA2
SE
SX2 ES2/EX2 SS2
SA2
SE
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.
X0
GRY K6513 K4Y20
00011 100 011 1 1000
b15
b0
K6513=H1971
000 0 0 00 001111111
K4Y20
Y37 Y20
GRAY 6513