TO_BCD_LWORD block

Short summary

Name

TO_BCD_LWORD

→POU type

→function

Category

IEC-block, Convert

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/check.svg no restrictions

Graphical interface

images/download/thumbnails/414781063/TO_BCD_LWORD-version-1-modificationdate-1534929612753-api-v2.png

Available since

version 1.22.0 (for logi.CAD 3)

Functionality

The block converts a decimal value into a binary coded decimal value (a →BCD-value) .

At input IN, connect the decimal value that should be converted. If the decimal value has more than 16 digits, only the 16 rightmost digits are considered. The remaining digits are not accepted by the data type of the return value. In case of decimal values < 0, the block always returns value 0.

Inputs, return value


Identifier

→Data type

Description

Inputs:

IN

USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT)

decimal input value

Return value:

LWORD


Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

Example for usage within ST-editor

PROGRAM Test
VAR
result1, result2 : LWORD;
END_VAR
result1 := TO_BCD_LWORD(IN := 215_832_767); (* The variable 'result' evaluates to '16#0000_0002_1583_2767' (decimal: 8_950_851_431). *)
result2 := TO_BCD_LWORD(IN := 238_183_205_215_832_767); (* The variable 'result' evaluates to '16#8183_2052_1583_2767' (decimal: 9_332_338_389_762_123_623). *)
(* Note: The single underscore character '_' has been inserted as separator to make the decimal values in the sample more readable. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.