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.
Input
Control code specifying byte positions
Number of bytes to be compared. Values: 1–99
Starting address of data block 1 to be compared to s4_StartBlock2
Starting address of data block 2 to be compared to s3_StartBlock1
Output
Compare operation result
TRUE if s3_StartBlock1 = s4_StartBlock2
Specifying the control code s1_Control
1: starting from higher byte
0: starting from lower byte
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.
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
When the variable bStart 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 := 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
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;