Convert to Integer (BCD_TO)

The BCD_TO instruction converts a BCD value (Source) to a decimal value and stores the result in the Destination.
This formula is used for calculations when source is 32bits:
Destination =(16#Source8*10
7
)+ (16#Source7*10
6
)+ (16#Source6*10
5
)+( 16#Source5*10
4
)+ (16#Source4*10
3
)+(16#Source3*10
2
)+ (16#Source2*10
1
)+( 16#Source1*10
0
)
For example:
Source = 16#1234_567E
Destination = (1*10
7
)+(2*10
6
)+(3*10
5
)+ (4*10
4
)+(5*10
3
)+(6*10
2
)+(7*10
1
)+ (14*10
0
)=12345684
Available Languages
Ladder Diagram
Operands
IMPORTANT: Unexpected operation may occur if:
  • Output tag operands are overwritten
  • Members of a structure operand are overwritten
  • Except when specified, structure operands are shared by multiple instructions.
There are data conversion rules for mixing numeric data types within an instruction. See Data conversions.
Ladder Diagram
Operand
Data Type
Format
Description
Source
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
Immediate
tag
Value to convert to decimal
Destination
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
tag
Tag to store the result
Affects Math Status Flags
Conditional. See Math status flags.
Major/Minor Faults
None specific to this instruction. See Common Attributes for operand related faults.
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
N/A
Rung-condition-in is false
Set Rung-condition-out to Rung-condition-in.
Rung-condition-in is true
Set Rung-condition-out to Rung-condition-in.
Dest = decimal value of source with BCD value.
Postscan
N/A
Examples
Ladder Diagram
BCD_TO ladder example
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.