TO_BCD_BYTE block

Short summary

Name

TO_BCD_BYTE

→POU type

→function

Category

Standard (non-safe), Convert

Conform to →IEC-standard

(tick) no restrictions

Graphical interface

Available since

version 1.22.0 (for Neuron Power Engineer) - initial variant

version 3.8.0 (for library Standard (non-safe)): block moved in this library

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 2 digits, only the 2 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

USINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_INT

decimal input value

Return value:

BYTE

 

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

See:

Example for usage within ST-editor

PROGRAM Test
    VAR
        result1, result2 : BYTE;
    END_VAR
    result1 := TO_BCD_BYTE(IN := 21);       (* The variable 'result' evaluates to '16#21' (decimal: 33). *)
    result2 := TO_BCD_BYTE(IN := 321);      (* The variable 'result' evaluates to '16#21' (decimal: 33). *)
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.