> 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/control/controlpiext.md).

# ControlPIext

## `ControlPIext` (FB)

FUNCTION\_BLOCK ControlPIext

### Short description

> Proportional-integral acting controller (PI controller), parameters as inputs.\
> The direction of action (inverted / direct) is also adjustable.\
> Typical application: control loops with actuators that have no storing character.

### Representation

<figure><img src="/files/b7c88feda213c3c9273c2a27ff53614c7b8dfc61" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name           | Data type | Value range | Initial value | Function                                   |
| -------------- | --------- | ----------- | ------------- | ------------------------------------------ |
| *rX*           | REAL      |             |               | Analog measured value                      |
| *rW*           | REAL      |             |               | Analog setpoint                            |
| *xEn*          | BOOL      |             |               | Enable of the controller                   |
| **rYDisabled** | REAL      |             | 0.0           | Disabled value                             |
| **rInitValue** | REAL      |             | 0.0           | Initialization value for the output signal |
| **rKp**        | REAL      | 0.0 …       | 2.0           | Gain factor                                |
| **rTn**        | REAL      | 0.0 …       | 200.0         | Reset time in seconds                      |
| **rMin**       | REAL      |             | 0.0           | Lower absolute limit of the output signal  |
| **rMax**       | REAL      |             | 100.0         | Upper absolute limit of the output signal  |

#### Outputs

| Name           | Data type | Value range | Initial value | Function                               |
| -------------- | --------- | ----------- | ------------- | -------------------------------------- |
| *rY*           | REAL      |             | 0.0           | Controller output signal               |
| *rDiff*        | REAL      |             |               | Control deviation                      |
| *rPartP*       | REAL      |             |               | Proportional part of the output signal |
| *rPartI*       | REAL      |             |               | Integral part of the output signal     |
| *xLimitActive* | BOOL      |             |               | Status - limit exceeded                |

#### Setpoints / parameters

| Name          | Data type    | Value range | Initial value         | Function                                                 |
| ------------- | ------------ | ----------- | --------------------- | -------------------------------------------------------- |
| **rOffset**   | REAL         |             | 0.0                   | Offset                                                   |
| **eAction**   | eControlMode |             | eControlMode.Inverted | Direction of action of the controller (Inverted, Direct) |
| **eManModeN** | eManNum      |             | eManNum.Auto          | Operating mode for the controller output signal          |
| **rManValue** | REAL         |             |                       | Output signal in manual mode                             |

### Function description

#### General

This function block contains a proportional-integral acting controller (PI controller).\
Some parameters are defined as inputs and thus not persistent. This allows the values to be changed continuously by the program.\
The controller's output signal *rY* is calculated when the controller is enabled (*xEn* = TRUE) and in the controller's automatic operating mode (**eManModeN** = eManNum.Auto) as follows:\
\
\
Output signal: *rY* = Proportional part + Integral part\
\
\
Proportional part: Proportional part = **rKp** \* control deviation\
\
Control deviation: Control deviation = *rW* - (*rx* + **rOffset**) \[Direction of action - Inverted: **eAction** = eControlMode.Inverted]\
\
Control deviation = *rX* - (*rW* + **rOffset**) \[Direction of action - Direct: **eAction** = eControlMode.Direct]\
\
Integral part: Integral part = (Proportional part \* (sampling time / reset time)) + Integral part (t-sampling time)\
\
\
Legend: t-sampling time … time point that was one sampling time before the current time t\
Sampling time … time interval between two calls of the function block\
t … current time

> **Control / Properties - reset time rTn**
>
> It may only take values > 0.\
> **rTn** >>> Sampling time: The integral part remains constant\
> Control deviation = 0: The integral part remains constant\
> Depending on the controller's direction of action **eAction** the measured and set values are determined as follows:
>
> \
> \| \*\*eAction\*\* | Control deviation | Function | |-------------------------|-------------------------------|-----------------------| | eControlMode.Inverted | \*rW\* - ( \*rx\* + \*\*rOffset\*\* ) | Direction of action - Inverted | | eControlMode.Direct | \*rX\* - ( \*rW\* + \*\*rOffset\*\* ) | Direction of action - Direct |

