FP_EXCHANGE

Exchange data

This FP instruction exchanges the contents of the variables connected to d1 and d2 if the trigger EN is TRUE.

Remarks

  • The input and output variables have to be of the same data type.

  • The operands d1_Start and d2_End should be:

    • in the same memory area, e.g. DT, WR, FL, LD ...
    • d1_Start £ d2_End

Parameters

Input/output

d1 (INT, UINT, WORD, DINT, UDINT, DWORD, REAL, DATE, TOD, DT)

Variable to be exchanged with d2

d2 (INT, UINT, WORD, DINT, UDINT, DWORD, REAL, DATE, TOD, DT)

Variable to be exchanged with d1

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.
sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.
Related topics:

Example

POU header

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

POU body

When the variable bStart changes from FALSE to TRUE, the function is carried out.

LD body

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

ST body

IF DF(bStart) then
    FP_EXCHANGE(d1 := iValue_1, d2 := iValue_2);
END_IF;

Modified on: 2019-08-23Feedback on this pagePanasonic hotline