F18_BXCH

16-bit blocked data exchange

The function exchanges one 16-bit data block for another. The beginning of the first data block is specified at output d1_Start and its end at output d2_End. Output d3_Start specifies the beginning of the second data block.

Example

Parameters

Output

d1_Start (WORD, INT, UINT)

starting 16-bit area of block data 1

d2_End (WORD, INT, UINT)

ending 16-bit area of block data 1

d3_Start (WORD, INT, UINT)

starting 16-bit area of block data 2

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the address of the variables at outputs d1_Start > d2_End

  • if the data block to be exchanged is larger than the target area.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the address of the variables at outputs d1_Start > d2_End

  • if the data block to be exchanged is larger than the target area.

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
		start: BOOL:=FALSE;
			(*activates the function*)
		d1: ARRAY [0..5] OF INT:=[1,2,3,4,5,6];
			(*result after a 0->1 leading
edge from start:
[1,2,8,9,10,6]*)
		d2: ARRAY [0..5] OF INT:=[7,8,9,10,11,12];
			(*result after a 0->1 leading
edge from start:
[7,3,4,5,11,12]*)
	END_VAR

POU body

When the variable start is set to TRUE, the function is carried out.

It exchanges the data of ARRAY data_field_1 (from the 2nd to the 5th element) with the data of ARRAY data_field_2 (from the 3rd element on).

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 13 ;
        NETWORK_BODY
B(B_VARIN,,output,5,1,7,3,);
B(B_VAROUT,,data_field_1[2],15,2,17,4,);
B(B_VAROUT,,data_field_1[5],15,3,17,5,);
B(B_VAROUT,,data_field_2[3],15,4,17,6,);
B(B_F,F18_BXCH,,7,0,15,6,,?DEN?AENO?Cd1?Cd2?Cd3);
B(B_COMMENT,,data_field_1[2] <----> data_field_2[3]ø^data_field_1[3] <----> data_field_2[4]ø^data_field_1[4] <----> data_field_2[5]ø^data_field_1[5] <----> data_field_2[6],24,4,41,8,);
B(B_COMMENT,,data_field_1[6]          data_field_2[7]ø^data_field_1[7]ø^data_field_1[8]ø^data_field_1[9],24,8,41,12,);
B(B_COMMENT,,                                 data_field_2[0]ø^data_field_1[0]          data_field_2[1]ø^data_field_1[1]          data_field_2[2],24,1,41,4,);
L(1,0,1,13);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF start then
    F18_BXCH(
         d1_Start=> d1[2], d2_End=> d1[4], d3_Start=>  d2[1]);
END_IF;

IL body

Modified on: 2019-01-25Feedback on this pagePanasonic hotline