DEC_TO_BCD

DEC_TO_BCD 1:

The function block "DEC_TO_BCD" allows decimal numbers to be converted to BCD format. The number to be converted is checked for admissibility of the values.

DEC_TO_BCD 2: Inputs

VAR_INPUT
    START  : BOOL;
    DIN    : BYTE;
END_VAR

Name

Type

Description

START

BOOL

The function block is activated by a positive edge at this input.

DIN

Byte

The decimal number requiring conversion

DEC_TO_BCD 3: Outputs

VAR_OUTPUT
    BUSY   : BOOL;
    ERR    : BOOL;
    ERRID  : UDINT;
    BOUT   : BYTE;
END_VAR

Name

Type

Description

BUSY

BOOL

This output is set at the start of the conversion procedure, and remains set until the conversion has been completed. Once the BUSY output has been reset, the BCD value is available at the BOUT output.

ERR

BOOL

This variable is set to TRUE if an error occurs.

ERRID

UDINT

Error code

BOUT

BYTE

The converted variable in BCD format is available at this output if the process is successful.

Error Codes:

Error Code

Error Description

0

no error

0x00FF

the variable that is to be converted has a forbidden decimal value

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)