BCD value of WORD into INTEGER
WORD_BCD_TO_INT converts a binary coded BCD value of WORD into binary values of type INT.
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
BCD_value_16bit: WORD:=0;
INT_value: INT:=0;
END_VAR
This example uses variables. You can also use a constant for the input variable.
BCD constants can be expressed in Control FPWIN Pro7 as follows: 2#0001100110010101 or 16#1995
BCD_value_16bit of the data type WORD is converted into an INTEGER value. The converted value is written into output variable INT_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_16bit,12,1,14,3,);
B(B_VAROUT,,INT_value,25,1,27,3,);
B(B_F,WORD_BCD_TO_INT!,Instance,14,1,25,3,,?D?C);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
INT_value:=WORD_BCD_TO_INT(BCD_value_16bit);
LD |
BCD_value_16bit |
WORD_BCD_TO_INT |
|
ST |
INT_value |