 FP_DATA_MEAN_SUM_UDINT0
FP_DATA_MEAN_SUM_UDINT0Calculate total and mean numbers in data table of UDINT numbers
This FP instruction calculates the sum and the arithmetic mean of UDINTnumbers in the data table specified by s1_Start and s2_End. The sum of all elements in the data table is returned at output d1_Sum and the arithmetic mean of all elements in the data table is returned at output d2_Mean. The arithmetic mean is rounded off if it is not a whole number.

Input
Beginning of data table
End of data table
Output
Sum of all elements in data table area specified
Mean of all elements in data table area specified
if the area specified using the index modifier exceeds the limit.
if s1_Start >s2_End
if s1_Start and s2_End belong to different data areas.
if the area specified using the index modifier exceeds the limit.
if s1_Start >s2_End
if s1_Start and s2_End belong to different data areas.
Corresponding F instructions: F275_MEAN, F276_DMEAN, F352_FMEAN

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*)
		audiDataField: ARRAY [0..4] OF UDINT:=[31111,42440,55555,61000,87778];
		udiSum: UDINT:=0;
			(*the sum of all elements of 
data_array; here: 161688*)
		uiMean: UINT:=0;
			(*the arithmetic mean of all
elements of data_array;
here: 32337*)
	END_VARWhen 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 := 6 ;
        NETWORK_BODY
B(B_CONTACT,,bStart,6,2,8,4,);
B(B_VARIN,,audiDataField[0],8,3,10,5,);
B(B_VARIN,,audiDataField[4],8,4,10,6,);
B(B_VAROUT,,udiSum,24,3,26,5,);
B(B_VAROUT,,uiMean,24,4,26,6,);
B(B_F,FP_DATA_MEAN_SUM_UDINT0!,,10,1,24,6,,?DEN?Ds1_Start?Ds2_End?AENO?Cd1_Sum?Cd2_Mean);
L(1,3,6,3);
L(8,3,10,3);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY
IF bStart then
    FP_DATA_MEAN_SUM_UDINT0(s1_Start := audiDataField[0], 
                         s2_End := audiDataField[4], 
                         d1_Sum => udiSum, 
                         d2_Mean => udiMean);
END_IF;