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.
Input/output
Bit area to be inverted
if the area specified using the index modifier exceeds the limit.
if the area specified using the index modifier exceeds the limit.
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
When the variable bStart changes from FALSE 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 := 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
IF DF(bStart) then
FP_INVERT(d := wInvert_value);
END_IF;