# Redundance4

## `Redundance4` (FB)

FUNCTION\_BLOCK Redundance4

### Short description

> Redundant control of 0 - 4 identical devices\
> Influencing factors: demands, operating hours, operating and fault states\
> Typical application: determination of leader and follower devices

### Representation

<figure><img src="/files/8de64a33925bc5697640832e0a1aca929aeae776" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name                     | Data type | Value range | Initial value | Function                                                   |
| ------------------------ | --------- | ----------- | ------------- | ---------------------------------------------------------- |
| *wActiveNumberOfDevices* | WORD      |             | 0             | Number of active devices (0 - 4)                           |
| *xFb1*                   | BOOL      |             | FALSE         | Running - Device 1 (TRUE = running)                        |
| *xFb2*                   | BOOL      |             | FALSE         | Running - Device 2 (TRUE = running)                        |
| *xFb3*                   | BOOL      |             | FALSE         | Running - Device 3 (TRUE = running)                        |
| *xFb4*                   | BOOL      |             | FALSE         | Running - Device 4 (TRUE = running)                        |
| *xAlarm1*                | BOOL      |             | TRUE          | Fault - Device 1 (TRUE = fault)                            |
| *xAlarm2*                | BOOL      |             | TRUE          | Fault - Device 2 (TRUE = fault)                            |
| *xAlarm3*                | BOOL      |             | TRUE          | Fault - Device 3 (TRUE = fault)                            |
| *xAlarm3*                | BOOL      |             | TRUE          | Fault - Device 4 (TRUE = fault)                            |
| *uiOperatingHours1*      | UDINT     |             | 0             | Operating hours - Device 1                                 |
| *uiOperatingHours2*      | UDINT     |             | 0             | Operating hours - Device 2                                 |
| *uiOperatingHours3*      | UDINT     |             | 0             | Operating hours - Device 3                                 |
| *uiOperatingHours4*      | UDINT     |             | 0             | Operating hours - Device 4                                 |
| *xUpdate*                | BOOL      |             |               | Trigger recalculation of the sequence on every rising edge |

#### Outputs

| Name                          | Data type                     | Value range | Initial value | Function                                         |
| ----------------------------- | ----------------------------- | ----------- | ------------- | ------------------------------------------------ |
| *udiCurrentSequence*          | UDINT                         |             | 0             | Current device sequence as integer               |
| *sCurrentSequence*            | STRING                        |             | ‘’            | Current device sequence as string                |
| *wNumberOfOperationalDevices* | WORD                          |             | 0             | Number of operational devices                    |
| *xCmd1*                       | BOOL                          |             | FALSE         | Enable - Device 1 (TRUE = enable)                |
| *xCmd2*                       | BOOL                          |             | FALSE         | Enable - Device 2 (TRUE = enable)                |
| *xCmd3*                       | BOOL                          |             | FALSE         | Enable - Device 3 (TRUE = enable)                |
| *xCmd4*                       | BOOL                          |             | FALSE         | Enable - Device 4 (TRUE = enable)                |
| *wPrio1*                      | WORD                          |             | 0             | Current priority of device 1 (0 = none, 1 - 3)   |
| *wPrio2*                      | WORD                          |             | 0             | Current priority of device 2 (0 = none, 1 - 3)   |
| *wPrio3*                      | WORD                          |             | 0             | Current priority of device 3 (0 = none, 1 - 3)   |
| *wPrio4*                      | WORD                          |             | 0             | Current priority of device 4 (0 = none, 1 - 3)   |
| *xErr*                        | BOOL                          |             | FALSE         | Output - Fault                                   |
| *eOperationalCondition*       | eRedundance3\_OperationalMode |             |               | Number / name of the current operating condition |

#### Setpoints / parameters

| Name                   | Data type | Value range | Initial value | Function                                                                                                         |
| ---------------------- | --------- | ----------- | ------------- | ---------------------------------------------------------------------------------------------------------------- |
| **xConOperatingHours** | BOOL      |             | TRUE          | FALSE = follow switching enabled only by input xUpdate, TRUE = follow switching automatically by operating hours |
| **xEnFb**              | BOOL      |             | TRUE          | FALSE = switching by enable (xCmdX), TRUE = switching by running signal (xFbX)                                   |
| **wTolerance**         | WORD      |             | 100           | Threshold - operating hours difference for direct follow change in partial load operation                        |

### Function description

#### General

