# SwitchTimeS

## `SwitchTimeS` (FB)

FUNCTION\_BLOCK SwitchTimeS

### Short description

> Time switch with 5 adjustable time periods and a binary output.\
> Each time period is defined by an on-time / off-time and a date.

### Representation

<figure><img src="/files/355fda1f47f2534cb11c463b84c9499d4b2e74a1" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name  | Data type | Value range | Initial value | Function     |
| ----- | --------- | ----------- | ------------- | ------------ |
| *xEn* | BOOL      |             |               | Enable input |

#### Outputs

| Name               | Data type | Value range | Initial value | Function                                                   |
| ------------------ | --------- | ----------- | ------------- | ---------------------------------------------------------- |
| *xActive*          | BOOL      |             |               | Display of active time periods                             |
| *todActivatedFrom* | TOD       |             |               | On time of the last active time period of the current day  |
| *todActivatedTo*   | TOD       |             |               | Off time of the last active time period of the current day |

#### Setpoints / parameters

| Name                 | Data type | Value range | Initial value   | Function                       |
| -------------------- | --------- | ----------- | --------------- | ------------------------------ |
| **datCH1\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 1          |
| **todCH1\_TimeFrom** | TOD       |             | TOD#07:00       | On time of time period 1       |
| **todCH1\_TimeTo**   | TOD       |             | TOD#12:00       | Off time of time period 1      |
| **xCH1\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 1 |
| **sCH1\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 1         |
| **datCH2\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 2          |
| **todCH2\_TimeFrom** | TOD       |             | TOD#07:00       | On time of time period 2       |
| **todCH2\_TimeTo**   | TOD       |             | TOD#12:00       | Off time of time period 2      |
| **xCH2\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 2 |
| **sCH2\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 2         |
| **datCH3\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 3          |
| **todCH3\_TimeFrom** | TOD       |             | TOD#07:00       | On time of time period 3       |
| **todCH3\_TimeTo**   | TOD       |             | TOD#12:00       | Off time of time period 3      |
| **xCH3\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 3 |
| **sCH3\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 3         |
| **datCH4\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 4          |
| **todCH4\_TimeFrom** | TOD       |             | TOD#07:00       | On time of time period 4       |
| **todCH4\_TimeTo**   | TOD       |             | TOD#12:00       | Off time of time period 4      |
| **xCH4\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 4 |
| **sCH4\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 4         |
| **datCH5\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 5          |
| **todCH5\_TimeFrom** | TOD       |             | TOD#07:00       | On time of time period 5       |
| **todCH5\_TimeTo**   | TOD       |             | TOD#12:00       | Off time of time period 5      |
| **xCH5\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 5 |
| **sCH5\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 5         |

### Function description

#### General

The current time (date / time) is continuously compared with the 5 defined time periods.\
The display output *xActive* assumes the state TRUE if, with the enable input active (*xEn* = TRUE) at least one of the 5 time periods is active.

> **Prerequisite for the use of the function block SwitchTimeS**
>
> The use of the TimeRead2 function block is required for correct operation.

#### Enable input *xEn*

| *xEn* | *xActive*                             | *todActivatedFrom*                                        | *todActivatedTo*                                           | Note        |
| ----- | ------------------------------------- | --------------------------------------------------------- | ---------------------------------------------------------- | ----------- |
| FALSE | FALSE                                 | unchanged                                                 | unchanged                                                  | FB disabled |
| TRUE  | State dependent on the 5 time periods | On time of the last active time period of the current day | Off time of the last active time period of the current day | FB enabled  |

#### Display output *xActive*

The display output assumes the state TRUE if, with the enable input active (*xEn* = TRUE) at least one of the 5 time periods is active.

| *xActive* | *xEn* | Time period 1 | Time period 2 | Time period 3 | Time period 4 | Time period 5 | Note                            |
| --------- | ----- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------------------------- |
| FALSE     | FALSE | X             | X             | X             | X             | X             | FB disabled                     |
| FALSE     | TRUE  | FALSE         | FALSE         | FALSE         | FALSE         | FALSE         | No time period active           |
| TRUE      | TRUE  | FALSE         | FALSE         | TRUE          | FALSE         | FALSE         | At least one time period active |

#### On time of the last active time period of the current day *todActivatedFrom*

This display output takes the value of the on-time of the last active time period if, with the enable input active (*xEn* = TRUE) the date of the current time matches the date of the time period.\
In all other situations it is not changed.

#### Off time of the last active time period of the current day *todActivatedTo*

This display output takes the value of the off-time of the last active time period if, with the enable input active (*xEn* = TRUE) the date of the current time matches the date of time period 5.\
In all other situations it is not changed.

#### Time periods 1 - 5 (X = 1 .. 5)

Each time period is defined by adjustable data (on-time **todCHX\_TimeFrom**, off-time **todCHX\_TimeTo** and date **datCHX\_Date**) defined\
Additionally an operating mode (**xCHX\_Mode**) as well as a descriptive text (**sCHX\_Notice**) can be specified.\
If the off-time is before the on-time, then for checking the off-time the value of the on-time is used.\
A time period is active if the current date matches the date of the time period and the time is within the time period (**xCHX\_Mode** = TRUE).\
A time period is active if the current date matches the date of the time period and the time is outside the time period (**xCHX\_Mode** = FALSE).

### Visualization

#### Representation

<figure><img src="/files/83d8720455ca51ea5b6bddb9fd5c784862a7e1c5" alt=""><figcaption></figcaption></figure>

#### Interfaces Visu-Element

| Name                | Data type   | Type         | Initial value | Function                                                                                                                                                                                                                                                                                                     |
| ------------------- | ----------- | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **FB\_SwitchTimeS** | SwitchTimeS | VAR\_IN\_OUT |               | Enter FB SwitchTimeS here e.g. PRG.SwitchTimeS                                                                                                                                                                                                                                                               |
| **BMS\_Active**     | BOOL        | VAR\_INPUT   |               | BMS (Building Management System) GLT (building management). If BMS\_Active = TRUE the input / editing of the clocks is disabled because they can then only be set via the BMS. Times can then only be viewed.                                                                                                |
| **DisableInput**    | BOOL        | VAR\_INPUT   |               | DisableInput = TRUE Times of the weekly timers can only be viewed and not edited./// - BMS (Building Management System) GLT (Building control technology). If BMS\_Active = TRUE the input / editing of the timers is disabled because they can then only be set via the BMS. Times can then only be viewed. |

\
Note: VAR\_IN\_OUT interfaces must be assigned, VAR\_INPUT are optional.

### CODESYS

InOut:

| Scope       | Name               | Type     | Initial            |
| ----------- | ------------------ | -------- | ------------------ |
| Input       | `xEn`              | `BOOL`   |                    |
| Input Const | `datCH1_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH1_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH1_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH1_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH1_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH2_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH2_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH2_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH2_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH2_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH3_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH3_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH3_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH3_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH3_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH4_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH4_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH4_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH4_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH4_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH5_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH5_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH5_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH5_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH5_Notice`      | `STRING` | ‘Notice’           |
| Output      | `xActive`          | `BOOL`   |                    |
| Output      | `todActivatedFrom` | `TOD`    |                    |
| Output      | `todActivatedTo`   | `TOD`    |                    |


---

# 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/clock/switchtimes.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.
