333
4
4 Instructions 4.12.4 Other Peripheral Instructions
◆
Operands
Operand
Bit Element Word Element
System·User System·User Bit Designation Indexed Address Constant
Real
Number
S X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
D X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
Note: The elements in gray background are supported.
◆
Function
Binary numbers are converted to gray code equivalents.
S is the BIN data source or data variable unit to be converted, in the range 0 to 32,767 in 16-bit operation
or 0 to 2,147,483,647 in 32-bit operation. When this range is exceeded, M8067 and M8068 are set to ON
and the instruction is not executed.
D is the unit that stores the gray code value after conversion.
Algorithm for BIN-to-gray code conversion: XOR operation is performed on every bit starting from the
rightmost bit and a left-hand bit to get the gray code value. The leftmost bit remains unchanged (with a
value of 0).
Example:
Execution result:
0 0 0 0 1 1 0 1 1 0 0 1 0 1 1 0
1 0 1 1 0 1 0 1 1 1 0 1
(K3478)
BIN
GRY
Y23 Y10
S
D
GBIN: Gray code inverse conversion
◆
Overview
The GBIN instruction converts gray code values to binary equivalents.
GBIN S D
Gray code inverse
conversion
Applicable model:
H3U
S Data source
Gray code value or data variable unit to be converted,
in the range 0 to 32,767 in 16-bit operation or 0 to
2,147,483,647 in 32-bit operation
16-bit instruction
(5 steps)
GBIN:
Continuous
execution
GBINP: Pulse
execution
32-bit instruction
(9 steps)
DGBIN:
Continuous
execution
DGBINP: Pulse
execution
D
Operation
result
Unit that stores the BIN value after conversion