5 Applied Functions
5.1 Type Conversion Functions
118
FXCPU Structured Programming Manual
(Application Functions)
5.1.41 BCD_TO_INT(_E)
Outline
This function converts BCD data into word [signed] data, and outputs the data obtained by conversion.
1. Format
*1.
Output variable
2. Set data
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts BCD data stored in a device specified in
into word [signed] data, and outputs the
data obtained by conversion to a device specified in
.
Cautions
Use the function having "_E" in its name to connect a bus.
Error
When the source data is not BCD (decimal number), M8067 (operation error) turns ON.
FX
3U(C)
FX
3G
FX
2N(C)
FX
1N(C)
FX
1S
FX
U
/FX
2C
FX
0N
FX
0(S)
Function name
Expression in each language
Structured ladder
ST
BCD_TO_INT
BCD_TO_INT(_BCD);
Example:
D10:=
BCD_TO_INT(D0);
BCD_TO_INT_E
BCD_TO_INT_E(EN,_BCD,
Output label);
Example:
BCD_TO_INT_E(X000,D0,D10);
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_BCD (
)
Conversion source BCD data
Word [unsigned]/
Bit String [16-bit]
Output
variable
ENO
Execution status
Bit
*1
(
)
Word [signed] data after conversion
Word [signed]
BCD_TO_INT
_BCD
*1
D0
D10
BCD_TO_INT_E
EN
ENO
*1
D10
X000
D0
_BCD
s
d
s
d
9999H
9999
Word [unsigned]/
bit string [16-bit] data
Thousands place Hundreds place
Tens place
Ones place
Word [signed] data
Conversion into word [signed] data
9999H
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
0
3276516354 8192 4095 2048 1024 512
256
128
64
32
16
8
4
2
1
8000 4000 2000 1000 800
400
200
100
80
40
20
10
8
4
2
1
0
1
0
0
1
1
1
0
0
0
0
1
1
1
1
9999
Always becomes "0".