LGF_Integration (FB / V3.0.2)

Overview

Author: Siemens Digital Industries

Short description

The function approximately calculates the area under a function curve. The function curve is transferred as an analog value (LReal) which varies over time. The integral value is output on integral.
The implementation is based on the trapezoidal rule and uses [ms] as time base.

Block Interface

LGF_Integration (FB)
Bool  enable integral  LReal
    
LReal  value error  Bool
    
Bool  reset status  Word
    
   subfunctionStatus  Word
    
   

Input parameter

IdentifierData type Default value Description
enableBool FALSE Enables integral calculation
If this input is set to the value `FALSE`, the integral calculation is stopped and the `integral` output shows the last calculated value.
valueLReal 0.0 Analog value of the continuous function curve, based on [ms], (e.g. [volume flow/ms])
resetBool FALSE Sets the output “integral” to “0.0”.

Output parameter

IdentifierData type Description
integralLReal Integral value
errorBool FALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord 16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)
subfunctionStatusWord Status or return value of called FB's, FC's and system blocks

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_EXECUTION_FINISHED_NO_ERROR
Status: No error in the function during execution
16#8600ERR_READ_SYS_TIME
Error: System time FC `RD_SYS_T` returned an error when excuting - check `subFunctionStatus` code

Functional description

NOTE
The status of called commands is output in subFunctionStatus. In this case, the output value in status indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.

The integral calculation includes the summation of those trapezoidal areas that span between the last two function values on the “value” input and the time. The elapsed time is calculated via the system time of the CPU. This trapezoidal area is identical to the product of the mean value of the two process values and the time interval.


NOTE
The calculation takes [ms] as time base. So the analoge value hase to use the same time base, e.g. [volume flow/ms].

A = \frac{1}{2} * (F_{t_1}+F_{t_0}) * (t_1-t_0) + \frac{1}{2} * (F_{t_2}+F_{t_1}) * (t_2-t_1) + ...

Figure: Principle of operation

LGF_Integration - Principle of operation

Start the integral calculation for the inputvalue at the parameter value:

If the parameter enable is set to the value FALSE, the integral calculation is stopped and the output integral outputs the last calculated value.
If the parameter reset is set to the value TRUE, the output integral is reset to 0.0

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
17.02.2017First released version
01.00.01Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
01.00.02Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
01.01.00Simatic Systems Support
12.11.2019Regions, comments and constants are added, code refactored
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
09.02.2021Insert documentation
03.00.02Simatic Systems Support
07.06.2021Fix bug - incompatibility with S7-1200 and LTIME