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

# Control2P

## `Control2P` (FB)

FUNCTION\_BLOCK Control2P

### Short description

> Two-point controller with actual value / setpoint / enable and adjustable switching hysteresis\
> The control action (inverted / direct) can also be adjusted.

### Representation

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-965699e0250c1ca3babf5e6b65bc16663db34593%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      |             |               | <p>\* <strong>FALSE:</strong><br>Controller locked<br>\* <strong>TRUE:</strong><br>Controller enabled</p> |

#### Outputs

| Name     | Data type | Value range | Initial value | Function                                               |
| -------- | --------- | ----------- | ------------- | ------------------------------------------------------ |
| *xY*     | BOOL      |             |               | Digital output signal                                  |
| *rDiff*  | REAL      |             |               | Control deviation (*rX* - *rW*)                        |
| *rOnAt*  | REAL      |             |               | Absolute switch-on point (*rW* + **rSwitchOnPoint**)   |
| *rOffAt* | REAL      |             |               | Absolute switch-off point (*rW* + **rSwitchOffPoint**) |

#### Setpoints / Parameters

| Name                | Data type    | Value range | Initial value         | Function                                                                     |
| ------------------- | ------------ | ----------- | --------------------- | ---------------------------------------------------------------------------- |
| **rSwitchOffPoint** | REAL         |             | 0.5                   | Switch-off point relative to the setpoint *rW*                               |
| **rSwitchOnPoint**  | REAL         |             | -0.5                  | Switch-on point relative to the setpoint *rW*                                |
| **xOffCondition**   | BOOL         |             | FALSE                 | State of the output *xY* at *xEn* = 0                                        |
| **xInitValue**      | BOOL         |             | FALSE                 | State of the output *xY* after a restart                                     |
| **eAction**         | eControlMode |             | eControlMode.Inverted | Direction of action of the controller (Inverted = heating, Direct = cooling) |
| **eManModeB**       | eManBin      |             | eManBin.Auto          | Operating mode for the digital output signal *xY*                            |

### Functional description

#### Enable input *xEn*

| *xEn* | Control process | *xY*                                                | *rDiff* | *rOnAt* | *rOffAt* | Notes           |
| ----- | --------------- | --------------------------------------------------- | ------- | ------- | -------- | --------------- |
| TRUE  | TRUE            | X                                                   | X       | x       | x        | Control enable  |
| FALSE | FALSE           | **xOffCondition** (if **eManModeB** = eManBin.Auto) | X       | x       | x        | Control lockout |

Legend: X = any

#### Digital output *xY*

The digital output *xY* is influenced by the enable input *xEn*, the control process and the manual override module.

| Control process | *xEn* | **eManModeB**  | *xY*              | Notes                                    |
| --------------- | ----- | -------------- | ----------------- | ---------------------------------------- |
| FALSE           | TRUE  | eManBin.Auto   | FALSE             | Automatic mode - Control process = FALSE |
| TRUE            | TRUE  | eManBin.Auto   | TRUE              | Automatic mode - Control process = TRUE  |
| X               | FALSE | eManBin.Auto   | **xOffCondition** | Automatic mode without enable            |
| X               | X     | eManBin.ManOff | FALSE             | Manual mode - Off                        |
| X               | X     | eManBin.ManOn  | TRUE              | Manual mode - On                         |

Legend: X = any

#### Control process

The controller can be operated in two different operating modes (**eAction** = eControlMode.Inverted or **eAction** = eControlMode.Direct).\
The following rules apply:

| **eAction**           | Rule                                     |
| --------------------- | ---------------------------------------- |
| eControlMode.Inverted | **rSwitchOnPoint** < **rSwitchOffPoint** |
| eControlMode.Direct   | **rSwitchOnPoint** > **rSwitchOffPoint** |

If, in operating mode eControlMode.Inverted, the **rSwitchOffPoint** the **rSwitchOnPoint**, then the **rSwitchOffPoint** compared to the **rSwitchOnPoint** is increased by 0.1.\
If, in operating mode eControlMode.Inverted, the **rSwitchOnPoint** the **rSwitchOffPoint**, then the **rSwitchOffPoint** compared to the **rSwitchOnPoint** is reduced by 0.1.\
\
The output values *rDiff* (*rX* - *rW*), absolute switch-on point *rOnAt* (*rW* + **rSwitchOnPoint**) and absolute switch-off point *rOffAt* (*rW* + **rSwitchOffPoint**) are available independently of the enable input *xEn* at all times.

| *xEn* | **eAction**           | *rDiff*               | *xY*  | Notes                         |
| ----- | --------------------- | --------------------- | ----- | ----------------------------- |
| TRUE  | eControlMode.Inverted | < **rSwitchOnPoint**  | TRUE  | Automatic mode - Inverted On  |
| TRUE  | eControlMode.Inverted | > **rSwitchOffPoint** | FALSE | Automatic mode - Inverted Off |
| TRUE  | eControlMode.Direct   | > **rSwitchOnPoint**  | TRUE  | Automatic mode - Direct On    |
| TRUE  | eControlMode.Direct   | < **rSwitchOffPoint** | FALSE | Automatic mode - Direct Off   |

Legend: X = arbitrary\
In summary, the control process can alternatively be described as follows:

| *xEn* | **eAction**           | *rX*         | *xY*  | Notes                         |
| ----- | --------------------- | ------------ | ----- | ----------------------------- |
| TRUE  | eControlMode.Inverted | < **rOnAt**  | TRUE  | Automatic mode - Inverted On  |
| TRUE  | eControlMode.Inverted | > **rOffAt** | FALSE | Automatic mode - Inverted Off |
| TRUE  | eControlMode.Direct   | > **rOnAt**  | TRUE  | Automatic mode - Direct On    |
| TRUE  | eControlMode.Direct   | < **rOffAt** | FALSE | Automatic mode - Direct Off   |

Legend: X = any

### CODESYS

InOut:

| Scope       | Name              | Type         | Initial               |
| ----------- | ----------------- | ------------ | --------------------- |
| Input       | `rX`              | `REAL`       |                       |
| Input       | `rW`              | `REAL`       |                       |
| Input       | `xEn`             | `BOOL`       |                       |
| Input Const | `rSwitchOffPoint` | `REAL`       | 0.5                   |
| Input Const | `rSwitchOnPoint`  | `REAL`       | -0.5                  |
| Input Const | `xOffCondition`   | `BOOL`       | FALSE                 |
| Input Const | `xInitValue`      | `BOOL`       | FALSE                 |
| Input Const | `eAction`         | eControlMode | eControlMode.Inverted |
| Input Const | `eManModeB`       | eManBin      | eManBin.Auto          |
| Output      | `xY`              | `BOOL`       |                       |
| Output      | `rDiff`           | `REAL`       |                       |
| Output      | `rOnAt`           | `REAL`       |                       |
| Output      | `rOffAt`          | `REAL`       |                       |


---

# 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/control2p.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.
