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

# PowerFeedOptimizer

## `PowerFeedOptimizer` (FB)

FUNCTION\_BLOCK PowerFeedOptimizer

### Short description

> Maximum value limiting of the electrical power at the grid connection point by switching off consumers 1 - 4 (index ‘\_Con’) (e.g. electric heating)\
> Minimum value limiting of the electrical power at the grid connection point by switching on generators 1 - 4 (index ‘\_Gen’) (e.g. heat pump for cooling)\
> Influencing factors: electrical power at the grid connection point, operating hours, operating and fault states of the consumers / generators\
> Typical application: optimization of the time profile of the electrical power at the grid connection point

### Representation

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

### Video

{% embed url="<https://www.youtube.com/watch?v=x77_l3Gkp8Y>" fullWidth="false" %}

### Interfaces

#### Inputs

| Name                          | Data type | Value range | Initial value | Function                                                                                                         |
| ----------------------------- | --------- | ----------- | ------------- | ---------------------------------------------------------------------------------------------------------------- |
| *xEn*                         | BOOL      |             | TRUE          | Enable / disable of the function block                                                                           |
| *xUpdateDeviceOutputs*        | BOOL      |             | FALSE         | Update of the device outputs (on every rising edge)                                                              |
| *xResError*                   | BOOL      |             | FALSE         | Reinitialization of the fault outputs to the respective fault-free states (on every rising edge)                 |
| *rElectricalPower*            | REAL      |             | 0.0           | Current electrical power at the feed-in point in XX.X kW                                                         |
| *rMaxElectricalPower\_Con*    | REAL      |             | 100.0         | Maximum electrical power at the feed-in point (import) in XX.X kW before switching off consumers                 |
| *rMaxElectricalPower\_Gen*    | REAL      |             | -100.0        | Maximum electrical power at the feed-in point (feed-in) in XX.X kW before switching on generators                |
| *wActiveNumberOfDevices\_Con* | WORD      |             | 4             | Number of requested consumers (0 - 4)                                                                            |
| *xFb\_Con1*                   | BOOL      |             | FALSE         | Operation - Consumer 1 (TRUE = operation)                                                                        |
| *xFb\_Con2*                   | BOOL      |             | FALSE         | Operation - Consumer 2 (TRUE = operation)                                                                        |
| *xFb\_Con3*                   | BOOL      |             | FALSE         | Operation - Consumer 3 (TRUE = operation)                                                                        |
| *xFb\_Con4*                   | BOOL      |             | FALSE         | Operation - Consumer 4 (TRUE = operation)                                                                        |
| *xAlarm\_Con1*                | BOOL      |             | FALSE         | Fault - Consumer 1 (TRUE = fault)                                                                                |
| *xAlarm\_Con2*                | BOOL      |             | FALSE         | Fault - Consumer 2 (TRUE = fault)                                                                                |
| *xAlarm\_Con3*                | BOOL      |             | FALSE         | Fault - Consumer 3 (TRUE = fault)                                                                                |
| *xAlarm\_Con4*                | BOOL      |             | FALSE         | Fault - Consumer 4 (TRUE = fault)                                                                                |
| *udiOpHours\_Con1*            | UDINT     |             | 0             | Operating hours - Consumer 1                                                                                     |
| *udiOpHours\_Con2*            | UDINT     |             | 0             | Operating hours - Consumer 2                                                                                     |
| *udiOpHours\_Con3*            | UDINT     |             | 0             | Operating hours - Consumer 3                                                                                     |
| *udiOpHours\_Con4*            | UDINT     |             | 0             | Operating hours - Consumer 4                                                                                     |
| *wActiveNumberOfDevices\_Gen* | WORD      |             | 4             | Number of requested generators (0 - 4)                                                                           |
| *xFb\_Gen1*                   | BOOL      |             | FALSE         | Operation - Generator 1 (TRUE = operation)                                                                       |
| *xFb\_Gen2*                   | BOOL      |             | FALSE         | Operation - Generator 2 (TRUE = operation)                                                                       |
| *xFb\_Gen3*                   | BOOL      |             | FALSE         | Operation - Generator 3 (TRUE = operation)                                                                       |
| *xFb\_Gen4*                   | BOOL      |             | FALSE         | Operation - Generator 4 (TRUE = operation)                                                                       |
| *xAlarm\_Gen1*                | BOOL      |             | FALSE         | Fault - Generator 1 (TRUE = fault)                                                                               |
| *xAlarm\_Gen2*                | BOOL      |             | FALSE         | Fault - Generator 2 (TRUE = fault)                                                                               |
| *xAlarm\_Gen3*                | BOOL      |             | FALSE         | Fault - Generator 3 (TRUE = fault)                                                                               |
| *xAlarm\_Gen4*                | BOOL      |             | FALSE         | Fault - Generator 4 (TRUE = fault)                                                                               |
| *udiOpHours\_Gen1*            | UDINT     |             | 0             | Operating hours - Generator 1                                                                                    |
| *udiOpHours\_Gen2*            | UDINT     |             | 0             | Operating hours - Generator 2                                                                                    |
| *udiOpHours\_Gen3*            | UDINT     |             | 0             | Operating hours - Generator 3                                                                                    |
| *udiOpHours\_Gen4*            | UDINT     |             | 0             | Operating hours - Generator 4                                                                                    |
| *xUpdateRedundance4\_Con*     | BOOL      |             | FALSE         | Triggering the recalculation of the sequence for the consumers (internal FB ‘Redundance4’) on every rising edge  |
| *xUpdateRedundance4\_Gen*     | BOOL      |             | FALSE         | Triggering the recalculation of the sequence for the generators (internal FB ‘Redundance4’) on every rising edge |

