# OpModeSelect

## `OpModeSelect` (FB)

FUNCTION\_BLOCK OpModeSelect EXTENDS MANASBase IMPLEMENTS IMan

### Short description

> Plant switch for switching between up to 6 operating modes (automatic and 5 manual operating modes)

### Representation

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

### Interfaces

#### Inputs

| Name  | Data type | Value range | Initial value | Function                                       |
| ----- | --------- | ----------- | ------------- | ---------------------------------------------- |
| *xIn* | BOOL      |             | FALSE         | State variable for *xActive* in automatic mode |

#### Outputs

| Name        | Data type | Value range | Initial value | Function                                              |
| ----------- | --------- | ----------- | ------------- | ----------------------------------------------------- |
| *xActive*   | BOOL      |             | FALSE         | Output variable in automatic mode                     |
| *xAutoM0*   | BOOL      |             | FALSE         | Indicator for automatic operating mode                |
| *xManOffM1* | BOOL      |             | FALSE         | Indicator for manual-off operating mode               |
| *xManM2*    | BOOL      |             | FALSE         | Indicator for manual 1 operating mode                 |
| *xManM3*    | BOOL      |             | FALSE         | Indicator for manual 2 operating mode                 |
| *xManM4*    | BOOL      |             | FALSE         | Indicator for manual 3 operating mode                 |
| *xManM5*    | BOOL      |             | FALSE         | Indicator for manual 4 operating mode                 |
| *sActMode*  | STRING    |             |               | Name of the current operating mode (e.g. 'Automatic') |

#### Setpoints / parameters

| Name              | Data type | Value range | Initial value     | Function                                                   |
| ----------------- | --------- | ----------- | ----------------- | ---------------------------------------------------------- |
| **tToggleTime**   | TIME      |             | 2s                | Time delay until operating mode change                     |
| **eMaxMode**      | eOpMode   |             | eOpMode.Mode5     | Definition of the maximum number of manual operating modes |
| **xOpModeToggle** | BOOL      |             | FALSE             | Operating mode toggle                                      |
| **xResAuto**      | BOOL      |             | FALSE             | Reset to automatic mode                                    |
| **xEn**           | BOOL      |             | TRUE              | Enable                                                     |
| **sTitle**        | STRING    |             | 'Operating mode ' | Name of the plant switch                                   |
| **sTitle2**       | STRING    |             | 'Description '    | Description of the plant switch                            |
| **eMode**         | eOpMode   |             | eOpMode.Mode0     | Current operating state of the plant switch                |
| **sTitleM0**      | STRING    |             | 'Automatic'       | Description of the automatic operating mode                |
| **sTitleM1**      | STRING    |             | 'Manual Off'      | Description of the manual-off operating mode               |
| **sTitleM2**      | STRING    |             | 'Manual 1'        | Description of the manual 1 operating mode                 |
| **sTitleM3**      | STRING    |             | 'Manual 2'        | Description of the manual 2 operating mode                 |
| **sTitleM4**      | STRING    |             | 'Manual 3'        | Description of the manual 3 operating mode                 |
| **sTitleM5**      | STRING    |             | 'Manual 4'        | Description of the manual 4 operating mode                 |

### Function description

#### General

The plant switch is used to switch between **eMaxMode** +1 different operating modes (automatic, manual-off and **eMaxMode** -1 manual operating modes).\
The switching operation is triggered by a rising edge on the setpoint / parameter **xOpModeToggle** triggered.\
The switching is cyclic, i.e. after the last manual operating mode the next switching operation selects the automatic operating mode.\
The operating mode can also be explicitly selected by choosing the setpoint / parameter **eMode** in the range eOpMode.Mode0 - **eMaxMode** take place.\
The current operating mode is represented numerically by the setpoint/parameter **eMode** in the range eOpMode.Mode0 - **eMaxMode** represented.\
It is additionally indicated by the corresponding digital outputs *xAutoM0*, *xManOffM1*, *xManM2*, *xManM3*, etc. represented.

#### State variable *xIn*

| In    | *xActive* | Note                                                     |
| ----- | --------- | -------------------------------------------------------- |
| FALSE | FALSE     | Valid only in automatic mode (**eMode** = eOpMode.Mode0) |
| TRUE  | TRUE      | Valid only in automatic mode (**eMode** = eOpMode.Mode0) |

#### Output variable *xActive*

In automatic mode (**eMode** = eOpMode.Mode0) the output variable follows *xActive* the input variable *xIn*.\
In all other operating modes the state FALSE is always active.

#### Reset to automatic mode

Any rising edge on the setpoint/parameter **xResAuto** activates automatic mode if the setpoint/parameter **xEn** is in the TRUE state.

#### Enable/disable of the switching

The operating mode can only be changed if the setpoint/parameter **xEn** is in the TRUE state.

#### Switching delay **tToggleTime**

