Exchange data
This FP instruction exchanges the contents of the variables connected to d1 and d2 if the trigger EN is TRUE.
The input and output variables have to be of the same data type.
The operands d1_Start and d2_End should be:
d1_Start £ d2_End
Input/output
Variable to be exchanged with d2
Variable to be exchanged with d1
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*)
iValue_1: INT:=17;
(*result after a 0->1 leading
edge from start: 24*)
iValue_2: INT:=24;
(*result after a 0->1 leading
edge from start: 17*)
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 := 6 ;
NETWORK_BODY
B(B_F,FP_EXCHANGE!,,13,1,21,6,,?DEN?Dd1?Ad1?Dd2?Ad2?AENO);
B(B_CONTACT,,bStart,5,2,7,4,R);
B(B_VARIN,,iValue_1,11,3,13,5,);
B(B_VARIN,,iValue_2,11,4,13,6,);
L(1,3,5,3);
L(7,3,13,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(bStart) then
FP_EXCHANGE(d1 := iValue_1, d2 := iValue_2);
END_IF;