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

# ControlP

## `ControlP` (FB)

FUNCTION\_BLOCK ControlP

### Short description

> Proportional-acting controller (P-controller)\
> The direction of action (inverted / direct) is also adjustable.\
> Typical application: control loops with actuators that have an integrating/storage character.

### Representation

<figure><img src="/files/c049807cab44cf84e3a7f69849acc9019cf82140" 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 |

#### Outputs

| Name           | Data type | Value range | Initial value | Function                 |
| -------------- | --------- | ----------- | ------------- | ------------------------ |
| *rY*           | REAL      |             | 0.0           | Controller output signal |
| *rDiff*        | REAL      |             |               | Control deviation        |
| *xLimitActive* | BOOL      |             |               | Status - limit exceeded  |

#### Setpoints / parameters

| Name           | Data type    | Value range | Initial value         | Function                                                 |
| -------------- | ------------ | ----------- | --------------------- | -------------------------------------------------------- |
| **rMax**       | REAL         |             | 100.0                 | Upper absolute limit of the output signal                |
| **rMin**       | REAL         |             | -100.0                | Lower absolute limit of the output signal                |
| **rKp**        | REAL         | 0.0 …       | 2.0                   | Gain factor                                              |
| **rOffset**    | REAL         |             | 0.0                   | Offset                                                   |
| **rYDisabled** | REAL         |             | 0.0                   | Disabled value                                           |
| **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-acting controller (P-controller).\
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) is calculated as follows:\
\
\
\&#xNAN;*rY* = **rKp** \* ((measured value + offset) - (setpoint))\
\
\
Depending on the controller's direction of action **eAction** the measured and set values are determined as follows:

| **eAction**           | measured value | setpoint | Formula                                           | Function                       |
| --------------------- | -------------- | -------- | ------------------------------------------------- | ------------------------------ |
| eControlMode.Inverted | *rW*           | *rX*     | *rY* = **rKp** \* ((*rW* + **rOffset**) - (*rX*)) | Direction of action - Inverted |
| eControlMode.Direct   | *rX*           | *rW*     | *rY* = **rKp** \* ((*rX* + **rOffset**) - (*rW*)) | Direction of action - Direct   |

#### 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.\
\
With the enable input 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.

#### Control deviation *rDiff*

The control deviation is calculated according to the following formula and passed to the output *rDiff* .\
\
\&#xNAN;*rDiff* = measured value - setpoint

#### 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 exceedance exists.\
The status of the limit exceedance is not set (*xLimitActive* = FALSE) if no limit exceedance exists.\
\
A limit exceedance exists 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 setpoint / parameter **rManValue** is overwritten with the current value of the output signal at every transition into automatic mode *rY* .

| **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 Const | `rYMax`       | `REAL`       | 100                   |
| Input Const | `rYMin`       | `REAL`       | -100                  |
| Input Const | `rKp`         | `REAL`       | 2                     |
| Input Const | `rOffset`     | `REAL`       | 0                     |
| Input Const | `rYDisabled`  | `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      | `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/controlp.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.
