> For the complete documentation index, see [llms.txt](https://support.powerio.com/hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/damping/averagetime.md).

# AverageTime

## `AverageTime` (FB)

FUNCTION\_BLOCK AverageTime

### Short description

> Average value calculation of an analog value over four different time periods\
> Average value calculation: Arithmetic mean\
> Typical application: Time averaging of the outdoor temperature

### Representation

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-438238997fe7f042af621962bccb83e95f7d7c7d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name  | Data type | Value range | Initial value | Function     |
| ----- | --------- | ----------- | ------------- | ------------ |
| *rIn* | REAL      |             |               | Analog input |

#### Outputs

| Name             | Data type       | Value range | Initial value | Function                                |
| ---------------- | --------------- | ----------- | ------------- | --------------------------------------- |
| *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 measured values    |
| *rOutMax*        | REAL            |             |               | Maximum value of all measured values    |
| *dtLastNewValue* | DATE\_AND\_TIME |             |               | Storage time of the last measured value |
| *sErr*           | STRING          |             |               | Current error text                      |

#### Setpoints / Parameters

| Name                  | Data type | Value range | Initial value    | Function                                                                                                             |
| --------------------- | --------- | ----------- | ---------------- | -------------------------------------------------------------------------------------------------------------------- |
| **xCalculation**      | BOOL      |             | TRUE             | Enable / disable data logging                                                                                        |
| **xResetOnInput**     | BOOL      |             | FALSE            | Initialization of the measured value storage and the average value outputs with *rIn*                                |
| **rInitValue**        | REAL      |             | 10               | Initialization value for the measured value storage and the average value outputs at **eInitial** = eInit2.InitValue |
| **tInitDelay**        | TIME      |             | 10s              | Delay time for storing measured values at **eInitial** = eInit2.InputValueDelayed                                    |
| **eInitial**          | eInit2    |             | eInit2.LastValue | Specification of the type of initialization                                                                          |
| **wCH3Time**          | WORD      |             | 72               | Specification of period 4                                                                                            |
| **wCH2Time**          | WORD      |             | 48               | Specification of period 3                                                                                            |
| **wCH1Time**          | WORD      | 1           | 36               | Specification of period 2                                                                                            |
| **wCH0Time**          | WORD      |             | 12               | Specification of period 1                                                                                            |
| **eTimeBaseCh0to3**   | eTime     |             | eTime.Hour       | Specification of the time unit for the periods                                                                       |
| **wInterval**         | WORD      |             | 30               | Specification of the logging interval                                                                                |
| **rTimeBaseInterval** | eTime     |             | eTime.Minute     | Specification of the time unit for the logging interval                                                              |

### Functional description

#### General

Measured value memory\
\
The value at the analog input *rIn* is stored in the measured value memory (storage depth = 221 entries) at the logging interval.\
The logging interval is defined by the time value **wInterval** and the time unit **rTimeBaseInterval** are specified.\
Default setting: Logging 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** are specified.\
These periods are reduced to the maximum possible size if an overflow of the storage depth threatens.\
If an overflow occurs, a corresponding error text is generated at output *sErr* generated.\
\
The correct arithmetic mean values are available at the average value outputs for the first time after the respective periods.\
Default setting: 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 **wCHXTime** of the corresponding entries in the measured value memory is available for the first time after the duration.

#### Minimum value output *rOutMin*

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 logging interval.

#### Maximum value output *rOutMax*

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 logging interval.

#### Time stamp *dtLastNewValue*

At the time stamp output *dtLastNewValue* the timestamp of the last storage operation in the measured value memory is available for the first time after a logging interval.

#### Error text *sErr*

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

#### Type of initialization **eInitial**

This setpoint / parameter determines the type of initialization of the measured value memory and the average value outputs. The following options are possible:

| Type                     | Value of initialization                                      | Note                     |
| ------------------------ | ------------------------------------------------------------ | ------------------------ |
| eInit2.InitValue         | *rInitValue*                                                 | Adjustable initial value |
| Input value              | *rIn*                                                        | eInit2.InputValue        |
| eInit2.InputValueDelayed | *rIn*                                                        | Delayed input value      |
| eInit2.LastValue         | Average - measured value memory (measured value memory full) | Last value               |
| eInit2.LastValue         | *rIn* (measured value memory empty)                          | eInit2.InputValue        |

#### Enable / disable data logging **xCalculation**

This setpoint / parameter enables data logging (= TRUE) or disables it (= FALSE)

#### Reset of the measured value memory / the average value outputs **xResetOnInput**

With this setpoint / parameter, the measured value memory / the average value outputs are reset to the value 'rIn' (= TRUE).

### CODESYS

InOut:

| Scope       | Name                | Type     | Initial          |
| ----------- | ------------------- | -------- | ---------------- |
| 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` |                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/damping/averagetime.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
