# 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 operation |

#### Outputs

| Name        | Data type | Value range | Initial value | Function                                              |
| ----------- | --------- | ----------- | ------------- | ----------------------------------------------------- |
| *xActive*   | BOOL      |             | FALSE         | Output variable in automatic operation                |
| *xAutoM0*   | BOOL      |             | FALSE         | Indicator for operating mode Automatic                |
| *xManOffM1* | BOOL      |             | FALSE         | Indicator for operating mode Manual-Off               |
| *xManM2*    | BOOL      |             | FALSE         | Indicator for operating mode Manual 1                 |
| *xManM3*    | BOOL      |             | FALSE         | Indicator for operating mode Manual 2                 |
| *xManM4*    | BOOL      |             | FALSE         | Indicator for operating mode Manual 3                 |
| *xManM5*    | BOOL      |             | FALSE         | Indicator for operating mode Manual 4                 |
| *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 the operating mode change                 |
| **eMaxMode**      | eOpMode   |             | eOpMode.Mode5     | Definition of the maximum number of manual operating modes |
| **xOpModeToggle** | BOOL      |             | FALSE             | Toggle of operating modes                                  |
| **xResAuto**      | BOOL      |             | FALSE             | Reset to automatic operation                               |
| **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 operating mode Automatic                |
| **sTitleM1**      | STRING    |             | 'Manual Off'      | Description of the operating mode Manual-Off               |
| **sTitleM2**      | STRING    |             | 'Manual 1'        | Description of the operating mode Manual 1                 |
| **sTitleM3**      | STRING    |             | 'Manual 2'        | Description of the operating mode Manual 2                 |
| **sTitleM4**      | STRING    |             | 'Manual 3'        | Description of the operating mode Manual 3                 |
| **sTitleM5**      | STRING    |             | 'Manual 4'        | Description of the operating mode Manual 4                 |

### 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 process 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 switch selects the Automatic mode.\
The operating mode can also be explicitly selected by choosing the setpoint/parameter **eMode** in the range eOpMode.Mode0 - **eMaxMode** be selected.\
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. displayed.\\

#### State variable *xIn*

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

#### Output variable *xActive*

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

#### Reset to automatic operation

Every rising edge on the setpoint/parameter **xResAuto** activates automatic operation if the setpoint/parameter **xEn** is in the TRUE state.\
\\

#### Enable/disable of switching

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

#### Switching delay **tToggleTime**

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

#### 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    | Operating mode Automatic  |
| eOpMode.Mode0 | **sTitleM0**               | TRUE  | TRUE      | TRUE      | FALSE       | FALSE    | FALSE    | FALSE    | FALSE    | Operating mode Automatic  |
| eOpMode.Mode1 | **sTitleM1**               | X     | FALSE     | FALSE     | TRUE        | FALSE    | FALSE    | FALSE    | FALSE    | Operating mode Manual-Off |
| eOpMode.Mode2 | **sTitleM2**               | X     | FALSE     | FALSE     | FALSE       | TRUE     | FALSE    | FALSE    | FALSE    | Operating mode Manual 1   |
| eOpMode.Mode3 | **sTitleM3**               | X     | FALSE     | FALSE     | FALSE       | FALSE    | TRUE     | FALSE    | FALSE    | Operating mode Manual 2   |
| eOpMode.Mode4 | **sTitleM4**               | X     | FALSE     | FALSE     | FALSE       | FALSE    | FALSE    | TRUE     | FALSE    | Operating mode Manual 3   |
| eOpMode.Mode5 | **sTitleM5**               | X     | FALSE     | FALSE     | FALSE       | FALSE    | FALSE    | FALSE    | TRUE     | Operating mode Manual 4   |

Legend: X = Unknown\\

### 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>

#### Interface Visu-Element 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. A click on 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. | | Note: VAR\_IN\_OUT interfaces must be assigned, VAR\_INPUT are optional. | |

### 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` |                  |
