FP_GRAY_TO_BIN

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.

Parameters

Input

s (WORD, DWORD)

Gray code value

Output

d (WORD, DWORD)

Binary data

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.

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

POU body

When the variable bStart is set to TRUE, the function is carried out.

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,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

ST body

IF bStart then
    FP_GRAY_TO_BIN(s := dwInput_value, d => dwConversionResult);
END_IF;

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