FP_BIN_TO_GRAY

Binary -> gray code conversion

This FP instruction converts the binary data at input s into a gray code value if the trigger EN is TRUE. The result is stored in d.

Parameters

Input

s (WORD, DWORD)

Binary data

Output

d (WORD, DWORD)

Gray code value

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.
Related topics:

Decimal to binary/BCD/gray code table

System instructions

Instructions pane

Memory areas

Data types

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#0000000B;
		dwConversionResult: DWORD:=0;
			(*result after a 0->1 leading
edge from start:
16#0000000E*)
	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_BIN_TO_GRAY!,,12,1,21,5,,?DEN?D@'s'?AENO?Cd);
B(B_CONTACT,,bStart,7,2,9,4,);
B(B_VARIN,,dwInput_value,10,3,12,5,);
B(B_VAROUT,,dwConversionResult,21,3,23,5,);
L(1,3,7,3);
L(9,3,12,3);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

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

Modified on: 2019-05-15Feedback on this pagePanasonic hotline