FP_DATA_DEVIATION

计算与数据表的偏差

该FP指令计算与数据表中数值的偏差。

参数

输入

s1_Start (WORD, INT, UINT)

数据表的开头

n_Number (WORD, INT, UINT)

数值数量

输出

d1_Variance (REAL)

方差,偏差2

d2_Deviation (REAL)

标准偏差,方差的平方根

例如

POU头

所有用于编程此函数的输入和输出变量已在POU头中声明。所有编程语言使用相同的POU头。

	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本体

当变量bStart设置为TRUE时,执行此函数。

LD本体

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本体

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

最后更新日期: 2024-04-26此页面上的反馈松下热线