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.
Input
Bit position to be inverted (permissible range: 0–15)
Input/output
Result
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
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 := 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
IF DF(start) then
FP_INVERT_BIT(n_Pos := 1, d := wOutput_value);
END_IF;