# HeatpumpGasboilerSelection

## `HeatpumpGasboilerSelection` (FB)

FUNCTION\_BLOCK HeatpumpGasboilerSelection

### Short description

Enablement of the gas boiler or the heat pump depending on various influencing factors.\
Influencing factors:

1. Current COP value of the heat pump
2. Cost of electrical energy (heat pump) in euros per kWh
3. Cost for natural gas supply (gas boiler) in euros per kWh
4. Efficiency of the heat pump (0.0 - 1.0)
5. Efficiency of the gas boiler (0.0 - 1.0)

The default settings of the internal characteristic curve match the COP curve W35-heating case of the WP Remeha E-HP AW 84.\
\
Typical application: Decision on enabling the gas boiler or the heat pump depending on the operating situation

### Representation

<figure><img src="/files/15e9d11621e6ec5c8881e91b2bfaf8de4d1e6e93" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name             | Data type                              | Value range | Initial value                                          | Function                                                                                     |
| ---------------- | -------------------------------------- | ----------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| *xEn*            | BOOL                                   |             | TRUE                                                   | Enable / disable the function block (TRUE = enabled)                                         |
| *eCOPSource*     | eHeatpumpGasboilerSelection\_COPSource |             | eHeatpumpGasboilerSelection\_COPSource.Internal\_Curve | Selection of the COP source (Internal\_Curve, External\_Input)                               |
| *rSourceTempCOP* | REAL                                   |             | 2.0                                                    | Current temperature of the heat source for the heat pump (air-water HP: outside temperature) |
| *rExtCOP*        | REAL                                   |             | 4.0                                                    | External value of the coefficient of performance (COP) of the heat pump (typical: 2.0 - 7.0) |
| *xExtError*      | BOOL                                   |             | FALSE                                                  | External error state (FALSE = no error, TRUE = error)                                        |
| *xExtValidData*  | BOOL                                   |             | FALSE                                                  | External input for the validity of the curve data (n) (FALSE = invalid)                      |

#### Outputs

| Name                          | Data type | Value range | Initial value | Function                                                                                    |
| ----------------------------- | --------- | ----------- | ------------- | ------------------------------------------------------------------------------------------- |
| *tRemainingTimeTestIntervall* | TIME      |             | T#0s          | Remaining time until the next test time point                                               |
| *rCOPLimit*                   | REAL      |             | 0.0           | Threshold of the COP for enabling the heat pump (rCOP >= rCOPLimit: enable the heat pump)   |
| *rCOP*                        | REAL      |             | 0.0           | Current value of the coefficient of performance (COP) of the heat pump (typical: 2.0 - 7.0) |
| *xCmdGasboiler*               | BOOL      |             | FALSE         | Enable / disable the gas boiler (TRUE = enabled)                                            |
| *xCmdHeatpump*                | BOOL      |             | FALSE         | Enable / disable the heat pump (TRUE = enabled)                                             |
| *xError*                      | BOOL      |             | FALSE         | Error state (FALSE = no error, TRUE = error)                                                |

#### Setpoints / parameters

