> 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-knx-library/funktionen/twopointfun.md).

# TwoPointFun

## `TwoPointFun` (FUN)

FUNCTION TwoPointFun : INT

### 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`   | `INT`  |         |                                                                                             |
| Input  | `iIn_X`         | `INT`  |         | Analogwerteingang                                                                           |
| Input  | `iX1`           | `INT`  | 0       | Punkt 1 des Eingangsbereiches                                                               |
| Input  | `iX2`           | `INT`  | 100     | Punkt 2 des Eingangsbereiches                                                               |
| Input  | `iY1`           | `INT`  | 0       | Punkt 1 der Ausgangskennlinie                                                               |
| Input  | `iY2`           | `INT`  | 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://support.powerio.com/hub/codesys-hvac/hvac-knx-library/funktionen/twopointfun.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
