7.11 String Processing Instructions
7.11.6 Decimal ASCII data to 4-/8-digit BCD data conversion
7-175
7
APPLI
C
A
T
IO
N
INSTRUCTIONS
DABCD, DDAB
C
D
DABCD, DDABCD
O
peration Error
In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and
the corresponding error code is stored to SD0.
• There are characters within the data of
that are outside the range of 0 to 9.
(Error code: 4100)
• The device specified for
exceeds the corresponding device range. (For Universal
model QCPU only)
(Error code: 4101)
Program Example
(1) In the following program, the decimal ASCII data set in Var_D20 are converted to the 4-digit
BCD data, and the result is output to Y40 to Y4F.
[Structured ladder]
[ST]
DABCDP(SM400,Var_D20,K4Y40);
[Operation]
(2) In the following program, the hexadecimal ASCII data set in Var_D20 are converted to 8-digit
BCD data, and the result is stored to Var_D10, and also they are output to Y40 to Y5F.
[Structured ladder]
[ST]
IF SM400 THEN
DDABCDP(TRUE,Var_D20,Var_D10);
DMOV(TRUE,Var_D10,K8Y40);
END_IF;
[Operation]
s
s
Output of the converted
BCD value to the display.
20
H
(
space
)
34
H
(4)
39
H
(9)
34
H
(4)
b15
b8 b7
b0
B
C
D
va
l
ue
0 4 9 4
Y4F
Y40
494
R
egar
d
e
d
as
0494
Var
_
D
20
Output of the converted
BCD value to the display.
20
H
(
space
)
34
H
(4)
39
H
(9)
37
H
(7)
b15
b8b7
b0
32
H
(2)
39
H
(9)
34
H
(4)
39
H
(9)
B
C
D
va
l
ue
0 4 9 7 2 9 4 9
R
egar
d
e
d
as
04972949
B
C
D
va
l
ue
0 4 9 7 2 9 4 9
Var
_
D
10
Y5F
Y50 Y4F
Y40
D
MO
V
" 4972949"
Var
_
D
20[1]
Var
_
D
20[2]
Var
_
D
20[0]
Var
_
D
20[3]
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: ......