AverageTimeCal (FB)¶
FUNCTION_BLOCK AverageTimeCal
Short Description¶
Averaging of an analog value over four different time periodsMean value formation: Weighted mean value (see formula below)Typical application: Averaging over time of the outside temperature
Portrayal¶
Interfaces¶
Inputs¶
Name Datatype
Range
Init-Value
Function
rIn REAL Analog value input
Outputs¶
Name Datatype
Range
Init-Value
Function
rOutCH0 REAL Average value for time period 1
rOutCH1 REAL Average value for time period 2
rOutCH2 REAL Average value for time period 3
rOutCH3 REAL Average value for time period 4
rOutMin REAL Minimum value of all measured values
rOutMax REAL Maximum value of all measured values
dtLastNewValue DATE_AND_TIME Save time of the last measured value
sErr STRING Current error text
Setpoints / Parameters¶
Name Datatype
Range
Init-Value
Function
xCalculation BOOL TRUE Enable / disable data recording
xResetOnInput BOOL FALSE Initialization of the measured value memory and the average value outputs with rIn.
rInitValue REAL 10 Initialization value for the measured value memory and the average value outputs with eInitial = eInit2. InitValue.
tInitDelay TIME 5s Delay time for saving measured values with eInitial = eInit2. InputValueDelayed.
eInitial eInit2 eInit2.LastValue Definition of the type of initialization
wCH3Time WORD 48 Definition of the time period 4 in hours
wCH2Time WORD 36 Definition of the time period 3 in hours
wCH1Time WORD 24 Definition of the time period 2 in hours
wCH0Time WORD 12 Definition of the time period 1 in hours
wInterval WORD 15 Setting the recording interval in minutes
Functional description¶
General¶
Example
rOutCHX Average value outputs ( X = 0 ... 3 )¶
rOutMin minimum value output¶
rOutMax maximum value output¶
dtLastNewValue time stamp¶
sErr error text¶
eInitial type of initialisation¶
Type
Initialization value
Notes
eInit2.InitValue rInitValue Configurable initial value
eInit2.InputValue rIn Input value
eInit2.InputValueDelayed rIn Delayed input value
eInit2.LastValue Average - measured value memory (measured value memory filled)
Last Value
eInit2.LastValue rIn (measured value memory empty)
Last Value
Enable / disable data recording xCalculation¶
Visualization¶
Information¶
Element Authors
Date
Version Note
Function
Adam Bartod 06.2016 1.0 Initial version
Programming
Adam Bartod 06.2016 1.0 Initial version
Test 12.2016 1.0 Initial version
Documentation
Jochen Reu 11.2017 1.0 Initial version
Codesys¶
- InOut:
Scope Name Type Initial Comment Input rIn REAL Analog value input
xCalculation BOOL TRUE Enable / disable data recording
xResetOnInput BOOL FALSE Initialization of the measured value memory and the average value outputs with rIn.
rInitValue REAL 10 Initialization value for the measured value memory and the average value outputs with eInitial = eInit2. InitValue.
tInitDelay TIME TIME#5s0ms Delay time for saving measured values with eInitial = eInit2. InputValueDelayed.
eInitial eInit2 eInit2.LastValue Definition of the type of initialization
wCH3Time WORD 48 Definition of the time period 4 in hours
wCH2Time WORD 36 Definition of the time period 3 in hours
wCH1Time WORD 24 Definition of the time period 2 in hours
wCH0Time WORD 12 Definition of the time period 1 in hours
wInterval WORD 15 Setting the recording interval in minutes
Output rOutCH0 REAL Average value for time period 1
rOutCH1 REAL Average value for time period 2
rOutCH2 REAL Average value for time period 3
rOutCH3 REAL Average value for time period 4
rOutMin REAL Minimum value of all measured values
rOutMax REAL Maximum value of all measured values
dtLastNewValue DT Save time of the last measured value
sErr STRING Current error text