DOUBLE INTEGER into BCD DOUBLE WORD
DINT_TO_BCD_DWORD converts a value of the data type DINT into a BCD value of the data type DWORD.
Input
Output
The value for the input variable should be between 0 and 999,999,999.
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
DINT_value: DINT:=0;
BCD_value_32bit: DWORD:=0;
END_VAR
This example uses variables. You can also use a constant for the input variable.
DINT_value of the data type DOUBLE INTEGER is converted into a BCD value of the data type DOUBLE WORD. The converted value is written to BCD_value_32bit.
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_VARIN,,DINT_value,8,1,10,3,);
B(B_VAROUT,,BCD_value_32bit,22,1,24,3,);
B(B_F,DINT_TO_BCD_DWORD!,Instance,10,1,22,3,,?D?C);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
BCD_value_32bit:=DINT_TO_BCD_DWORD(DINT_value);
LD |
DINT_value |
DINT_TO_BCD_DWORD |
|
ST |
BCD_value_32bit |