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

# TwoPoint

## `TwoPoint` (FB)

FUNCTION\_BLOCK TwoPoint

### Short description

> Linear conversion of a numeric input value by a characteristic curve defined by two points.

### Representation

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

### Interfaces

#### Inputs

| Name     | Data type | Value range | Initial value | Function     |
| -------- | --------- | ----------- | ------------- | ------------ |
| *rIn\_X* | REAL      |             | 0             | Analog input |

#### Outputs

| Name      | Data type | Value range | Initial value | Function                                                                                                                       |
| --------- | --------- | ----------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| *rOut\_Y* | REAL      |             |               | Analog value output                                                                                                            |
| *xErr*    | BOOL      |             |               | <p>\* <strong>FALSE:</strong><br>Conversion error-free<br>\* <strong>TRUE:</strong><br>Error during the conversion process</p> |

#### Setpoints / Parameters

| Name              | Data type | Value range | Initial value | Function                                                        |
| ----------------- | --------- | ----------- | ------------- | --------------------------------------------------------------- |
| **iMinMaxOffset** | INTEGER   |             | 0             | Values of the limits at the analog value output *rOut\_Y*       |
| **xMinMaxLimit**  | BOOL      |             | FALSE         | Enable / disable the limit at the analog value output *rOut\_Y* |
| **rY2**           | REAL      |             | 100           | Point 2 of the output characteristic curve                      |
| **rX2**           | REAL      |             | 100           | Point 2 of the input range                                      |
| **rY1**           | REAL      |             | 0             | Point 1 of the output characteristic curve                      |
| **rX1**           | REAL      |             | 0             | Point 1 of the input range                                      |

### Functional description

#### Analog value output *rOut\_Y*

The analog value output *rOut\_Y* is calculated from the analog value input *rIn\_X* depending on the linear characteristic defined by the two points P1(**rX1**/**rY1**) and P2(**rX2**/**rY2**) is calculated.\
In the event of a conversion error ( *xErr* = TRUE ) the analog value output remains *rOut\_Y* unchanged.

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

{% hint style="info" %}
**Formula**

rOut\_Y = (((rX1-rIn\_X)\*(rY2-rY1))/(rX1-rX2))+rY1

**Restrictions**

The analog value output *rOut\_Y* is of data type REAL. Through an unsuitable selection of the parameters **rX1**, **rX2**, **rY1** and **rY2** as well as the value of the analog value input *rIn\_X* the data type limits may be exceeded.
{% endhint %}

#### Enable / disable the limits **xMinMaxLimit**

The limits of the analog value output *rOut\_Y* can generally be enabled and disabled with this setpoint / parameter.

| **xMinMaxLimit** | Limits            | Notes                                             |
| ---------------- | ----------------- | ------------------------------------------------- |
| FALSE            | none              | *rOut\_Y* without absolute limits                 |
| TRUE             | Y\_min and Y\_max | Limiting the analog value output *rOut\_Y* active |

#### Values of the limits **iMinMaxOffset**

The limits of the analog value output are only active if the setpoint / parameter **xMinMaxLimit** is active (= TRUE).\
The limit values Y\_min and Y\_max are then calculated as follows:

{% hint style="info" %}
**Formulas:**

Y\_min = rY1 - ((ABS(rY2-rY1))\*iMinMaxOffset)/100\
Y\_max = rY2 + ((ABS(rY2-rY1))\*iMinMaxOffset)/100\\
{% endhint %}

| *rY1* | *rY2* | *rY2* - *rY1* | **iMinMaxOffset** | *Y\_min* | *Y\_max* | Notes           |
| ----- | ----- | ------------- | ----------------- | -------- | -------- | --------------- |
| 0     | 100   | 100           | 0                 | 0        | 100      | Standard limits |
| 0     | 100   | 100           | 10                | -10      | 110      | Positive offset |
| 0     | 100   | 100           | -10               | 10       | 90       | Negative offset |

#### Digital output *xErr*

The digital output *xErr* signals an error during the conversion process. The following errors are considered:

* *rX1* AND *rX2* = 0
* *rX1* = *rX2*
* *rY1* AND *rY2* = 0
* *rY1* = *rY2*

| Error during the conversion process | *xErr* | Notes                               |
| ----------------------------------- | ------ | ----------------------------------- |
| FALSE                               | FALSE  | Conversion error-free               |
| TRUE                                | TRUE   | Error during the conversion process |

Legend: X = any

### CODESYS

InOut:

| Scope       | Name            | Type   | Initial |
| ----------- | --------------- | ------ | ------- |
| Input       | `rIn_X`         | `REAL` | 0       |
| Output      | `rOut_Y`        | `REAL` |         |
| Output      | `xErr`          | `BOOL` |         |
| Input Const | `iMinMaxOffset` | `INT`  | 0       |
| Input Const | `xMinMaxLimit`  | `BOOL` | FALSE   |
| Input Const | `rY2`           | `REAL` | 100     |
| Input Const | `rX2`           | `REAL` | 100     |
| Input Const | `rY1`           | `REAL` | 0       |
| Input Const | `rX1`           | `REAL` | 0       |


---

# 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/numeric/twopoint.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.