#### Outputs

| Name                               | Data type                               | Value range | Initial value | Function                                                                                      |
| ---------------------------------- | --------------------------------------- | ----------- | ------------- | --------------------------------------------------------------------------------------------- |
| *xLoadRejection\_Con*              | BOOL                                    |             | FALSE         | Current state of switching off active consumers (TRUE = switching off active)                 |
| *rTotalNomElectricalPower\_Con*    | REAL                                    |             | 0.0           | Total nominal electrical power of all operational and active consumers in XX.X kW             |
| *rControlSignal\_Con*              | REAL                                    |             | 0.0           | Difference in electrical power in XX.X kW for the consumers                                   |
| *wNumberOfOperationalDevices\_Con* | WORD                                    |             | 0             | Number of operational consumers                                                               |
| *udiCurrentSequence\_Con*          | UDINT                                   |             | 0             | Current device sequence of the consumers as integer (criteria: fault state, operating hours)  |
| *sCurrentSequence\_Con*            | STRING                                  |             | ‘’            | Current device sequence of the consumers as string (criteria: fault state, operating hours)   |
| *stOutputs\_Con1*                  | stDevicesOutputsCon\_PowerFeedOptimizer |             |               | Current states of all outputs of consumer 1                                                   |
| *stOutputs\_Con2*                  | stDevicesOutputsCon\_PowerFeedOptimizer |             |               | Current states of all outputs of consumer 2                                                   |
| *stOutputs\_Con3*                  | stDevicesOutputsCon\_PowerFeedOptimizer |             |               | Current states of all outputs of consumer 3                                                   |
| *stOutputs\_Con4*                  | stDevicesOutputsCon\_PowerFeedOptimizer |             |               | Current states of all outputs of consumer 4                                                   |
| *eOperationalCondition\_Con*       | eRedundance3\_OperationalMode           |             |               | Number / name of the current operating state of the consumers (Redundance4)                   |
| *xLoadConnection\_Gen*             | BOOL                                    |             | FALSE         | Current state of switching on active generators (TRUE = switching on active)                  |
| *rTotalNomElectricalPower\_Gen*    | REAL                                    |             | 0.0           | Total nominal electrical power of all operational and active generators in XX.X kW            |
| *rControlSignal\_Gen*              | REAL                                    |             | 0.0           | Difference in electrical power in XX.X kW for the generators                                  |
| *wNumberOfOperationalDevices\_Gen* | WORD                                    |             | 0             | Number of operational generators                                                              |
| *udiCurrentSequence\_Gen*          | UDINT                                   |             | 0             | Current device sequence of the generators as integer (criteria: fault state, operating hours) |
| *sCurrentSequence\_Gen*            | STRING                                  |             | ‘’            | Current device sequence of the generators as string (criteria: fault state, operating hours)  |
| *stOutputs\_Gen1*                  | stDevicesOutputsGen\_PowerFeedOptimizer |             |               | Current states of all outputs of generator 1                                                  |
| *stOutputs\_Gen2*                  | stDevicesOutputsGen\_PowerFeedOptimizer |             |               | Current states of all outputs of generator 2                                                  |
| *stOutputs\_Gen3*                  | stDevicesOutputsGen\_PowerFeedOptimizer |             |               | Current states of all outputs of generator 3                                                  |
| *stOutputs\_Gen4*                  | stDevicesOutputsGen\_PowerFeedOptimizer |             |               | Current states of all outputs of generator 4                                                  |
| *eOperationalCondition\_Gen*       | eRedundance3\_OperationalMode           |             |               | Number / name of the current operating state of the generators (Redundance4)                  |
| *xErr*                             | BOOL                                    |             | FALSE         | Output - fault (TRUE = fault)                                                                 |
| *sErrorCodes\_General*             | STRING                                  |             | ‘’            | String with the numbers of the active error bits - General                                    |
| *sErrorCodes\_Con*                 | STRING                                  |             | ‘’            | String with the numbers of the active error bits - Consumer                                   |
| *sErrorCodes\_Gen*                 | STRING                                  |             | ‘’            | String with the numbers of the active error bits - Generator                                  |

#### Setpoints / Parameters