This function block is used for the redundant control of 0 - 4 identical devices depending on the influencing variables\
Demands (*wActiveNumberOfDevices*), operating hours (*uiOperatingHours*), operating states (*xFb*) and\
fault states (*xAlarm*).

#### Input *wActiveNumberOfDevices*

This input is used to set the number of devices that should currently be used.\
Permissible range: 0 - 4

#### Input *xUpdate*

Each rising edge on this input triggers a recalculation of the current device sequence.\
Boundary conditions: *xConOperationHours* = FALSE, operating hours difference = 0 hours.

#### Output *udiCurrentSequence*

This output always shows 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, etc.\
Example: *udiCurrentSequence* = 145 means: Device 1 = priority 1, Device 4 = priority 2 and Device 5 = priority 3

#### Output *sCurrentSequence*

This output always shows the current device sequence as a string with delimiters. The same applies regarding priorities as for the output *udiCurrentSequence*.\
Example: *sdiCurrentSequence* = ‘1-4-5’ means: Device 1 = priority 1, Device 4 = priority 2 and Device 5 = priority 3

#### Output *wNumberOfOperationalDevices*

This output always indicates the number of operational devices.

#### Output Fault *xErr*

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

1. *wActiveNumberOfDevices* > wTotalMumberOfDevices

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

#### Output *eOperationalCondition*

This output always represents the current load situation (idle, partial load, full load) depending on the setpoint / parameter **xEnFb** thereof.\
**xEnFb** = FALSE: The enable outputs ***xCmd*** of the operational devices are evaluated / considered.\
**xEnFb** = TRUE: The operating states ***xFb*** of the operational devices are evaluated / considered.\
Example: **xEnFb** = TRUE and *xFb1* = TRUE and *xFb2* = TRUE: Output = *PartLoad\_Inputs\_Fb*

#### Setpoint / parameters **xConOperatingHours**

**xConOperatingHours** = FALSE: Switching of the device sequence is triggered only by a rising edge at input *xUpdate* .\
**xConOperatingHours** = TRUE: Switching of the device sequence is triggered depending on the operating hours, the running signals (when **xEnFb** = TRUE)\
and the enables (when **xEnFb** = FALSE) .

#### Setpoint / parameters **xEnFb**

**xEnFb** = FALSE: The enable outputs ‘xCmd’ of the operational devices are evaluated / considered.\
**xEnFb** = TRUE: The running states ‘xFb’ of the operational devices are evaluated / considered.

#### Setpoint / parameters **wTolerance**

This setpoint determines the maximum operating hours difference before switching the device sequence due to operating hours.

#### Determination of the device sequence

A switch of the device sequence can generally only take place if at least one of the following conditions is met:

1. The fault state of at least one device has changed (high priority)
2. The operating hours of at least one operational device have changed (low priority)

#### Definition - idle:

xEnFb = FALSE: The enable outputs ‘xCmd’ of all operational devices are inactive (= FALSE)\
xEnFb = TRUE: The operating feedbacks ‘xFb’ of all operational devices are inactive (= FALSE)

#### Definition - full load:

xEnFb = FALSE: The enable outputs ‘xCmd’ of all operational devices are active (= TRUE)\
xEnFb = TRUE: The operating feedbacks ‘xFb’ of all operational devices are active (= TRUE)

#### Definition - partial load:

xEnFb = FALSE: The number of enable outputs ‘xCmd‘ of all operational devices in the active state (= TRUE) is greater than/equal to 1 and less than the number of all operational devices\
xEnFb = FALSE: The number of operating feedbacks ‘xFb‘ of all operational devices in the active state (= TRUE) is greater than/equal to 1 and less than the number of all operational devices\
\
\
\
High-priority switching (= immediate) depending on fault states (inputs xAlarm)\
\
The fault state of each device in the range 1 - 4 is recorded cyclically and evaluated for changes.\
Any faulty device in the range 1 - 4 (input xAlarm = TRUE) is no longer operationally ready.\
Any change in the fault state of at least one device in the range 1 - 4 triggers an immediate recalculation of the device sequence.\
\
\
\
Low-priority switching depending on operating hours (inputs udiOperationHours), operating states (inputs xFb)\
and enable outputs (outputs \*xCmd) of devices 1 - 4.\
\
The operating hours of each operational device in the range 1 - 4 are recorded cyclically and evaluated for changes.\
The operating states and enable outputs of each operational device in the range 1 - 3 are recorded cyclically.\
The recalculation of the device sequence takes place as soon as one of the situations described below is given:\
\
\
\
Situation 1 (xConOperationHours = FALSE, rising edge at input xUpdate)\
\
A recalculation of the device sequence takes place with an operating hour difference of 0 hours, i.e. the non-faulty device with the lowest number of operating hours\
has the highest priority (in the event of equal operating hours, the device with the lower number has the higher priority).\
\
\
\
Situation 2 (xConOperationHours = TRUE, idle or full load)\
\
In idle or under full load, a recalculation of the device sequence takes place with an operating hour difference of 0 hours, i.e. the non-faulty device with the lowest number of operating hours has the highest priority (in the event of equal operating hours, the device with the lower number has the higher priority).

