AverageTime
AverageTime (FB)
AverageTime (FB)FUNCTION_BLOCK AverageTime
Short description
Averaging of an analog value over four different time periods Averaging method: arithmetic mean Typical application: temporal averaging of the outside temperature\
Representation

Interfaces
Inputs
rIn
REAL
Analog value input
Outputs
rOutCH0
REAL
Average value period 1
rOutCH1
REAL
Average value period 2
rOutCH2
REAL
Average value period 3
rOutCH3
REAL
Average value period 4
rOutMin
REAL
Minimum value of all measurements
rOutMax
REAL
Maximum value of all measurements
dtLastNewValue
DATE_AND_TIME
Timestamp of the last measurement stored
sErr
STRING
Current error text
Setpoints / parameters
xCalculation
BOOL
TRUE
Enable / disable data recording
xResetOnInput
BOOL
FALSE
Initialization of the measurement storage and the average value outputs with rIn
rInitValue
REAL
10
Initialization value for the measurement storage and the average value outputs at eInitial = eInit2.InitValue
tInitDelay
TIME
10s
Delay time for measurement storage at eInitial = eInit2.InputValueDelayed
eInitial
eInit2
eInit2.LastValue
Definition of the type of initialization
wCH3Time
WORD
72
Definition of period 4
wCH2Time
WORD
48
Definition of period 3
wCH1Time
WORD
1
36
Definition of period 2
wCH0Time
WORD
12
Definition of period 1
eTimeBaseCh0to3
eTime
eTime.Hour
Definition of the time unit for the periods
wInterval
WORD
30
Definition of the recording interval
rTimeBaseInterval
eTime
eTime.Minute
Definition of the time unit for the recording interval
Function description
General
Measurement value memory The value at the analog value input rIn is stored at recording interval in a measurement memory (memory depth = 221 entries). The recording interval is determined by the time value wInterval and the time unit rTimeBaseInterval is defined. Default setting: recording interval = 30 minutes Periods 0 … 3 ( X = 0 … 3 ) Each of the four periods is defined by the respective time value wCHXTime and the time unit rTimeBaseCh0to3 is specified. These periods are reduced to the maximum possible size if exceeding the memory depth is imminent. If an overflow occurs, a corresponding error text is generated at the output sErr is produced. The correct arithmetic means for the average value outputs are available for the first time after the respective periods. Default: period 0 = 12 hours, period 1 = 36 hours, period 3 = 48 hours, period 4 = 72 hours \
Average value outputs rOutCHX ( X = 0 … 3 )
At the average value output rOutCHX ( X = 0 … 3 ) the correct arithmetic mean of the corresponding entries in the measurement memory is available for the first time after the duration wCHXTime is available.\
Minimum value output rOutMin
At the minimum value output rOutMin the absolute minimum value of all entries in the measurement memory is available for the first time after one recording interval.\
Maximum value output rOutMax
At the maximum value output rOutMax the absolute maximum value of all entries in the measurement memory is available for the first time after one recording interval.\
Timestamp dtLastNewValue
At the timestamp output dtLastNewValue the timestamp of the last storage in the measurement memory is available for the first time after one recording interval.\
Error text sErr
At the output for the current error text sErr a descriptive text is available in case of error. If there is no error, an empty string is output.\
Type of initialization eInitial
This setpoint / parameter defines the type of initialization of the measurement memory and the average value outputs. The following options are possible:\
eInit2.InitValue
rInitValue
Configurable initial value
eInit2.InputValue
rIn
Input value
eInit2.InputValueDelayed
rIn
Delayed input value
eInit2.LastValue
Average - measurement memory (measurement memory filled)
Last value
eInit2.LastValue
rIn ( measurement memory empty )
Input value
Enable / disable data recording xCalculation
This setpoint / parameter enables ( = TRUE ) or disables ( = FALSE ) data recording\
Reset of the measurement memory / the average value outputs xResetOnInput
With this setpoint / parameter the measurement memory / the average value outputs are reset to the value ‘rIn’ ( = TRUE ).
CODESYS
InOut:
Input
rIn
REAL
Input Const
xCalculation
BOOL
TRUE
Input Const
xResetOnInput
BOOL
FALSE
Input Const
rInitValue
REAL
10
Input Const
tInitDelay
TIME
TIME#10s0ms
Input Const
eInitial
eInit2
eInit2.LastValue
Input Const
wCH3Time
WORD
72
Input Const
wCH2Time
WORD
48
Input Const
wCH1Time
WORD
36
Input Const
wCH0Time
WORD
24
Input Const
eTimeBaseCh0to3
eTime
eTime.Hour
Input Const
wInterval
WORD
30
Input Const
eTimeBaseInterval
eTime
eTime.Minute
Output
rOutCH0
REAL
Output
rOutCH1
REAL
Output
rOutCH2
REAL
Output
rOutCH3
REAL
Output
rOutMin
REAL
Output
rOutMax
REAL
Output
dtLastNewValue
DT
Output
sErr
STRING
Last updated

