Exchange higher bytes and lower bytes
This FP instruction exchanges the higher bytes and lower bytes of the data area specified by s if the trigger EN is TRUE. The result is transferred to d.
Input
Source data area
Output
Destination data area
Corresponding F instructions: F17_SWAP
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*)
wSwapValue: WORD:=16#2345;
(*result after 0->1 leading
edge from start: 16#4523*)
wResult: WORD:=0;
END_VAR
When the variable bStart changes from FALSE to TRUE, the function is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_CONTACT,,bStart,3,2,5,4,R);
B(B_F,FP_SWAP_BYTES!,,12,1,21,5,,?DEN?D@'s'?AENO?Cd);
B(B_VARIN,,wSwapValue,10,3,12,5,);
B(B_VAROUT,,wResult,21,3,23,5,);
L(1,0,1,6);
L(1,3,3,3);
L(5,3,12,3);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(bStart) THEN
FP_SWAP_BYTES(s := wSwapValue_Copy, d => wResult);
END_IF;