\
The recalculation of the device sequence is triggered if the number of operating hours of at least one operational device has changed.\
\
\
\
Situation 3 (xConOperationHours = TRUE, partial load)\
\
When first switching to partial load operation, a recalculation of the device sequence takes place with an operating hour difference of 0 hours, i.e. the non-faulty device with the lowest number of operating hours has the highest priority (in the event of equal operating hours, the device with the lower number has the higher priority).\
\
In regular partial load operation, a recalculation of the device sequence takes place with an operating hour difference of wTolerance hours.\
The recalculation of the device sequence is triggered if the number of operating hours of at least one operational device has changed.

#### Enable outputs xCmd

\
The states of the outputs of the devices in the range 1 - 4 are finally determined as follows:\
\
The enable outputs of the operational devices in the range 1 - 4 are activated if their current priority <= the number of\
requested devices (input wActiveNumberOfDevices).\
The enable outputs of the operational devices in the range 1 - 4 are deactivated if their current priority > the number of\
requested devices (input wActiveNumberOfDevices).

#### Priority outputs *wPrio*

\
The priority outputs of each device always contain the current priority in the range 0 - 4.\
\
Priority = 0: The device has no or an invalid priority\
Priority = 1: The device has the highest priority\
Priority = 2: The device has the second highest priority\
Priority = 3: The device has the third highest priority\
Priority = 4: The device has the fourth highest priority

### CODESYS

InOut:

| Scope       | Name                          | Type                          | Initial |
| ----------- | ----------------------------- | ----------------------------- | ------- |
| Input       | `wActiveNumberOfDevices`      | `WORD`                        | 0       |
| Input       | `xFb1`                        | `BOOL`                        | FALSE   |
| Input       | `xFb2`                        | `BOOL`                        | FALSE   |
| Input       | `xFb3`                        | `BOOL`                        | FALSE   |
| Input       | `xFb4`                        | `BOOL`                        | FALSE   |
| Input       | `xAlarm1`                     | `BOOL`                        | TRUE    |
| Input       | `xAlarm2`                     | `BOOL`                        | TRUE    |
| Input       | `xAlarm3`                     | `BOOL`                        | TRUE    |
| Input       | `xAlarm4`                     | `BOOL`                        | TRUE    |
| Input       | `udiOperatingHours1`          | `UDINT`                       | 0       |
| Input       | `udiOperatingHours2`          | `UDINT`                       | 0       |
| Input       | `udiOperatingHours3`          | `UDINT`                       | 0       |
| Input       | `udiOperatingHours4`          | `UDINT`                       | 0       |
| Input       | `xUpdate`                     | `BOOL`                        |         |
| Input Const | `xConOperatingHours`          | `BOOL`                        | TRUE    |
| Input Const | `xEnFb`                       | `BOOL`                        | FALSE   |
| Input Const | `wTolerance`                  | `WORD`                        | 100     |
| Output      | `udiCurrentSequence`          | `UDINT`                       | 0       |
| Output      | `sCurrentSequence`            | `STRING`                      | ‘’      |
| Output      | `wNumberOfOperationalDevices` | `WORD`                        | 0       |
| Output      | `xCmd1`                       | `BOOL`                        | FALSE   |
| Output      | `xCmd2`                       | `BOOL`                        | FALSE   |
| Output      | `xCmd3`                       | `BOOL`                        | FALSE   |
| Output      | `xCmd4`                       | `BOOL`                        | FALSE   |
| Output      | `wPrio1`                      | `WORD`                        | 0       |
| Output      | `wPrio2`                      | `WORD`                        | 0       |
| Output      | `wPrio3`                      | `WORD`                        | 0       |
| Output      | `wPrio4`                      | `WORD`                        | 0       |
| Output      | `xErr`                        | `BOOL`                        | FALSE   |
| Output      | `eOperationalCondition`       | eRedundance3\_OperationalMode |         |


---

# 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/general/redundance4.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.
