FP_DATA_DEVIATION

Calculate deviation from data table

This FP instruction calculates the deviation from the values in a data table.

Parameters

Input

s1_Start (WORD, INT, UINT)

Beginning of data table

n_Number (WORD, INT, UINT)

Number of values

Output

d1_Variance (REAL)

Variance, deviation2

d2_Deviation (REAL)

Standard deviation, square root of variance

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
		arrData: ARRAY [0..31] OF INT:=[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1];
		rDeviation: REAL:=0.0;
		rVariance: REAL:=0.0;
		iNumberOfData: INT:=8;
		bStart: 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 := 5 ;
        NETWORK_BODY
B(B_F,FP_DATA_DEVIATION!,,15,0,26,5,,?DEN?Ds1_Start?Dn_Number?AENO?Cd1_Variance?Cd2_Deviation);
B(B_VARIN,,arrData[0],13,2,15,4,);
B(B_VARIN,,iNumberOfData,13,3,15,5,);
B(B_VAROUT,,rVariance,26,2,28,4,);
B(B_VAROUT,,rDeviation,26,3,28,5,);
B(B_CONTACT,,bStart,4,1,6,3,);
L(1,2,4,2);
L(6,2,15,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF bStart then
    FP_DATA_DEVIATION(s1_Start := arrData[0],
                      n_Number := iNumberOfData,
                      d1_Variance => rVariance, 
                      d2_Deviation => rDeviation);
END_IF;

Modified on: 2024-04-26Feedback on this pagePanasonic hotline