Higher/lower byte in 16-bit data exchange
The higher byte (higher 8-bits) and lower bytes (lower 8-bits) of a 16-bit area specified by d are exchanged if the trigger EN is in the ON-state. 1 byte means 8 bit.
Output
16-bit area in which the higher and lower bytes are swapped (exchanged)
Instead of using this F instruction, we recommend using the corresponding FP7 instruction: FP_SWAP_BYTES
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
start: BOOL:=FALSE;
(*activates the function*)
swap_value: WORD:=16#2345;
(*result after 0->1 leading
edge from start: 16#4523*)
END_VAR
When the variable start 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 := 7 ;
NETWORK_BODY
B(B_CONTACT,,start,3,2,5,4,);
B(B_F,F17_SWAP!,Instance,5,1,12,5,,?DEN?AENO?Cd);
B(B_VAROUT,,swap_value,12,3,14,5,);
L(1,3,3,3);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF start then
F17_SWAP(swap_value);
END_IF;
LD |
start |
(* EN = start; Starting signal for the F17_SWAP function. *) |
F17_SWAP |
swap_value |
(* d = swap_value (source/destination) *) |
(* Byte1Byte0 ゙ Byte0Byte1 *) |
||
ST |
out |
(* option *) |