#### Integral part

The integral part is limited both upwards and downwards by the following absolute limits:\
Upper limit = **rMax** - Proportional part\
Lower limit = **rMin** - Proportional part

#### Enable input *xEn*

If the enable input is not active (*xEn* = FALSE) the disabled value **rYDisabled** is transferred to the output *rY* (precondition: **eManModeN** = eManNum.Auto) and limited by the absolute limits. The integral part is set to 0.0.\
\
If the enable input is active (*xEn* = TRUE) the output signal is calculated according to the formula above and passed to the output *rY* (precondition: **eManModeN** = eManNum.Auto) and limited by the absolute limits.\
\
On each rising edge of the enable input *xEn* the control process is restarted.

#### Restart of the controller

On each rising edge of the enable input *xEn* the control process is restarted. (Preconditions: **eManModeN** = eManNum.Auto and *xEn* = TRUE)\
The integral part is set to the difference between **rInitValue** and the proportional part.

#### Control deviation *rDiff*

The control deviation corresponds to the value of the control deviation according to the above formula.

#### Proportional part of the output signal *rPartP*

This output always provides the proportional part of the output signal, see description above.

#### Integral part of the output signal *rPartI*

This output always provides the integral part of the output signal, see description above.

#### Absolute limits **rMin** and **rMax**

The controller's output signal *rY* is limited downwards by the absolute limit **rMin** and upwards by **rMax** .\
The absolute limit **rMin** is set to the current value of **rMax** - 0.1 if it is >= the current value of **rMax** .\
The only exception is manual operation for the controller output signal (**eManModeN** = eManNum.Man).

#### Status - limit exceeded *xLimitActive*

The limit-exceeded status is activated (*xLimitActive* = TRUE) if a limit is exceeded upwards or downwards (*xEn* = TRUE).\
The limit-exceeded status is not activated (*xLimitActive* = FALSE) if no limit is exceeded or the enable signal is deactivated (*xEn* = FALSE).\
\
A limit is considered exceeded if the controller's output signal *rY* reaches / exceeds the upper limit **rMax** or reaches / falls below the lower limit **rMin** .

#### Operating mode for the controller output signal **eManModeN**

The parameter **eManModeN** allows switching the output signal *rY* from automatic to manual mode and vice versa.\
In manual mode the output signal *rY* takes over the output signal in manual mode **rManValue**. The integral part is set to the difference between **rInitValue** and the proportional part.

| **eManModeN** | *rY*                                         | Function                       |
| ------------- | -------------------------------------------- | ------------------------------ |
| eManNum.Auto  | signal according to formula / disabled value | Automatic mode - output signal |
| eManNum.Man   | **rManValue**                                | Manual mode - output signal    |

### Codesys

InOut:

| Scope       | Name          | Type         | Initial               |
| ----------- | ------------- | ------------ | --------------------- |
| Input       | `rX`          | `REAL`       |                       |
| Input       | `rW`          | `REAL`       |                       |
| Input       | `xEn`         | `BOOL`       |                       |
| Input       | `rYDisabled`  | `REAL`       | 0                     |
| Input       | `rInitValue`  | `REAL`       | 0                     |
| Input       | `rKp`         | `REAL`       | 2                     |
| Input       | `rTn`         | `REAL`       | 200                   |
| Input       | `rYMin`       | `REAL`       | 0                     |
| Input       | `rYMax`       | `REAL`       | 100                   |
| Input Const | `rOffset`     | `REAL`       | 0                     |
| Input Const | `eAction`     | eControlMode | eControlMode.Inverted |
| Input Const | `eManModeN`   | eManNum      | eManNum.Auto          |
| Input Const | `rManValue`   | `REAL`       |                       |
| Output      | `rY`          | `REAL`       | 0                     |
| Output      | `rDiff`       | `REAL`       |                       |
| Output      | `rPartP`      | `REAL`       |                       |
| Output      | `rPartI`      | `REAL`       |                       |
| Output      | `xLimitAktiv` | `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 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/control/controlpiext.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.
