> 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/numeric/averagech.md).

# AverageCh

## `AverageCh` (FB)

FUNCTION\_BLOCK AverageCh

### Short description

> Calculation of an average from up to six weighted numerical input values\
> Typical application: Calculation of an average room temperature from various sensors

### Representation

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

### Interfaces

#### Inputs

| Name   | Data type | Value range | Initial value | Function                    |
| ------ | --------- | ----------- | ------------- | --------------------------- |
| *rIn1* | REAL      |             |               | Analog value input 1        |
| *rIn2* | REAL      |             |               | Analog value input 2        |
| *rIn3* | REAL      |             |               | Analog value input 3        |
| *rIn4* | REAL      |             |               | Analog value input 4        |
| *rIn5* | REAL      |             |               | Analog value input 5        |
| *rIn6* | REAL      |             |               | Analog value input 6        |
| *xEn1* | BOOL      |             |               | Enable analog value input 1 |
| *xEn2* | BOOL      |             |               | Enable analog value input 2 |
| *xEn3* | BOOL      |             |               | Enable analog value input 3 |
| *xEn4* | BOOL      |             |               | Enable analog value input 4 |
| *xEn5* | BOOL      |             |               | Enable analog value input 5 |
| *xEn6* | BOOL      |             |               | Enable analog value input 6 |

#### Outputs

| Name   | Data type | Value range | Initial value | Function         |
| ------ | --------- | ----------- | ------------- | ---------------- |
| *rOut* | REAL      |             |               | Average          |
| *xErr* | BOOL      |             |               | Collective fault |

#### Setpoints / Parameters

| Name          | Data type | Value range | Initial value | Function                         |
| ------------- | --------- | ----------- | ------------- | -------------------------------- |
| **iLoading6** | INT       |             | 10            | Weighting - analog value input 6 |
| **iLoading5** | INT       |             | 10            | Weighting - analog value input 5 |
| **iLoading4** | INT       |             | 10            | Weighting - analog value input 4 |
| **iLoading3** | INT       |             | 10            | Weighting - analog value input 3 |
| **iLoading2** | INT       |             | 10            | Weighting - analog value input 2 |
| **iLoading1** | INT       |             | 10            | Weighting - analog value input 1 |

### Functional description

#### Average *rOut*

The average is calculated by multiplying the analog value inputs ***rInX*** with their individual weighting **iLoadingX** and then adding up all products (numerator).\
The sum of the weightings is formed by adding the individual weightings (= divisor).\
The resulting quotient is finally available as the average ***rOut*** available.\
\
The individual weighting of an analog value input X always has the value 0.0 as long as the enable of analog value input X *xEnX* is disabled (= FALSE).\
If the sum of the weightings (divisor) = zero, then at the output ***rOut*** the value 0.0 is output constantly.\
\
Legend: X = 1 to 6

#### Collective fault *xErr*

The collective fault is active (= TRUE) if at least one of the analog value inputs *rInX* is disabled (*xEnX* = FALSE).\
In all other cases, the collective fault is not active (= FALSE).

### CODESYS

InOut:

| Scope       | Name        | Type   | Initial |
| ----------- | ----------- | ------ | ------- |
| Input       | `rIn1`      | `REAL` |         |
| Input       | `rIn2`      | `REAL` |         |
| Input       | `rIn3`      | `REAL` |         |
| Input       | `rIn4`      | `REAL` |         |
| Input       | `rIn5`      | `REAL` |         |
| Input       | `rIn6`      | `REAL` |         |
| Input       | `xEn1`      | `BOOL` |         |
| Input       | `xEn2`      | `BOOL` |         |
| Input       | `xEn3`      | `BOOL` |         |
| Input       | `xEn4`      | `BOOL` |         |
| Input       | `xEn5`      | `BOOL` |         |
| Input       | `xEn6`      | `BOOL` |         |
| Input Const | `iLoading6` | `INT`  | 10      |
| Input Const | `iLoading5` | `INT`  | 10      |
| Input Const | `iLoading4` | `INT`  | 10      |
| Input Const | `iLoading3` | `INT`  | 10      |
| Input Const | `iLoading2` | `INT`  | 10      |
| Input Const | `iLoading1` | `INT`  | 10      |
| Output      | `rOut`      | `REAL` |         |
| Output      | `xErr`      | `BOOL` |         |


---

# 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/numeric/averagech.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.