| Name                      | Data type | Value range | Initial value | Function                                                   |
| ------------------------- | --------- | ----------- | ------------- | ---------------------------------------------------------- |
| **rEfficiencyGasboiler**  | REAL      |             | 0.9           | Overall efficiency of heat production with the gas boiler  |
| **rEfficiencyHeatpump**   | REAL      |             | 0.9           | Overall efficiency of heat production with the heat pump   |
| **rEnergyPriceGasboiler** | REAL      |             | 0.20          | Energy cost - gas (in euros / kWh of produced heat energy) |
| **rEnergyPriceHeatpump**  | REAL      |             | 0.45          | Energy cost - electricity (in euros / kWh)                 |
| **tTimeTestIntervall**    | TIME      |             | T#30M         | Duration of the test interval                              |
| **rCOP\_Subst**           | REAL      |             | 3.5           | Substitute value for the COP in case of error              |
| **rCOP\_Min**             | REAL      |             | 1.0           | Absolute minimum value of the COP                          |
| **rCOP\_Max**             | REAL      |             | 10.0          | Absolute maximum value of the COP                          |
| **rSP1\_X**               | REAL      |             | 1.0           | Support point 1 - X value                                  |
| **rSP1\_Y**               | REAL      |             | 2.0           | Support point 1 - Y value                                  |
| **rSP2\_X**               | REAL      |             | 2.0           | Support point 2 - X value                                  |
| **rSP2\_Y**               | REAL      |             | 4.0           | Support point 2 - Y value                                  |
| **rSP3\_X**               | REAL      |             | 3.0           | Support point 3 - X value                                  |
| **rSP3\_Y**               | REAL      |             | 6.0           | Support point 3 - Y value                                  |
| **rSP4\_X**               | REAL      |             | 4.0           | Support point 4 - X value                                  |
| **rSP4\_Y**               | REAL      |             | 8.0           | Support point 4 - Y value                                  |
| **rSP5\_X**               | REAL      |             | 5.0           | Support point 5 - X value                                  |
| **rSP5\_Y**               | REAL      |             | 10.0          | Support point 5 - Y value                                  |
| **rSP6\_X**               | REAL      |             | 6.0           | Support point 6 - X value                                  |
| **rSP6\_Y**               | REAL      |             | 12.0          | Support point 6 - Y value                                  |
| **rSP7\_X**               | REAL      |             | 7.0           | Support point 7 - X value                                  |
| **rSP7\_Y**               | REAL      |             | 14.0          | Support point 7 - Y value                                  |
| **rSP8\_X**               | REAL      |             | 8.0           | Support point 8 - X value                                  |
| **rSP8\_Y**               | REAL      |             | 16.0          | Support point 8 - Y value                                  |
| **rSP9\_X**               | REAL      |             | 9.0           | Support point 9 - X value                                  |
| **rSP9\_Y**               | REAL      |             | 18.0          | Support point 9 - Y value                                  |
| **rSP10\_X**              | REAL      |             | 10.0          | Support point 10 - X value                                 |
| **rSP10\_Y**              | REAL      |             | 20.0          | Support point 10 - Y value                                 |

### Function description

\
The enablement of the heat generators gas boiler or heat pump is determined by a calculation taking into account the following influencing factors:\
\
1\) Current COP value of the heat pump\
2\) Cost of electrical energy (heat pump) in euros per kWh\
3\) Cost for natural gas supply (gas boiler) in euros per kWh\
4\) Efficiency of the heat pump (0.0 - 1.0)\
5\) Efficiency of the gas boiler (0.0 - 1.0)\
\
Only one heat generator is enabled at any time; the other is automatically disabled.\
\
This calculation is performed (condition: xEn = TRUE) if at least one of the following situations occurs:\
\
1\) Cyclically at interval tTimeTestIntervall\
2\) Once at a rising edge on the input xEn\
3\) Once after every restart\
4\) Once at every change of the COP source selection eCOPSource\
\
The COP value of the heat pump can be determined by an internally stored curve with 10 value pairs (eCOPSource = Internal\_Curve, heat source temperature rSourceTempCOP) or\
by the external input rExtCOP (eCOPSource = External\_Input, xExtError = FALSE, xExtValidData = TRUE). It is limited by the absolute bounds **rCOP\_Min** or\
**rCOP\_Max** and, if error-free, output at the rCOP output and used for the calculation.\
In case of error (eCOPSource = Internal\_Curve: error in the input of the value pairs) or (eCOPSource = External\_Input: xExtError = TRUE or xExtValidData = FALSE) the\
substitute value **rCOP\_Subst** is used.\
\
The X-values of the 10 support points of the internal COP curve must meet the following boundary conditions:\
\
1\) The X-values must be either strictly increasing or strictly decreasing\
2\) Each X-value may only occur once\
3\) Two adjacent support points are each connected by a straight line\
\
At the output tRemainingTimeTestIntervall the remaining time until the next cyclic calculation is available.\
At the output rCOPLimit the threshold for switching to the gas boiler is available (rCOP < rCOPLimit: enable the gas boiler)\
\
In the disabled state (xEn = FALSE) the outputs take on sensible, constant values; no calculation is performed.\
\
At the output \*xError\* the current error state is available (xError = TRUE: error active). It is active if either the internal\
COP curve is faulty or the external error input xExtError is active (= TRUE).

### CODESYS

InOut:

