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*106
)+ (16#Source6*105
)+( 16#Source5*104
)+ (16#Source4*103
)+(16#Source3*102
)+ (16#Source2*101
)+( 16#Source1*100
)For example:
Source = 16#1234_567E
Destination = (1*10
7
)+(2*106
)+(3*105
)+ (4*104
)+(5*103
)+(6*102
)+(7*101
)+ (14*100
)=12345684Available 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
Provide Feedback