Conversion instructions
244
Part II IEC Instructions
INT_TO_BCD_WORD
INTEGER into BCD value of WORD
To add an enable input and enable output to the instruction, select [With EN/ENO] from the
"Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the
context menu or press <Ctrl>+<Shift>+<v> in the programming window.
PLC types
Availability of INT_TO_BCD_WORD (see page 1327)
Since the output variable is of the type WORD and is therefore comprised of 16
bits, the value for the input variable is limited to 4 digits and must be between 0
and 9999.
Data type I/O Function
INT Input input data type
BCD_WORD Output conversion result
Description
INT_TO_BCD_WORD converts a binary value of the data type INT into a binary coded decimal
integer (BCD) value of the type WORD in order to be able to output BCD values in word format.
Data types
Example
In this example, the same POU header is used for all programming languages. For an example
using IL (instruction list), please refer to the online help.
POU header
All input and output variables used for programming this function have been declared in the POU
header.
This example uses variables. You can also use a constant for the input variable.
Body
INT_value of the data type INTEGER is converted into a BCD value of the data type WORD. The
converted value is written into BCD_value_16bit.
LD
ST
When programming with structured text, enter the following:
BCD_value_16bit:=INT_TO_BCD_WORD(INT_value);