The time interval between activation of the operating mode toggle and the actual switch can be set via the setpoint / parameter **tToggleTime** be set.\
The time interval only starts if the operating mode change was initiated via the setpoint/parameter **xOpModeToggle** was made.

#### Operating modes

| **eMode**     | Name of the operating mode | *xIn* | *xActive* | *xAutoM0* | *xManOffM1* | *xManM2* | *xManM3* | *xManM4* | *xManM5* | Note                      |
| ------------- | -------------------------- | ----- | --------- | --------- | ----------- | -------- | -------- | -------- | -------- | ------------------------- |
| eOpMode.Mode0 | **sTitleM0**               | FALSE | FALSE     | TRUE      | FALSE       | FALSE    | FALSE    | FALSE    | FALSE    | Automatic operating mode  |
| eOpMode.Mode0 | **sTitleM0**               | TRUE  | TRUE      | TRUE      | FALSE       | FALSE    | FALSE    | FALSE    | FALSE    | Automatic operating mode  |
| eOpMode.Mode1 | **sTitleM1**               | X     | FALSE     | FALSE     | TRUE        | FALSE    | FALSE    | FALSE    | FALSE    | Manual-off operating mode |
| eOpMode.Mode2 | **sTitleM2**               | X     | FALSE     | FALSE     | FALSE       | TRUE     | FALSE    | FALSE    | FALSE    | Manual 1 operating mode   |
| eOpMode.Mode3 | **sTitleM3**               | X     | FALSE     | FALSE     | FALSE       | FALSE    | TRUE     | FALSE    | FALSE    | Manual 2 operating mode   |
| eOpMode.Mode4 | **sTitleM4**               | X     | FALSE     | FALSE     | FALSE       | FALSE    | FALSE    | TRUE     | FALSE    | Manual 3 operating mode   |
| eOpMode.Mode5 | **sTitleM5**               | X     | FALSE     | FALSE     | FALSE       | FALSE    | FALSE    | FALSE    | TRUE     | Manual 4 operating mode   |

Legend: X = Indeterminate

### Visualization

Matching visualization element from the HVACV Visu Library: **OpModeSelect** **OpModeSelect\_Button**

#### Representation

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

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

#### Visualization element interface OpModeSelect\_Button

| Name                    | Data type         | Type         | Initial value | Function                                                  |
| ----------------------- | ----------------- | ------------ | ------------- | --------------------------------------------------------- |
| **FB\_OpModeSelect\_0** | HVAC.OpModeSelect | VAR\_IN\_OUT |               | Enter FB instance OpModeSelect here e.g. PRG.OpModeSelect |

It is sufficient to place the visualization element OpModeSelect\_Button. Clicking it opens the OpModeSelect dialog in the visualization. The number of operating modes is defined in the FB HVAC.OpModeSelect (eMaxMode) as well as the titles (sTitleM0 to M5) and the dialog title (sTitle and sTitle2). The visualization element automatically adapts to the size of the maximum operating modes.

{% hint style="info" %}
Note: VAR\_IN\_OUT interfaces must be assigned, VAR\_INPUT are optional.
{% endhint %}

### CODESYS

InOut:

| Scope       | Name            | Type     | Initial          |
| ----------- | --------------- | -------- | ---------------- |
| Input       | `xIn`           | `BOOL`   | 0                |
| Input Const | `tToggleTime`   | `TIME`   | TIME#2s0ms       |
| Input Const | `eMaxMode`      | eOpMode  | eOpMode.Mode5    |
| Input Const | `xOpModeToggle` | `BOOL`   | FALSE            |
| Input Const | `xResAuto`      | `BOOL`   | FALSE            |
| Input Const | `xEn`           | `BOOL`   | TRUE             |
| Input Const | `sTitle`        | `STRING` | 'Operating mode' |
| Input Const | `sTitle2`       | `STRING` | 'Description'    |
| Input Const | `eMode`         | eOpMode  | eOpMode.Mode0    |
| Input Const | `sTitleM0`      | `STRING` | 'Automatic'      |
| Input Const | `sTitleM1`      | `STRING` | 'Manual Off'     |
| Input Const | `sTitleM2`      | `STRING` | 'Manual 1'       |
| Input Const | `sTitleM3`      | `STRING` | 'Manual 2'       |
| Input Const | `sTitleM4`      | `STRING` | 'Manual 3'       |
| Input Const | `sTitleM5`      | `STRING` | 'Manual 4'       |
| Output      | `xActive`       | `BOOL`   |                  |
| Output      | `xAutoM0`       | `BOOL`   |                  |
| Output      | `xManOffM1`     | `BOOL`   |                  |
| Output      | `xManM2`        | `BOOL`   |                  |
| Output      | `xManM3`        | `BOOL`   |                  |
| Output      | `xManM4`        | `BOOL`   |                  |
| Output      | `xManM5`        | `BOOL`   |                  |
| Output      | `sActMode`      | `STRING` |                  |
