> 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/hvac-modbus-library/functions/twopointfun.md).

# TwoPointFun

## `TwoPointFun` (FUN)

`FUNCTION` TwoPointFun: `REAL`

### Kurzbeschreibung

> Lineare Umwandlung eines nummerischen Eingangswertes durch eine durch zwei Punkte definierte Kennlinie.
>
> Typische Anwendung: Skalierung von Prozessrohwerten

### Schnittstellen

#### Eingänge

| Name            | Datentyp | Wertebereich | Initialwert | Funktion                                                |
| --------------- | -------- | ------------ | ----------- | ------------------------------------------------------- |
| *rIn\_X*        | `REAL`   |              |             | Analogwerteingang                                       |
| *rX1*           | `REAL`   |              | 0           | Punkt 1 des Eingangsbereiches                           |
| *rY1*           | `REAL`   |              | 0           | Punkt 1 der Ausgangskennlinie                           |
| *rX2*           | `REAL`   |              | 100         | Punkt 2 des Eingangsbereiches                           |
| *rY2*           | `REAL`   |              | 100         | Punkt 2 der Ausgangskennlinie                           |
| *xMinMaxLimit*  | `BOOL`   |              |             | Freigabe / Sperrung der Begrenzung am Analogwertausgang |
| *iMinMaxOffset* | INTEGER  |              |             | Werte der Begrenzungen am Analogwertausgang             |

#### Ausgänge

| Name          | Datentyp | Wertebereich | Initialwert | Funktion                                                                                                                  |
| ------------- | -------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------- |
| *TwoPointFun* | `REAL`   |              |             | Lineare Umwandlung eines numerischen Eingangswertes                                                                       |
| *xErr*        | `BOOL`   |              |             | <p>\* <strong>FALSE:</strong><br>Umwandlung fehlerfrei<br>\* <strong>TRUE:</strong><br>Fehler beim Umwandlungsprozess</p> |

### Funktionsbeschreibung

#### Analogwertausgang

Der Analogwertausgang wird vom Analogwerteingang *rIn\_X* in Abhängigkeit der durch die beiden Punkte P1(*rX1*/*rY1*) und P2(*rX2*/*rY2*) bestimmten linearen Kennlinie berechnet. Im Falle eines Konvertierungsfehlers (*xErr* = TRUE) bleibt der Analogwertausgang unverändert.

> **Formel**
>
> rOut\_Y = (((rX1-rIn\_X)\*(rY2-rY1))/(rX1-rX2))+rY1
>
> **Einschränkungen**
>
> Der Analogwertausgang ist vom Datentyp `REAL`. Durch eine ungeeignete Auswahl der Parameter *rX1*, *rX2*, *rY1* und *rY2* sowie des Wertes des Analogwerteingangs *rIn\_X* kann es zu einer Überschreitung der Grenzen des Datentyps kommen.

#### Freigabe / Sperrung der Begrenzungen *xMinMaxLimit*

Die Begrenzungen des Analogwertausgangs können mit diesem Eingang generell freigegeben und gesperrt werden.

| *xMinMaxLimit* | Begrenzungen      | Hinweise                                     |
| -------------- | ----------------- | -------------------------------------------- |
| FALSE          | keine             | Analogwertausgang ohne absolute Begrenzungen |
| TRUE           | Y\_min und Y\_max | Begrenzung des Analogwertausgangs aktiv      |

#### Werte der Begrenzungen *iMinMaxOffset*

Die Begrenzungen des Analogwertausgangs sind nur dann aktiv, falls der Eingang *xMinMaxLimit* aktiv (= TRUE) ist. Die Grenzwerte Y\_min und Y\_max werden dann wie folgt berechnet:

> **Formeln**
>
> > Y\_min = rY1 - ((ABS(rY2-rY1))\*iMinMaxOffset)/100 Y\_max = rY2 + ((ABS(rY2-rY1))\*iMinMaxOffset)/100

| *rY1* | *rY2* | *rY2* - *rY1* | *iMinMaxOffset* | *Y\_min* | *Y\_max* | Hinweise              |
| ----- | ----- | ------------- | --------------- | -------- | -------- | --------------------- |
| 0     | 100   | 100           | 0               | 0        | 100      | Standard-Begrenzungen |
| 0     | 100   | 100           | 10              | -10      | 110      | Positiver Offset      |
| 0     | 100   | 100           | -10             | 10       | 90       | Negativer Offset      |

#### Digitalausgang *xErr*

Der digitale Ausgang *xErr* signalisiert einen Fehler beim Umwandlungsprozess. Folgende Fehler werden berücksichtigt:

* *rX1* UND *rX2* = 0
* *rX1* = *rX2*
* *rY1* UND *rY2* = 0
* *rY1* = *rY2*

| Fehler beim Umwandlungsprozess | *xErr* | Hinweise                       |
| ------------------------------ | ------ | ------------------------------ |
| FALSE                          | FALSE  | Umwandlung fehlerfrei          |
| TRUE                           | TRUE   | Fehler beim Umwandlungsprozess |

Legende: X = beliebig

### Codesys

InOut:

| Scope  | Name            | Type   | Initial | Comment                                                                                     |
| ------ | --------------- | ------ | ------- | ------------------------------------------------------------------------------------------- |
| Return | `TwoPointFun`   | `REAL` |         |                                                                                             |
| Input  | `rIn_X`         | `REAL` |         | Analogwerteingang                                                                           |
| Input  | `rX1`           | `REAL` | 0       | Punkt 1 des Eingangsbereiches                                                               |
| Input  | `rX2`           | `REAL` | 100     | Punkt 2 des Eingangsbereiches                                                               |
| Input  | `rY1`           | `REAL` | 0       | Punkt 1 der Ausgangskennlinie                                                               |
| Input  | `rY2`           | `REAL` | 100     | Punkt 2 der Ausgangskennlinie                                                               |
| Input  | `xMinMaxLimit`  | `BOOL` |         | Freigabe / Sperrung der Begrenzung am Analogwertausgang                                     |
| Input  | `iMinMaxOffset` | `INT`  |         | Werte der Begrenzungen am Analogwertausgang                                                 |
| Output | `xErr`          | `BOOL` |         | <p>FALSE: Umwandlung fehlerfrei<br><br><br>TRUE: Fehler beim Umwandlungsprozess<br><br></p> |


---

# 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/hvac-modbus-library/functions/twopointfun.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.
