6-88
6.3 Data Conversion Instructions
6.3.9 16-/32-bit BIN data to Gray code conversion
GRY, DGRY
DGRY(P)
Converts 32-bit BIN data in the device specified for
to Gray code, and stores the result to the
device specified for
.
Negative values cannot be specified for
.
O
p
erat
i
on
E
rror
In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the
corresponding error code is stored to SD0.
• The value of
is a negative number.
(Error code: 4100)
Program
E
xam
pl
e
(1) In the following program, the BIN value in Var_D100 is converted to Gray code when X10
turns ON, and the result is stored to Var_D200.
[Structured ladder]
[ST]
GRYP(X10,Var_D100,Var_D200);
(2) In the following program, the BIN value in Var_D10 is converted to Gray code when X1C
turns ON, and the result is stored to Var_D100.
[Structured ladder]
[ST]
DGRYP(X1C,Var_D10,Var_D100);
s
d
s
0
B
IN
30
541
989
6
0
0
1
0 0
1
0 0 0
1 1
0
1
0 0 0
1
0
1
0
1 1
0 0
1 1 1 1
0 0 0
b
3
1
b16
b
0
b15
0
Gray
code
30
541
989
6
0
0
1 1
0
1 1
0 0
1
0
1 1 1
0 0
1 1 1 1 1
0
1
0
1
0 0 0
1
0 0
s
d
b
3
1
b16
b
0
b15
s
d
(
Upp
er
16 bi
ts)
(
L
o
w
er
16 bi
ts)
s
Summary of Contents for MELSEC Q Series
Page 1: ...Structured Programming Manual Mitsubishi Programmable Controller QCPU Common Instructions ...
Page 2: ......
Page 14: ...A 12 MEMO ...
Page 340: ...6 178 MEMO MTR ...
Page 708: ...7 368 MEMO ...
Page 776: ...8 68 MEMO ...
Page 796: ...9 20 MEMO ...
Page 804: ...App 8 MEMO ...
Page 812: ...Index 8 MEMO ...
Page 815: ......