Automationdirect.com DL05 User Manual page 239

Micro plc
Hide thumbs Also See for DL05:
Table of Contents

Advertisement

Gray Code (GRAY)
The Gray code instruction converts a 16 bit gray code
DS5
Used
value to a BCD value. The BCD conversion requires 10
HPP
Used
bits of the accumulator. The upper 22 bits are set to "0".
This instruction is designed for use with devices (typically
encoders) that use the grey code numbering scheme. The
Gray Code instruction will directly convert a gray code
number to a BCD number for devices having a resolution
of 512 or 1024 counts per revolution. If a device having
a resolution of 360 counts per revolution is to be used
you must subtract a BCD value of 76 from the converted
value to obtain the proper result. For a device having a
resolution of 720 counts per revolution you must subtract
a BCD value of 152.
In the following example, when X1 is ON the binary value represented by X10–X27 is loaded
into the accumulator using the Load Formatted instruction. The gray code value in the
accumulator is converted to BCD using the Gray Code instruction. The value in the lower 16
bits of the accumulator is copied to V2010.
Discrete Bit Flags
SP63
SP70
DirectSOFT 5
Direct SOFT32
X1
LDF
X10
Load the value represented
by X10–X27 into the lower
16 bits of the accumulator
GRAY
Convert the 16 bit grey code
value in the accumulator to a
BCD value
OUT
V2010
Copy the value in the lower
16 bits of the accumulator to
V2010
Handheld Programmer Keystrokes
$
B
ENT
STR
1
L
D
F
SHFT
ANDST
3
5
G
R
A
SHFT
6
ORN
0
GX
V
SHFT
OUT
AND
On when the result of the instruction causes the value in the accumulator to be zero.
On anytime the value in the accumulator is negative.
K16
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
B
A
B
1
0
1
Y
ENT
MLS
C
A
B
A
ENT
2
0
1
0
DL05 Micro PLC User Manual, 6th Edition, Rev. D
Chapter 5: Standard RLL Instructions
Description
X27
OFF
15 14 13 12 11 10 9
0
0 0 0 0 0 0 0 0 0 0 0 0 0 1
15 14 13 12 11 10 9
0
0 0 0 0 0 0 0 0 0 0 0 0 0 1
Gray Code
0000000000
0000000001
0000000011
0000000010
0000000110
G
ENT
6
0000000111
0000000101
0000000100
1000000001
1000000000
GRAY
X26
X25
X12
X11
OFF
OFF
ON
OFF
8 7
6 5 4 3 2 1 0
8 7
6 5 4 3 2 1 0
BCD
0
0
0
6
0000
0001
V2010
0002
0003
0004
0005
0006
0007
1022
1023
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
X10
ON
11
11
12
12
0 1
13
13
14
14
1 0
a
A
B
b
c
C
D
D
5-93

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DL05 and is the answer not in the manual?

Table of Contents