AverageTime (FB)

FUNCTION_BLOCK AverageTime

Short Description

Averaging of an analog value over four different time periods
Averaging: Arithmetic mean value
Typical application: Averaging over time of the outside temperature

Portrayal

../_images/AverageTime_FB.png

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   10s

Delay time for saving measured values with eInitial = eInit2. InputValueDelayed.

eInitial eInit2   eInit2.LastValue

Definition of the type of initialization

wCH3Time WORD   72

Definition of the time period 4

wCH2Time WORD   48

Definition of the time period 3

wCH1Time WORD 1 36

Definition of the time period 2

wCH0Time WORD   12

Definition of the time period 1

rTimeBaseCh0to3 eTime   eTime.Hour

Determination of the time unit for the periods

wInterval WORD   30

Setting the recording interval

rTimeBaseInterval eTime   eTime.Minute

Defining the time unit for the recording interval

Functional description

General

rIn (measured value memory empty)

The value at the analog value input rIn is stored at a recording interval in a measured value memory (memory depth = 221 entries).
The recording interval is defined by the time value wInterval and the time unit rTimeBaseInterval.
Default setting: Recording interval = 30 minutes


Time periods 0... 3 (X = 0... 3)

Each of the four time periods is defined by the respective time value wCHXTime and the time unit rTimeBaseCh0to3.
If necessary, these periods are reduced to the maximum possible size if there is a risk of the storage depth being exceeded.
If the value is exceeded, a corresponding error text is generated at the output sErr.

The correct arithmetic mean values are available at the average value outputs for the first time after the respective periods.
Default value: period 0 = 12 hours, period 1 = 36 hours, period 3 = 48 hours, period 4 = 72 hours

rOutCHX Average value outputs ( X = 0 ... 3 )

At the average value output rOutCHX (X = 0... 3) the correct arithmetic mean value of the corresponding entries in the measured value memory is available for
the first time after the time period wCHXTime.

rOutMin minimum value output

At the minimum value output rOutMin, the absolute minimum value of all entries in the measured value memory is available for the first time after a recording interval.
recording interval.

rOutMax maximum value output

At the maximum value output rOutMax, the absolute maximum value of all entries in the measured value memory is available for the first time after a recording interval.
recording interval.

dtLastNewValue time stamp

At the timestamp output dtLastNewValue, the timestamp of the last storage in the measured value memory is displayed for the first time after a recording interval.
recording interval.

sErr error text

At the sErr output for the current error text, a descriptive text is available in case of error. If there is no error, an empty string is the output.

eInitial type of initialisation

This set-point / parameter will define the type of initialisation of the measured value memory and the average value outputs.

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

This data recording is enabled (= TRUE) or disabled (= FALSE) with this set-point / parameter

**xResetOnInput**reset of the measured value memory / the average value outputs

With this set-point / parameter, the measured value memory / the average value outputs are reset to the ‘rIn’ value (= TRUE).

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 10.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 eInit2 = eInit2. InitValue.

tInitDelay TIME TIME#10s0ms

Delay time for saving measured values with eInit2 = eInit2. InputValueDelayed.

eInitial eInit2 eInit2.LastValue  
wCH3Time WORD 72

Definition of the time period 4 in hours

wCH2Time WORD 48

Definition of the time period 3 in hours

wCH1Time WORD 36

Definition of the time period 2 in hours

wCH0Time WORD 24

Definition of the time period 1 in hours

eTimeBaseCh0to3 eTime eTime.Hour

Time unit for CH 0 to 3

wInterval WORD 30

memory interval

eTimeBaseInterval eTime eTime.Minute

Time unit for memory interval

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