| Name                             | Data type                          | Value range | Initial value                                    | Function                                                                                                                                                                                             |
| -------------------------------- | ---------------------------------- | ----------- | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **tTimeUpdateDeviceOutputs**     | TIME                               |             | T#3s                                             | Update interval for the processes influenced by the input ‘xUpdateDeviceOutputs’                                                                                                                     |
| **wTolerance\_Con**              | WORD                               |             | 100                                              | Limit value - operating hour difference for direct successive change in partial-load operation of the consumers                                                                                      |
| **xEnFb\_Con**                   | BOOL                               |             | FALSE                                            | Selection criterion for determining the operating state (idle / partial load / full load), FALSE: enable outputs - consumers (xCmd\_ConX), TRUE: operating feedback inputs - consumers (xFb\_ConX)   |
| **xConOperatingHours\_Con**      | BOOL                               |             | TRUE                                             | Trigger criterion for recalculating the sequence, FALSE: only via input ‘xUpdateRedundance4\_Con’, TRUE: automatically after operating hours ‘udiOpHours\_ConX’                                      |
| **wTolerance\_Gen**              | WORD                               |             | 100                                              | Limit value - operating hour difference for direct successive change in partial-load operation of the generators                                                                                     |
| **xEnFb\_Gen**                   | BOOL                               |             | FALSE                                            | Selection criterion for determining the operating state (idle / partial load / full load), FALSE: enable outputs - generators (xCmd\_GenX), TRUE: operating feedback inputs - generators (xFb\_GenX) |
| **xConOperatingHours\_Gen**      | BOOL                               |             | TRUE                                             | Trigger criterion for recalculating the sequence, FALSE: only via input ‘xUpdateRedundance4\_Gen’, TRUE: automatically after operating hours ‘udiOpHours\_GenX’                                      |
| **tInitDelay\_EP**               | TIME                               |             | T#5s                                             | Start delay - initialization for the input ‘rElectricalPower’ (eInitial\_rEP = InitValueDelayed)                                                                                                     |
| **eInitial\_EP**                 | eInit                              |             | eInit.InputValue                                 | Selection of the initial value for the input ‘rElectricalPower’                                                                                                                                      |
| **rInitValue\_EP**               | REAL                               |             | 0.0                                              | Initial value for the input ‘rElectricalPower’ (eInitial\_rEP = InitValue)                                                                                                                           |
| **tTimeConstant\_EP**            | TIME                               |             | T#15s                                            | Filter - time constant for the input ‘rElectricalPower’                                                                                                                                              |
| **rTn\_Con**                     | REAL                               |             | 180.0                                            | PI controller for the power difference: reset time for the control deviation in seconds                                                                                                              |
| **rTn\_Gen**                     | REAL                               |             | 180.0                                            | PI controller for the power difference: reset time for the control deviation in seconds                                                                                                              |
| eControlSelect                   | ePowerFeedOptimizer\_ControlSelect |             | ePowerFeedOptimizer\_ControlSelect.P\_Controller | Selection of the controller characteristics (common for the controllers for consumers and generators)                                                                                                |
| **rMinNomElectricalPower\_Con1** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of consumer 1 in XX.X kW                                                                                                                                            |
| **rMaxNomElectricalPower\_Con1** | REAL                               |             | 10.0                                             | Maximum nominal electrical power of consumer 1 in XX.X kW                                                                                                                                            |
| **tOnDelayCmd\_Con1**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - consumer 1                                                                                                                                                  |
| **tOffDelayCmd\_Con1**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - consumer 1                                                                                                                                                 |
| **rMinNomElectricalPower\_Con2** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of consumer 2 in XX.X kW                                                                                                                                            |
| **rMaxNomElectricalPower\_Con2** | REAL                               |             | 10.0                                             | Maximum nominal electrical power of consumer 2 in XX.X kW                                                                                                                                            |
| **tOnDelayCmd\_Con2**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - consumer 2                                                                                                                                                  |
| **tOffDelayCmd\_Con2**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - consumer 2                                                                                                                                                 |
| **rMinNomElectricalPower\_Con3** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of consumer 3 in XX.X kW                                                                                                                                            |
| **rMaxNomElectricalPower\_Con3** | REAL                               |             | 10.0                                             | Maximum nominal electrical power of consumer 3 in XX.X kW                                                                                                                                            |
| **tOnDelayCmd\_Con3**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - consumer 3                                                                                                                                                  |
| **tOffDelayCmd\_Con3**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - consumer 3                                                                                                                                                 |
| **rMinNomElectricalPower\_Con4** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of consumer 4 in XX.X kW                                                                                                                                            |
| **rMaxNomElectricalPower\_Con4** | REAL                               |             | 10.0                                             | Maximum nominal electrical power of consumer 4 in XX.X kW                                                                                                                                            |
| **tOnDelayCmd\_Con4**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - consumer 4                                                                                                                                                  |
| **tOffDelayCmd\_Con4**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - consumer 4                                                                                                                                                 |
| **rMinNomElectricalPower\_Gen1** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of generator 1 in XX.X kW                                                                                                                                           |
| **rMaxNomElectricalPower\_Gen1** | REAL                               |             | -10.0                                            | Maximum nominal electrical power of generator 1 in XX.X kW                                                                                                                                           |
| **tOnDelayCmd\_Gen1**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - generator 1                                                                                                                                                 |
| **tOffDelayCmd\_Gen1**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - generator 1                                                                                                                                                |
| **rMinNomElectricalPower\_Gen2** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of generator 2 in XX.X kW                                                                                                                                           |
| **rMaxNomElectricalPower\_Gen2** | REAL                               |             | -10.0                                            | Maximum nominal electrical power of generator 2 in XX.X kW                                                                                                                                           |
| **tOnDelayCmd\_Gen2**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - generator 2                                                                                                                                                 |
| **tOffDelayCmd\_Gen2**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - generator 2                                                                                                                                                |
| **rMinNomElectricalPower\_Gen3** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of generator 3 in XX.X kW                                                                                                                                           |
| **rMaxNomElectricalPower\_Gen3** | REAL                               |             | -10.0                                            | Maximum nominal electrical power of generator 3 in XX.X kW                                                                                                                                           |
| **tOnDelayCmd\_Gen3**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - generator 3                                                                                                                                                 |
| **tOffDelayCmd\_Gen3**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - generator 3                                                                                                                                                |
| **rMinNomElectricalPower\_Gen4** | REAL                               |             | 0.0                                              | Minimum nominal electrical power of generator 4 in XX.X kW                                                                                                                                           |
| **rMaxNomElectricalPower\_Gen4** | REAL                               |             | -10.0                                            | Maximum nominal electrical power of generator 4 in XX.X kW                                                                                                                                           |
| **tOnDelayCmd\_Gen4**            | TIME                               |             | T#10s                                            | Switch-on delay - enable output ‘xCmd’ - generator 4                                                                                                                                                 |
| **tOffDelayCmd\_Gen4**           | TIME                               |             | T#10s                                            | Switch-off delay - enable output ‘xCmd’ - generator 4                                                                                                                                                |

