FP_INVERT_BIT

Bit invert

This FP instruction inverts [1 (TRUE) ®0 (FALSE) or 0 (FALSE) ®1 (TRUE)] the bit at bit position n_Pos in the data area specified by d if the trigger EN is TRUE. Bits other than the bit specified do not change.

Parameters

Input

n_Pos (INT, DINT, UINT, UDINT)

Bit position to be inverted (permissible range: 0–15)

Input/output

d (WORD)

Result

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*)
		wOutput_value: WORD:=2#111;
			(*result after a 0->1 leading
edge from start: 2#101*)
	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 := 6 ;
        NETWORK_BODY
B(B_F,FP_INVERT_BIT!,,11,1,20,6,,?DEN?Dn_Pos?Dd?Ad?AENO);
B(B_CONTACT,,bStart,5,2,7,4,R);
B(B_VARIN,,1,9,3,11,5,);
B(B_VARIN,,wOutput_value,9,4,11,6,);
L(1,3,5,3);
L(7,3,11,3);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF DF(start) then
    FP_INVERT_BIT(n_Pos := 1, d := wOutput_value);
END_IF;

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