INT_TO_BCD_WORD

INTEGER into binary coded WORD value

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.

Parameters

Input

Unnamed input (INT)
Input data type

Output

Unnamed output (BCD_WORD)
Conversion result

Remarks

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.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		INT_value: INT:=0;
		BCD_value_16bit: WORD:=0;
	END_VAR
	VAR
		INT_value: INT:=0;
		BCD_value_16bit: WORD:=0;
	END_VAR

This example uses variables. You can also use a constant for the input variable.

POU 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 body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_F,INT_TO_BCD_WORD!,Instance,11,1,22,3,,?D?C);
B(B_VARIN,,INT_value,9,1,11,3,);
B(B_VAROUT,,BCD_value_16bit,22,1,24,3,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

BCD_value_16bit:=INT_TO_BCD_WORD(INT_value);

IL body

LD

INT_value

INT_TO_BCD_WORD

ST

BCD_value_16bit

Modified on: 2019-01-24Feedback on this pagePanasonic hotline