| Scope       | Name                          | Type                                   | Initial                                                |
| ----------- | ----------------------------- | -------------------------------------- | ------------------------------------------------------ |
| Input       | `xEn`                         | `BOOL`                                 | TRUE                                                   |
| Input       | `eCOPSource`                  | eHeatpumpGasboilerSelection\_COPSource | eHeatpumpGasboilerSelection\_COPSource.Internal\_Curve |
| Input       | `rSourceTempCOP`              | `REAL`                                 | 2.0                                                    |
| Input       | `rExtCOP`                     | `REAL`                                 | 4.0                                                    |
| Input       | `xExtError`                   | `BOOL`                                 | FALSE                                                  |
| Input       | `xExtValidData`               | `BOOL`                                 | FALSE                                                  |
| Output      | `tRemainingTimeTestIntervall` | `TIME`                                 | TIME#0ms                                               |
| Output      | `rCOPLimit`                   | `REAL`                                 | 0.0                                                    |
| Output      | `rCOP`                        | `REAL`                                 | 0.0                                                    |
| Output      | `xCmdGasboiler`               | `BOOL`                                 | FALSE                                                  |
| Output      | `xCmdHeatpump`                | `BOOL`                                 | FALSE                                                  |
| Output      | `xError`                      | `BOOL`                                 | FALSE                                                  |
| Input Const | `rSP10_Y`                     | `REAL`                                 | 6.8                                                    |
| Input Const | `rSP10_X`                     | `REAL`                                 | 20.0                                                   |
| Input Const | `rSP9_Y`                      | `REAL`                                 | 5.85                                                   |
| Input Const | `rSP9_X`                      | `REAL`                                 | 16.1                                                   |
| Input Const | `rSP8_Y`                      | `REAL`                                 | 5.25                                                   |
| Input Const | `rSP8_X`                      | `REAL`                                 | 12.2                                                   |
| Input Const | `rSP7_Y`                      | `REAL`                                 | 4.65                                                   |
| Input Const | `rSP7_X`                      | `REAL`                                 | 8.3                                                    |
| Input Const | `rSP6_Y`                      | `REAL`                                 | 4.2                                                    |
| Input Const | `rSP6_X`                      | `REAL`                                 | 4.4                                                    |
| Input Const | `rSP5_Y`                      | `REAL`                                 | 3.7                                                    |
| Input Const | `rSP5_X`                      | `REAL`                                 | 0.5                                                    |
| Input Const | `rSP4_Y`                      | `REAL`                                 | 3.35                                                   |
| Input Const | `rSP4_X`                      | `REAL`                                 | -3.3                                                   |
| Input Const | `rSP3_Y`                      | `REAL`                                 | 3.1                                                    |
| Input Const | `rSP3_X`                      | `REAL`                                 | -7.2                                                   |
| Input Const | `rSP2_Y`                      | `REAL`                                 | 2.95                                                   |
| Input Const | `rSP2_X`                      | `REAL`                                 | -11.1                                                  |
| Input Const | `rSP1_Y`                      | `REAL`                                 | 2.8                                                    |
| Input Const | `rSP1_X`                      | `REAL`                                 | -15.0                                                  |
| Input Const | `rCOP_Max`                    | `REAL`                                 | 10.0                                                   |
| Input Const | `rCOP_Min`                    | `REAL`                                 | 1.0                                                    |
| Input Const | `rCOP_Subst`                  | `REAL`                                 | 3.5                                                    |
| Input Const | `tTimeTestIntervall`          | `TIME`                                 | TIME#30m0s0ms                                          |
| Input Const | `rEnergyPriceHeatpump`        | `REAL`                                 | 0.45                                                   |
| Input Const | `rEnergyPriceGasboiler`       | `REAL`                                 | 0.2                                                    |
| Input Const | `rEfficiencyHeatpump`         | `REAL`                                 | 0.9                                                    |
| Input Const | `rEfficiencyGasboiler`        | `REAL`                                 | 0.9                                                    |

Methods:

> mCalculateCurveSectionValue\_Real\_Real

> mCalculateCurveValue\_Real\_Real

Structure:

* mCalculateCurveSectionValue\_Real\_Real (Method)
* mCalculateCurveValue\_Real\_Real (Method)


---

# Agent Instructions: 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:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/components/heatpumpgasboilerselection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
