The STEP 7 (TIA Portal) V11 program "STEP7_V11_Totalizer" includes the "Totalizer" function block which you can use to add up values measured within a time unit to a total value. For example, for using units of measurement for linear velocity or for volumetric magnitudes. You can use distances or volumes as physical magnitudes and milliseconds, seconds, minutes, hours or days as units of time measurement.
Table 01 below includes a list of the input and output variables of the "Totalizer" function.
||Measured value in a time interval|
||Time interval of the measurement|
||Reset of the "Total" output|
||Accumulated total output value|
In a cycle
- The values of the input variables "Interval" and "Cycle" of the data type Time are converted into the data type Real.
- The converted values are then transferred to the temporary variables "Interval_real" and "Cycle_real".
- The input value of the variable "VALUE" is multiplied by the value of the temporary variable "Cycle_real" and then divided by the value of the temporary variable "Interval_real".
- The result is then stored in the buffer of the static variable "Accum".
Thus after each cycle the interim result in the "Accum" buffer is incremented by this value, which is also transferred to the output variable "Total". If the "Reset" variable has the value "True", the output value of the "Total" variable is reset to zero.
In the example as in Fig. 01 the "Value" variable has the value 60.0 and the time value of the "Interval" variable is one minute.
- The output variable "Total" is then added up to the values 1 to 60 within the interval, that is to say within one minute.
- The cycle time of 100ms reflects the scan time in which the FB "Totalizer" is processed.
- When the FB is called in the "Cyclic interrupt", the program is processed in a time interval of 100ms and is independent of OB1 (main).
The associated physical units of the measured value "Value" can be, for example, meters per second, cubic meters per minute or kilograms per hour. For the input variable "Interval" you must enter the interval time for the physical unit, for example,
- Meters per second: T#1s
- Cubic meters per minute: T#1M
- Kilograms per hour: T#1h
The attached download "STEP7_V11_Totalizer.zip" contains a STEP 7 project with the blocks described above (FB "Totalizer" with instance DB and call in the "Cyclic interrupt" OB). The program contains German and English comments.
Copy the "STEP7_V11_Totalizer.zip" file into a separate directory and then start the file with a double-click. The STEP 7 project is now unpacked automatically with all the associated subdirectories. You can then use STEP 7 V11 to open and process the extracted project.
STEP7_V11_Totalizer.zip ( 9206 KB )
The screens and download in this FAQ response were created with STEP 7 (TIA Portal) V11 SP2.