### Functional description

#### General

This function block is used to limit (control) the electrical power at the grid connection point ‘rElectricalPower’ to adjustable maximum values. Power / energy drawn from the grid connection point is marked with a positive sign, and power / energy fed back into the grid connection point is marked with a negative sign.\
\
If the electrical power ‘rElectricalPower’ exceeds the adjustable positive maximum value ‘rMaxElectricalPower\_Con’, then the consumers are switched off continuously, starting with the active device with the lowest priority.\
\
If the electrical power ‘rElectricalPower’ falls below the adjustable negative maximum value ‘rMaxElectricalPower\_Gen’, then the generators are switched on continuously, starting with the device with the highest priority (PI controller behavior).\
\
Without any further wiring at the inputs ‘xFb’, ‘xAlarm’ and ‘udiOpHours’ as well as the initial parameter settings, device 1 is assigned priority 1 (= highest) and device 4 is assigned priority 4 (= lowest).\
For each functionality (switching off consumers, switching on generators), there is internally a separate function block ‘Redundance4’ from this library, in which a configurable number of consumers (‘wActiveNumberOfDevices\_Con’) and generators (‘wActiveNumberOfDevices\_Gen’) is used. The detailed information on this function block is described there.\
\
The enable / disable of the function block is performed via the input **xEn**, when disabled, all outputs assume defined states.\
The devices with the index ‘\_Con’ are consumers, and the devices with the index ‘*Gen’ are generators.*\
\
*Signal flow:*\
\
*The current actual value ‘rElectricalPower’ is subjected to time filtering (four parameters with index ‘\_*&#x45;P’)\
and fed to the selected controllers.\
Depending on the selected controller (parameter ‘eControlSelect’), the difference between the actual value at the input ‘rElectricalPower’ and the corresponding maximum value ‘rMaxElectricalPower\_Con’ / ‘rMaxElectricalPower\_Gen’ is formed (gain factor = 1.0 constant) and then passed to the logic for selecting the consumers / generators. Each device is represented by the\
elements of a structure variable ‘stOutputs\_ConX’ or ‘stOutputs\_GenY’.\
\
The element ‘rPowerSignalkW’ always contains the maximum possible power of the device.\
The element ‘xCmd\_Redundance4’ contains the enable of the device from the FB ‘Redundance4’.\
The element ‘xCmd’ contains the enable of the device from the signal flow; it also includes the\
blocking of the device (xCmd = FALSE).

#### Input *xEn*

This input is used to enable / disable the function block; when disabled, all outputs assume defined states.

#### Input *xUpdateDeviceOutputs*

Every rising edge at this input triggers an update of all device outputs (outputs ‘stOutputs\_XXXX’).

#### Input *xResError*

Every rising edge at this input triggers a reset of all fault outputs (‘sErrorCodes\_General’, ‘sErrorCodes\_Con’ and ‘sErrorCodes\_Gen ’)\
to the fault-free state.

#### Input *rElectricalPower*

The current electrical power at the grid connection point is available at this input. Power import is indicated by a positive sign, feed-in by a negative sign. The electrical power is then time-filtered (four parameters with the index \_EP’) and is then available for the internal control processes.

#### Input *rMaxElectricalPower\_Con*

The current maximum value of electrical power import is specified at this input. If the current electrical power at input ‘rElectricalPower’ exceeds this maximum value, the consumers are continuously switched off, depending on their nominal power, starting with the consumer with the lowest priority.\
The control behavior of the PI controller used can be influenced by parameter ‘rTn\_Con’ (= reset time, if PI controller is selected).

#### Input *rMaxElectricalPower\_Gen*

The current maximum value of electrical power feed-in is specified at this input. If the current electrical power at input ‘rElectricalPower’ falls below this maximum value,\
the generators are continuously switched on, depending on their nominal power, starting with the generator with the highest priority.\
The control behavior of the PI controller used can be influenced by parameter ‘rTn\_Gen’ (= reset time, if PI controller is selected).

#### Input *wActiveNumberOfDevices\_Con*

The number of consumers used in the range 0 - 4 is specified at this input. It is directly connected to the internal function block ‘Redundance4\_Con’\
(input ‘wActiveNumberOfDevices’).

#### Input *wActiveNumberOfDevices\_Gen*

The number of generators used in the range 0 - 4 is specified at this input. It is directly connected to the internal function block ‘Redundance4\_Gen’\
(input ‘wActiveNumberOfDevices’).

#### Device inputs `xFb``, alarm` and `udiOpHours`

These device inputs are fed directly to the corresponding inputs of the internal function blocks of type ‘Redundance4’ and influence the current\
sequence of the respective four devices.

#### Inputs `xUpdateRedundance4`

These inputs are fed directly to the corresponding inputs of the internal function blocks of type ‘Redundance4’ and influence the current\
sequence of the respective four devices.

#### Output *xLoadRejection\_Con*

This output always indicates the current switch-off of active consumers (= TRUE).

#### Output *rTotalNomElectricalPower\_Con*

This output always indicates the currently switch-off-capable power of the operational and active consumers in kW.

#### Output *rControlSignal\_Con*

This output always indicates the control signal of the internal PI controller (= desired power to be switched off).

#### Output *wNumberOfOperationalDevices\_Con*

This output always indicates the number of operational consumers.

#### Output *udiCurrentSequence\_Con*

This output always indicates the current device sequence as an integer. The number of the device with the highest priority is always at the beginning, followed by the number of the device with the second-highest priority, and so on.

{% hint style="info" %}
Example: *udiCurrentSequence\_Con* = 145 means: device 1 = priority 1, device 4 = priority 2 and device 5 = priority 3
{% endhint %}

#### Output *sCurrentSequence\_Con*

This output always shows the current device sequence as a string with separators. The same applies to the priorities as for the output *udiCurrentSequence*.

{% hint style="info" %}
Example: *sCurrentSequence\_Con* = ‘1-4-5’ means: device 1 = priority 1, device 4 = priority 2 and device 5 = priority 3
{% endhint %}

#### Outputs *stOutputs\_Con*

This structure variable always indicates the current states of the respective devices. The following variables are displayed:

1. rMinNomElectricalPower: Minimum nominal electrical power of the consumer in XX.X kW
2. rMaxNomElectricalPower: Maximum nominal electrical power of the consumer in XX.X kW
3. wPrio: Current priority of the device (0 = none, 1 = highest, 4 = lowest)
4. rPowerSignalPercent: Control signal for electrical power in percent (0.0 - 100.0%)
5. rPowerSignalkW: Control signal for electrical power in kW
6. xCmd: Enable output of the device (TRUE = enable) taking into account the on and off delay
7. xCmd\_Redundance4: Enable output of the device (TRUE = enable) due to the internal function block **Redundance4\_Con**
8. rMinRangeElectricalPower: Absolute minimum value - range of the electrical power of the consumer in XX.X kW
9. rMaxRangeElectricalPower: Absolute maximum value - range of the electrical power of the consumer in XX.X kW
10. rPowerSignalPercentCmd: Control signal for electrical power in percent (0.0 - 100.0%) for the enable output xCmd<br>

#### Output *eOperationalCondition\_Con*

This output always shows the current load situation (idle, partial load, full load) and is taken directly from the internal function block **Redundance4** .

#### Output *xLoadConnection\_Gen*

This output always indicates the current switching on of active (= TRUE) generators.

#### Output *rTotalNomElectricalPower\_Gen*

This output always indicates the currently switch-on-capable power of the operational and active generators in kW.

#### Output *rControlSignal\_Gen*

This output always indicates the control signal of the internal PI controller (= desired power to be switched on).

#### Output *wNumberOfOperationalDevices\_Gen*

This output always indicates the number of operational generators.

#### Output *udiCurrentSequence\_Gen*

This output always indicates the current device sequence as an integer. The number of the device with the highest priority is always at the beginning, followed by the number of the device with the second-highest priority, and so on.

{% hint style="info" %}
Example: *udiCurrentSequence\_Gen* = 145 means: device 1 = priority 1, device 4 = priority 2 and device 5 = priority 3
{% endhint %}

#### Output *sCurrentSequence\_Gen*

This output always shows the current device sequence as a string with separators. The same applies to the priorities as for the output *udiCurrentSequence*.

{% hint style="info" %}
Example: *sCurrentSequence\_gen* = ‘1-4-5’ means: device 1 = priority 1, device 4 = priority 2 and device 5 = priority 3
{% endhint %}

#### Outputs *stOutputs\_Gen*

This structure variable always indicates the current states of the respective devices. The following variables are displayed:

1. rMinNomElectricalPower: Minimum nominal electrical power of the generator in XX.X kW
2. rMaxNomElectricalPower: Maximum nominal electrical power of the generator in XX.X kW
3. wPrio: Current priority of the device (0 = none, 1 = highest, 4 = lowest)
4. rPowerSignalPercent: Control signal for electrical power in percent (0.0 - 100.0%)
5. rPowerSignalkW: Control signal for electrical power in kW
6. xCmd: Enable output of the device (TRUE = enable) taking into account the on and off delay
7. xCmd\_Redundance4: Enable output of the device (TRUE = enable) due to the internal function block **Redundance4\_Gen**
8. rMinRangeElectricalPower: Absolute minimum value - range of the electrical power of the consumer in XX.X kW
9. rMaxRangeElectricalPower: Absolute maximum value - range of the electrical power of the consumer in XX.X kW
10. rPowerSignalPercentCmd: Control signal for electrical power in percent (0.0 - 100.0%) for the enable output xCmd

#### Output *eOperationalCondition\_Gen*

This output always shows the current load situation (idle, partial load, full load) and is taken directly from the internal function block **Redundance4** .

#### Fault output *xErr*

This output is active (= TRUE) if at least one of the following conditions is met.

1. Number of general errors > 0
2. Number of errors in the consumer functionality > 0
3. Number of errors in the generator functionality > 0

\
In all other cases, the output is **xErr** not active (= FALSE).

#### Output *sErrorCodes\_General*

Any active errors (maximum 16 = bits 0 - 15) from the general area are displayed as a string at this output.

{% hint style="info" %}
Example: ‘1-2’: Error bits 0 and 1 are active.
{% endhint %}

#### Output *sErrorCodes\_Con*

Any active errors (maximum 16 = bits 0 - 15) from the consumer area are displayed as a string at this output.

{% hint style="info" %}
Example: ‘1-2’: Error bits 0 and 1 are active.
{% endhint %}

#### Output *sErrorCodes\_Gen*

Any active errors (maximum 16 = bits 0 - 15) from the generator area are displayed as a string at this output.

{% hint style="info" %}
Example: ‘1-2’: Error bits 0 and 1 are active.
{% endhint %}

#### Parameter ***wTolerance\_Con***, **xEnFb\_Con** and **xConOperatingHours\_Con**

These parameters relate to the strategies for determining the device sequence in the internal function block **Redundance4** and are described there in detail.

#### Parameter ***wTolerance\_Gen***, **xEnFb\_Gen** and **xConOperatingHours\_Gen**

These parameters relate to the strategies for determining the device sequence in the internal function block **Redundance4** and are described there in detail.

#### Parameter ***rMinNominalElectricalPower\_ConX***, ***rMaxNominalElectricalPower\_ConX***, **tOnDelayCmd\_ConX** and **tOffDelayCmd\_ConX**

These parameters relate to consumers 1 - 4 and influence the assigned device outputs. The respective on and off delays act on the respective device outputs **xCmd**.

#### Parameter ***rMinNominalElectricalPower\_GenX***, ***rMaxNominalElectricalPower\_GenX***, **tOnDelayCmd\_GenX** and **tOffDelayCmd\_GenX**

These parameters relate to generators 1 - 4 and influence the assigned device outputs. The respective on and off delays act on the respective device outputs **xCmd**.

#### Parameter eControlSelect

These parameters define the controller characteristic (P or PI behavior) of the two controllers (consumers and generators).\
The gain factor rkP is fixed to the constant 1.0 for both controllers and cannot be changed.\
The reset times rTn can be set separately for both PI controllers.

#### Criteria for updating the device outputs ‘stOutputs\_ConX’

These outputs are updated in the enabled state (xEn = TRUE) if at least one of the following criteria applies:

1. once after every restart of the controller
2. on every rising edge at the input **xUpdateDeviceOutputs**
3. cyclically in the time interval ‘**tTimeUpdateDeviceOutputs**’ (**tTimeUpdateDeviceOutputs** > 0)
4. once for every change in the sequence (**udiCurrentSequence\_Con**)
5. once for every change in the minimum nominal electrical power of the consumers (**rMinNomElectricalPower\_ConX**)
6. once for every change in the maximum nominal electrical power of the consumers (**rMaxNomElectricalPower\_ConX**)
7. once for every rising edge at the input **xEn**

#### Criteria for updating the device outputs **stOutputs\_GenX**

These outputs are updated in the enabled state (xEn = TRUE) if at least one of the following criteria applies:

1. once after every restart of the controller
2. on every rising edge at the input **xUpdateDeviceOutputs**
3. cyclically at the time interval **tTimeUpdateDeviceOutputs** (**tTimeUpdateDeviceOutputs** > 0)
4. once for every change in the sequence (**udiCurrentSequence\_Gen**)
5. once for every change in the minimum nominal electrical power of the generators (**rMinNomElectricalPower\_GenX**)
6. once for every change in the maximum nominal electrical power of the generators (**rMaxNomElectricalPower\_GenX**)
7. once for every rising edge at the input **xEn**

### CODESYS

InOut:

| Scope       | Name                              | Type                                    | Initial          |
| ----------- | --------------------------------- | --------------------------------------- | ---------------- |
| Input       | `xEn`                             | `BOOL`                                  | TRUE             |
| Input       | `xUpdateDeviceOutputs`            | `BOOL`                                  | FALSE            |
| Input       | `xResError`                       | `BOOL`                                  | FALSE            |
| Input       | `rElectricalPower`                | `REAL`                                  | 0.0              |
| Input       | `rMaxElectricalPower_Con`         | `REAL`                                  | 100.0            |
| Input       | `rMaxElectricalPower_Gen`         | `REAL`                                  | -100.0           |
| Input       | `wActiveNumberOfDevices_Con`      | `WORD`                                  | 4                |
| Input       | `xFb_Con1`                        | `BOOL`                                  | FALSE            |
| Input       | `xFb_Con2`                        | `BOOL`                                  | FALSE            |
| Input       | `xFb_Con3`                        | `BOOL`                                  | FALSE            |
| Input       | `xFb_Con4`                        | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Con1`                     | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Con2`                     | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Con3`                     | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Con4`                     | `BOOL`                                  | FALSE            |
| Input       | `udiOpHours_Con1`                 | `UDINT`                                 | 0                |
| Input       | `udiOpHours_Con2`                 | `UDINT`                                 | 0                |
| Input       | `udiOpHours_Con3`                 | `UDINT`                                 | 0                |
| Input       | `udiOpHours_Con4`                 | `UDINT`                                 | 0                |
| Input       | `wActiveNumberOfDevices_Gen`      | `WORD`                                  | 4                |
| Input       | `xFb_Gen1`                        | `BOOL`                                  | FALSE            |
| Input       | `xFb_Gen2`                        | `BOOL`                                  | FALSE            |
| Input       | `xFb_Gen3`                        | `BOOL`                                  | FALSE            |
| Input       | `xFb_Gen4`                        | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Gen1`                     | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Gen2`                     | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Gen3`                     | `BOOL`                                  | FALSE            |
| Input       | `xAlarm_Gen4`                     | `BOOL`                                  | FALSE            |
| Input       | `udiOpHours_Gen1`                 | `UDINT`                                 | 0                |
| Input       | `udiOpHours_Gen2`                 | `UDINT`                                 | 0                |
| Input       | `udiOpHours_Gen3`                 | `UDINT`                                 | 0                |
| Input       | `udiOpHours_Gen4`                 | `UDINT`                                 | 0                |
| Input       | `xUpdateRedundance4_Con`          | `BOOL`                                  | FALSE            |
| Input       | `xUpdateRedundance4_Gen`          | `BOOL`                                  | FALSE            |
| Output      | `xLoadRejection_Con`              | `BOOL`                                  | FALSE            |
| Output      | `rTotalNomElectricalPower_Con`    | `REAL`                                  | 0.0              |
| Output      | `rControlSignal_Con`              | `REAL`                                  | 0.0              |
| Output      | `wNumberOfOperationalDevices_Con` | `WORD`                                  | 0                |
| Output      | `udiCurrentSequence_Con`          | `UDINT`                                 | 0                |
| Output      | `sCurrentSequence_Con`            | `STRING`                                | ‘’               |
| Output      | `stOutputs_Con1`                  | stDevicesOutputsCon\_PowerFeedOptimizer |                  |
| Output      | `stOutputs_Con2`                  | stDevicesOutputsCon\_PowerFeedOptimizer |                  |
| Output      | `stOutputs_Con3`                  | stDevicesOutputsCon\_PowerFeedOptimizer |                  |
| Output      | `stOutputs_Con4`                  | stDevicesOutputsCon\_PowerFeedOptimizer |                  |
| Output      | `eOperationalCondition_Con`       | eRedundance3\_OperationalMode           |                  |
| Output      | `xLoadConnection_Gen`             | `BOOL`                                  | FALSE            |
| Output      | `rTotalNomElectricalPower_Gen`    | `REAL`                                  | 0.0              |
| Output      | `rControlSignal_Gen`              | `REAL`                                  | 0.0              |
| Output      | `wNumberOfOperationalDevices_Gen` | `WORD`                                  | 0                |
| Output      | `udiCurrentSequence_Gen`          | `UDINT`                                 | 0                |
| Output      | `sCurrentSequence_Gen`            | `STRING`                                | ‘’               |
| Output      | `stOutputs_Gen1`                  | stDevicesOutputsGen\_PowerFeedOptimizer |                  |
| Output      | `stOutputs_Gen2`                  | stDevicesOutputsGen\_PowerFeedOptimizer |                  |
| Output      | `stOutputs_Gen3`                  | stDevicesOutputsGen\_PowerFeedOptimizer |                  |
| Output      | `stOutputs_Gen4`                  | stDevicesOutputsGen\_PowerFeedOptimizer |                  |
| Output      | `eOperationalCondition_Gen`       | eRedundance3\_OperationalMode           |                  |
| Output      | `xErr`                            | `BOOL`                                  | FALSE            |
| Output      | `sErrorCodes_General`             | `STRING`                                | ‘’               |
| Output      | `sErrorCodes_Con`                 | `STRING`                                | ‘’               |
| Output      | `sErrorCodes_Gen`                 | `STRING`                                | ‘’               |
| Input Const | `tOffDelayCmd_Gen4`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Gen4`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Gen4`     | `REAL`                                  | -10.0            |
| Input Const | `rMinNomElectricalPower_Gen4`     | `REAL`                                  | 0.0              |
| Input Const | `tOffDelayCmd_Gen3`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Gen3`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Gen3`     | `REAL`                                  | -10.0            |
| Input Const | `rMinNomElectricalPower_Gen3`     | `REAL`                                  | 0.0              |
| Input Const | `tOffDelayCmd_Gen2`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Gen2`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Gen2`     | `REAL`                                  | -10.0            |
| Input Const | `rMinNomElectricalPower_Gen2`     | `REAL`                                  | 0.0              |
| Input Const | `tOffDelayCmd_Gen1`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Gen1`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Gen1`     | `REAL`                                  | -10.0            |
| Input Const | `rMinNomElectricalPower_Gen1`     | `REAL`                                  | 0.0              |
| Input Const | `tOffDelayCmd_Con4`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Con4`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Con4`     | `REAL`                                  | 10.0             |
| Input Const | `rMinNomElectricalPower_Con4`     | `REAL`                                  | 0.0              |
| Input Const | `tOffDelayCmd_Con3`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Con3`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Con3`     | `REAL`                                  | 10.0             |
| Input Const | `rMinNomElectricalPower_Con3`     | `REAL`                                  | 0.0              |
| Input Const | `tOffDelayCmd_Con2`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Con2`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Con2`     | `REAL`                                  | 10.0             |
| Input Const | `rMinNomElectricalPower_Con2`     | `REAL`                                  | 0.0              |
| Input Const | `tOffDelayCmd_Con1`               | `TIME`                                  | TIME#10s0ms      |
| Input Const | `tOnDelayCmd_Con1`                | `TIME`                                  | TIME#10s0ms      |
| Input Const | `rMaxNomElectricalPower_Con1`     | `REAL`                                  | 10.0             |
| Input Const | `rMinNomElectricalPower_Con1`     | `REAL`                                  | 0.0              |
| Input Const | `rTn_Gen`                         | `REAL`                                  | 180.0            |
| Input Const | `rTn_Con`                         | `REAL`                                  | 180.0            |
| Input Const | `tTimeConstant_EP`                | `TIME`                                  | TIME#15s0ms      |
| Input Const | `rInitValue_EP`                   | `REAL`                                  | 0.0              |
| Input Const | `eInitial_EP`                     | eInit                                   | eInit.InputValue |
| Input Const | `tInitDelay_EP`                   | `TIME`                                  | TIME#5s0ms       |
| Input Const | `xConOperatingHours_Gen`          | `BOOL`                                  | TRUE             |
| Input Const | `xEnFb_Gen`                       | `BOOL`                                  | FALSE            |
| Input Const | `wTolerance_Gen`                  | `WORD`                                  | 100              |
| Input Const | `xConOperatingHours_Con`          | `BOOL`                                  | TRUE             |
| Input Const | `xEnFb_Con`                       | `BOOL`                                  | FALSE            |
| Input Const | `wTolerance_Con`                  | `WORD`                                  | 100              |
| Input Const | `tTimeUpdateDeviceOutputs`        | `TIME`                                  | TIME#3s0ms       |


---

# 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/optimizer/powerfeedoptimizer.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.
