> 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 controller (P controller)\
> The action direction (inverted / direct) can also be set.\
> Typical application: control loops with actuators that have a storage characteristic.

### Representation

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

### Interfaces

#### Inputs

| Name  | Data type | Value range | Initial value | Function              |
| ----- | --------- | ----------- | ------------- | --------------------- |
| *rX*  | REAL      |             |               | Analog actual value   |
| *rW*  | REAL      |             |               | Analog setpoint value |
| *xEn* | BOOL      |             |               | Controller enable     |

#### Outputs

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

#### Setpoints / Parameters

| Name           | Data type    | Value range | Initial value         | Function                                              |
| -------------- | ------------ | ----------- | --------------------- | ----------------------------------------------------- |
| **rMax**       | REAL         |             | 100.0                 | Upper absolute limit value of the output signal       |
| **rMin**       | REAL         |             | -100.0                | Lower absolute limit value of the output signal       |
| **rKp**        | REAL         | 0.0 …       | 2.0                   | Gain factor                                           |
| **rOffset**    | REAL         |             | 0.0                   | Offset                                                |
| **rYDisabled** | REAL         |             | 0.0                   | Switch-off value                                      |
| **eAction**    | eControlMode |             | eControlMode.Inverted | Action direction of the controller (Inverted, Direct) |
| **eManModeN**  | eManNum      |             | eManNum.Auto          | Operating mode for the controller output signal       |
| **rManValue**  | REAL         |             |                       | Output signal in manual mode                          |

### Functional description

#### General

This function block contains a proportional controller (P controller).\
The controller output signal *rY* is calculated when the controller is enabled (*xEn* = TRUE) and in automatic mode of the controller (**eManModeN** = eManNum.Auto) as follows:\
\
\
*rY* = **rKp** \* ((Actual value + Offset) - (Setpoint value))\
\
\
Depending on the action direction of the controller **eAction** the actual and setpoint values are defined as follows:

| **eAction**             | Actual value | Setpoint | Formula                                           | Function                    |
| ----------------------- | ------------ | -------- | ------------------------------------------------- | --------------------------- |
| eControlMode.Invertiert | *rW*         | *rX*     | *rY* = **rKp** \* ((*rW* + **rOffset**) - (*rX*)) | Action direction - Inverted |
| eControlMode.Direct     | *rX*         | *rW*     | *rY* = **rKp** \* ((*rX* + **rOffset**) - (*rW*)) | Action direction - Direct   |

#### Enable input *xEn*

If the enable input is not active (*xEn* = FALSE) the switch-off value **rYDisabled** to the output *rY* is transferred (prerequisite: **eManModeN** = eManNum.Auto) and limited by the absolute limit values.\
\
If the enable input is active (*xEn* = TRUE) the output signal is calculated according to the formula above and to the output *rY* is transferred (prerequisite: **eManModeN** = eManNum.Auto) and limited by the absolute limit values.

#### Control deviation *rDiff*

The control deviation is calculated according to the following formula and to the output *rDiff* transferred.\
\
*rDiff* = Actual value - setpoint value

#### Absolute limit values **rMin** and **rMax**

The controller output signal *rY* is limited by the absolute limit values **rMin** downward and **rMax** upward.\
The absolute limit value **rMin** is set to the current value of **rMax** - 0.1, if it is >= the current value of **rMax** is.\
The only exception is manual mode for the controller output signal (**eManModeN** = eManNum.Man).

#### Status - limit exceedance *xLimitActive*

The limit exceedance status is activated (*xLimitActive* = TRUE) if a limit exceedance is present.\
The limit exceedance status is not activated (*xLimitActive* = FALSE) if no limit exceedance is present.\
\
A limit exceedance exists if the controller output signal *rY* the upper limit value **rMax** reaches / exceeds or the lower limit value **rMin** reaches / falls below.

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

The parameter **eManModeN** allows switching the output signal *rY* from automatic mode to manual mode and vice versa.\
In manual mode, the output signal takes over *rY* the output signal in manual mode **rManValue**.\
The setpoint / parameter **rManValue** is overwritten each time the system switches to automatic mode with the current value of the output signal *rY* overwritten.

| **eManModeN** | *rY*                                           | Function                       |
| ------------- | ---------------------------------------------- | ------------------------------ |
| eManNum.Auto  | Signal according to formula / switch-off 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      | `xLimitActive` | `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/control/controlp.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.
