FP_INVERT

Data inversion (one's complement)

This FP instruction inverts each bit (0 or 1) of the data area specified by d if the trigger EN is TRUE. The result is stored in the data area specified by d. This instruction is useful for controlling an external device that uses negative logic operation.

Parameters

Input/output

d (WORD, DWORD)

Bit area to be inverted

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 function*)
		wInvert_value: WORD:=2#111000111000;
			(*result after a 0->1 leading
edge from start:
2#000111000111*)
	END_VAR

POU body

When the variable bStart changes from FALSE 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 := 4 ;
        NETWORK_BODY
B(B_F,FP_INVERT!,,12,0,19,4,,?DEN?Dd?Ad?AENO);
B(B_CONTACT,,bStart,7,1,9,3,R);
B(B_VARIN,,wInvert_value,10,2,12,4,);
L(1,2,7,2);
L(9,2,12,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF DF(bStart) then
    FP_INVERT(d := wInvert_value);
END_IF;

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