-

BCD_TO_*

Type Function
Description Converts any BCD input value (binary-coded decimal number) into an output value of the connected unsigned integer data type.

"*" is a placeholder for the supported data types. The function is available for the output data types USINT, UINT, UDINT and ULINT.

The function is an overloaded function. It can operate on all BCD input data types (BYTE, WORD, DWORD and LWORD).
Parameters Input

IN

Output

OUT
Conversion rules If an incorrect input value (outside the permissible value range 0 to 9) is connected or an overflow occurs, the maximum value is output. For example, the input values 16#0A (BYTE) or 16#0A23 (WORD) or 16#0A0B0A0B (DWORD) or 16#00000000110A0B (LWORD) result in the maximum output value (e.g., 4,294,967,295 for an UDINT output).

Note
In some cases it is not possible to differ whether the returned value is a correct value or the maximum value which is returned when a wrong BCD value is connected. If, for example, the input value WORD#255 is connected to the BCD_TO_USINT function, the function returns the correct value 255, the same value as the maximum USINT value / error indication value (see item above).

Error behavior Error behavior
Additional information EN/ENO behavior