# AverageCh

## `AverageCh` (FB)

FUNCTION\_BLOCK AverageCh

### Short description

> Formation of an average from up to six weighted numerical input values\
> Typical application: formation of a room temperature average from different sensors

### Representation

<figure><img src="/files/9d2f54bb9e10a7e0aafb7c79ac9af2a14082b73e" 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      |             |               | Aggregate 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 |

### Function description

#### Average *rOut*

The average is formed by multiplying the analog value inputs ***rInX*** by their individual weighting **iLoadingX** and then summing all products (dividend).\
The sum of the weightings is formed by adding the individual weightings (= divisor).\
The quotient obtained in this way 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 for analog value input X *xEnX* is locked (= FALSE).\
If the sum of the weightings (divisor) = zero, then the output ***rOut*** constantly outputs the value 0.0.\
\
Legend: X = 1 to 6

#### Aggregate fault *xErr*

The collective fault is active (= TRUE) if at least one of the analog value inputs *rInX* is locked (*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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/numeric/averagech.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
