Gray code -> binary data conversion
This FP instruction converts the gray code value at input s into binary data if the trigger EN is TRUE. The result is stored in d.
Input
Gray code value
Output
Binary data
if the area specified using the index modifier exceeds the limit.
if the area specified using the index modifier exceeds the limit.
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
bStart: BOOL:=FALSE;
(*activates the fuction*)
dwInput_value: DWORD:=16#0000000E;
dwConversionResult: DWORD:=0;
(*result after a 0->1 leading
edge from start:
16#0000000B*)
END_VAR
When the variable bStart is set to TRUE, the function is carried out.
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,FP_GRAY_TO_BIN!,,11,1,20,5,,?DEN?D@'s'?AENO?Cd);
B(B_CONTACT,,bStart,7,2,9,4,);
B(B_VARIN,,dwInput_value,9,3,11,5,);
B(B_VAROUT,,dwConversionResult,20,3,22,5,);
L(1,3,7,3);
L(9,3,11,3);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF bStart then
FP_GRAY_TO_BIN(s := dwInput_value, d => dwConversionResult);
END_IF;