Binary value of DWORD into DOUBLE INTEGER
DWORD_BCD_TO_DINT converts a binary coded value of the data type DWORD into a binary value of the data type DINT in order to be able to process a BCD value in double word format.
Input
Input data type
Output
Conversion result
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.
BCD constants can be indicated in Control FPWIN Pro as follows:
2#00011001100101010001100110010101 or 16#19951995
BCD_value_32bit of the data type DOUBLE WORD is converted into a DOUBLE INTEGER value. The converted value is written into DINT_value.
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,,BCD_value_32bit,13,2,15,4,);
B(B_VAROUT,,DINT_value,27,2,29,4,);
B(B_F,DWORD_BCD_TO_DINT!,Instance,15,2,27,4,,?D?C);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
DINT_value:=DWORD_BCD_TO_DINT(BCD_value_32bit);
LD |
BCD_value_32bit |
DWORD_BCD_TO_DINT |
|
ST |
DINT_value |