# CTime

## `CTime` (FB)

FUNCTION\_BLOCK CTime

### Short description

> Conversion of a time input (UDINT) into a time output (TIME). The scaling for the time input can be selected. Automatic calculation of min/max limits for the input as well as monitoring of the input.

### Representation

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

### Interfaces

#### Inputs

#### Outputs

| Name         | Data type | Value range      | Initial value | Function                                      |
| ------------ | --------- | ---------------- | ------------- | --------------------------------------------- |
| *tOutTime*   | TIME      | 0 … 4294967295ms |               | Time value in TIME format                     |
| *udiMinVisu* | UDINT     |                  |               | Display of **tMinTime** for the visualization |
| *udiMaxVisu* | UDINT     |                  |               | Display of **tMaxTime** for the visualization |

#### Setpoints / parameters

| Name           | Data type | Value range          | Initial value | Function                                                              |
| -------------- | --------- | -------------------- | ------------- | --------------------------------------------------------------------- |
| **udiTime**    | UDINT     | 0 … 4294967295       |               | Time input (absolute limits: 0..7 days) depending on scaling          |
| **eTimeScale** | eTime     | Second, Minute, Hour | eTime.Second  | Definition of the scaling of the time input (seconds, minutes, hours) |
| **tMinTime**   | TIME      | 0 … 4294967295ms     | 0s            | Lower limit for the time input **udiTime**                            |
| **tMaxTime**   | TIME      | 0 … 4294967295ms     | 2h            | Upper limit for the time input **udiTime**                            |

### Function description

#### General

This function block is used to convert a time input **udiTime** into a time output *tOutTime*.\
The scaling for the time input **udiTime** is done via the setpoint and parameters **eTimeScale**.\
The time input is absolutely limited to a value range of 0 … 7 days.\
The time input is limited by a lower limit **tMinTime** and an upper limit **tMaxTime** as well, both limits are also subject to the scaling.\
The time output *tOutTime* is correspondingly also limited to the range **tMinTime** - **tMaxTime** .\
If the lower limit exceeds **tMinTime** the upper limit **tMaxTime**, the lower limit **tMinTime** is reduced to the upper limit.\
This block can for example be used for input in a visualization.\\

### Visualization

Matching visualization element from the HVACV Visu Library: **CTime** and **CTime\_single\_input**

#### Representation

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

#### Interfaces visual element

| Name             | Data type | Type         | Initial value | Function                                                                                                |
| ---------------- | --------- | ------------ | ------------- | ------------------------------------------------------------------------------------------------------- |
| **FB\_CTime**    | CTime     | VAR\_IN\_OUT |               | Enter FB instance CTime here e.g. PRG.CTime                                                             |
| **sDialogTitle** | STRING    | VAR\_INPUT   |               | Enter the title in string format e.g.: 'Input room temperature' - appears on the numpad during entry.   |
| **iFieldSizeL**  | INT       | VAR\_INPUT   | 0             | Field enlarges by the number of entered pixels to the left. Required to display long numbers or units.  |
| **iFieldSizeR**  | INT       | VAR\_INPUT   | 0             | Field enlarges by the number of entered pixels to the right. Required to display long numbers or units. |

The unit seconds 's', minutes 'm' or hours 'h' is automatically adjusted via the setting in the FB CTime. The MIN and MAX input limits are also automatically generated by the FB and adapted in the visual element. Can be changed at runtime! || Note: VAR\_IN\_OUT interfaces must be assigned, VAR\_INPUT are optional. ||

The visualization element **CTime\_single\_input** works like **CTime** however all inputs must be entered separately via the interfaces. Thus you can also use this visualization element without your CTime block.

#### Interfaces Visu-Element CTime\_single\_input

| Name             | Data type  | Type         | Initial value | Function                                                                                                |
| ---------------- | ---------- | ------------ | ------------- | ------------------------------------------------------------------------------------------------------- |
| **udiTime**      | UDINT      | VAR\_IN\_OUT |               | Enter the UDINT variable here.                                                                          |
| **eTimeScale**   | HVAC.eTime | VAR\_INPUT   |               | Here the enum eTimeScale can be entered. Displays whether second, minute or hour.                       |
| **udiMinVisu**   | UDINT      | VAR\_INPUT   | 0             | Here the MIN input limit can be entered. Inputs below it will not be accepted by the visualization.     |
| **udiMaxVisu**   | UDINT      | VAR\_INPUT   | 7200          | Here the MAX input limit can be entered. Inputs above it will not be accepted by the visualization.     |
| **sDialogTitle** | STRING     | VAR\_INPUT   |               | Enter the title in string format e.g.: 'Input post-run time' - appears on the numpad during entry.      |
| **iFieldSizeL**  | INT        | VAR\_INPUT   | 0             | Field enlarges by the number of entered pixels to the left. Required to display long numbers or units.  |
| **iFieldSizeR**  | INT        | VAR\_INPUT   | 0             | Field enlarges by the number of entered pixels to the right. Required to display long numbers or units. |

### CODESYS

InOut:

| Scope       | Name         | Type    | Initial        |
| ----------- | ------------ | ------- | -------------- |
| Input Const | `tMaxTime`   | `TIME`  | TIME#120m0s0ms |
| Input Const | `tMinTime`   | `TIME`  | TIME#0ms       |
| Input Const | `eTimeScale` | eTime   | eTime.Second   |
| Input Const | `udiTime`    | `UDINT` |                |
| Output      | `tOutTime`   | `TIME`  |                |
| Output      | `udiMinVisu` | `UDINT` |                |
| Output      | `udiMaxVisu` | `UDINT` |                |
