Using FB_FlowEstimation

Overview

A use case for the function block FB_FlowEstimation is the estimation of a flow of products on a conveyor.

The method used to generate the products in the application is not relevant for the flow estimation. For example, it could be a vision system sending information to the controller or a software trigger generated in the program, based on a time period.

From a flow estimation point of view, it is important that every time a new product is detected, the Notify method of FB_FlowEstimation is also called to signal it to the function block.

How to Use the Function Block

The table includes the main steps required to use the function block:

Step

Action

1

Define an instance of the function block:


VAR 
  fbFlowEstimation : SERT.FB_FlowEstimation;
END_VAR

2

Set the desired time period that will be used for the estimation; the value must be strictly positive. In this case, the time period is set to 1000 ms.


fbFlowEstimation.SetTimePeriod(
   i_timValue:= T#1000MS, 
   q_etDiag => etDiag,
   q_etDiagExt => q_etDiagExt,
   q_sMsg => sMsg
);

This must be done at least once before calling an Update.

3

At runtime, the Update method must be called at every cycle to keep the estimation updated.


fbFlowEstimation.Update(
   q_etDiag => etDiag,
   q_etDiagExt => q_etDiagExt,
   q_sMsg => sMsg
);

The first time, Update is called after the initialization of the function block or after the call of the Reset method, the internal timer starts to count.

4

At runtime, the Notify method must be called each time a new product is detected. The input i_udiNumberOfObjects specifies how many objects must be notified.


//on the detection of a new product
fbFlowEstimation.Notify(
   i_udiNumberOfObjects := 1,
   q_etDiag => etDiag,
   q_etDiagExt => q_etDiagExt,
   q_sMsg => sMsg
);

5

The estimated flow value is available in the property lrAverageFlowPerMinute. This value is based on the number of already evaluated time periods, described by udiNumberOfTimePeriods.