FP_COMPARE_BLOCK

Comparison of data blocks

Compares the contents of the data block specified by s3_StartBlock1 with the contents of the data block specified by s4_StartBlock2 if the trigger EN is TRUE. s1_Control specifies the byte positions and n_Bytes the number of bytes.

Parameters

Input

s1_Control (WORD, INT, UINT)

Control code specifying byte positions

n_Bytes (WORD, INT, UINT)

Number of bytes to be compared. Values: 1–99

s3_StartBlock1 (WORD, INT, UINT)

Starting address of data block 1 to be compared to s4_StartBlock2

s4_StartBlock2 (WORD, INT, UINT)

Starting address of data block 2 to be compared to s3_StartBlock1

Output

d_IsEqual (BOOL)

Compare operation result

TRUE if s3_StartBlock1 = s4_StartBlock2

Remarks

  • Specifying the control code s1_Control

    1.  (1) Starting byte position of the data block specified by s3_StartBlock1

      1: starting from higher byte

      0: starting from lower byte

    2.  (2) Starting byte position of the data block specified by s4_StartBlock2

      1: starting from higher byte

      0: starting from lower byte

  • The variables s3_StartBlock1 and s4_StartBlock2 have to be of the same data type.

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*)
		wControlCode: WORD:=16#11;
			(*s3 starting from upper byte
s4 starting from upper byte
compare 6 bytes*)
		iNumberOfBytes: INT:=6;
			(*number of bytes to be compared*)
		awDataBlock1: ARRAY [0..2] OF WORD:=[3(0)];
		aiDataBlock2: ARRAY [0..5] OF INT:=[6(1234)];
		bCompareResult: BOOL:=FALSE;
	END_VAR

POU body

When the variable bStart is set 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 := 8 ;
        NETWORK_BODY
B(B_F,FP_COMPARE_BLOCK!,,13,1,24,8,,?DEN?Ds1_Control?Dn_Bytes?Ds3_StartBlock1?Ds4_StartBlock2?AENO?Cd_IsEqual);
B(B_CONTACT,,bStart,5,2,7,4,);
B(B_VARIN,,wControlCode,11,3,13,5,);
B(B_VARIN,,iNumberOfBytes,11,4,13,6,);
B(B_VARIN,,awDataBlock1[0],11,5,13,7,);
B(B_VARIN,,aiDataBlock2[0],11,6,13,8,);
B(B_VAROUT,,bCompareResult,24,3,26,5,);
L(1,3,5,3);
L(7,3,13,3);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If (bStart) then
    FP_COMPARE_BLOCK(s1_Control := wControlCode,
                     n_Bytes := iNumberOfBytes,
                     s3_StartBlock1[0] := awDataBlock1,
                     s4_StartBlock2[0] := aiDataBlock2,
                     d_IsEqual => bCompareResult);
End_if;

Modified on: 2022-09-27Feedback on this pagePanasonic hotline