我用FB 做的带数据块的流量累积功能块
采样累积在毫秒单位内ms_v,满一秒转入是s_v,同时将ms、ms_v 清零,满一分钟累积量转入m_v,t 同时将s、s_v 清零,满一一小时累积量转入h_v,同时将min、m_v 清零,可以累积入天……
每一时刻的累积量是ms_v+s_v+m_v+h_v
Rest 为零累积量清零
在OB35 中调用即可,如 OB35 中断周期为 100ms,流量输入单位方/H,Unilt_c 就是36000,Hz就为 10,unilt_v 对应流量记满量程值
In pv word 瞬时流量 In Unit_c Real 瞬时流量单位转换为采样时间流量单位 In Rest int 为零时,累加器清零 In Hz int 每秒采样次数 In unilt_v Real 流量计最大流量单位 Out ov Real 流量累积输出 In_out ms int 毫秒记数 In_out s int 秒记数 In_out min int 分钟记数 In_out h int 小时记数 In_out ms_v dint 毫秒流量累积 In_out s_v dint 秒流量累积 In_out m_v dint 分钟流量累积 In_out h_v dint 小时流量累积 In_out in_v dint 将输入瞬时流量变为长整型 流量累积功能块 毫秒流量累积 L #PV T #iv_c L #iv_c L #ms_v +D T #ms_v L #ms L 1 +I T #ms L #Hz