# StopWatchExt

## `StopWatchExt` (FB)

FUNCTION\_BLOCK StopWatchExt

### Short description

> Measurement of time intervals with plus/minus input and reset capability.\
> Display of the total time (*tElapsed*) and of the total time before the last measurement (*tMeasured*).

### Representation

<figure><img src="/files/a46c67b0131695148be140ac518b9c9c5303849d" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name     | Data type | Value range | Initial value | Function                             |
| -------- | --------- | ----------- | ------------- | ------------------------------------ |
| *xUp*    | BOOL      |             |               | Enable increase of the measured time |
| *xDown*  | BOOL      |             |               | Enable decrease of the measured time |
| *xReset* | BOOL      |             |               | Reset the stopwatch                  |

#### Outputs

| Name         | Data type | Value range | Initial value | Function                                    |
| ------------ | --------- | ----------- | ------------- | ------------------------------------------- |
| *tMeasured*  | TIME      | 0 days      | 0 … 10 days   | Time measured before the last measurement   |
| *tElapsed*   | TIME      | 0 … 10 days |               | Time duration measured since the last reset |
| *xTimeError* | BOOL      |             |               | Display of a stopwatch error                |

### Function description

#### General

This function block is used to measure individual time intervals.\
The counter value is increased if the input *xUp* is active.\
The counter value is decreased if the input *xDown* is active.\
The input *xUp* has priority over the input *xDown*.\
The sum of the measured time intervals is shown at the output *tElapsed* .\
The sum of the measured time intervals before the last measurement is shown at the output *tMeasured* .\
The sum of the measured time intervals must be at most 14400 minutes (= 10 days) and at least 0 minutes.\
Any rising edge on the reset input (*xReset* = FALSE / TRUE) resets the outputs *tElapsed* and *tMeasured* to FALSE regardless of the other states.\
If measurement is not enabled (*xUp* = FALSE and *xDown* = FALSE) the outputs *tElapsed* and *tMeasured* are not changed.

> **Different reaction to an edge on the reset input&#x20;*****xReset***
>
> Input *xUp* = TRUE:\
> Each edge on the reset input resets the outputs *tElapsed* and *tMeasured* to 0. Afterwards the counter value immediately increases again continuously.\
> \
> Input *xDown* = TRUE:\
> Each edge on the reset input resets the outputs *tElapsed* and *tMeasured* to 0.\
> The counter value does not change.\
> The error indication *xTimeError* is activated as long as the input *xDown* remains TRUE in this state.

#### Error indication *xTimeError*

It is used to indicate functional errors (*xTimeError* = TRUE).

| State                                                    | *xTimeError* |
| -------------------------------------------------------- | ------------ |
| no malfunction                                           | FALSE        |
| Measurement time greater than / equal to 14400 minutes   | TRUE         |
| Measurement time less than 1 ms and input *xDown* = TRUE | TRUE         |

### CODESYS

InOut:

| Scope  | Name         | Type   |
| ------ | ------------ | ------ |
| Input  | `xUp`        | `BOOL` |
| Input  | `xDown`      | `BOOL` |
| Input  | `xReset`     | `BOOL` |
| Output | `tMeasured`  | `TIME` |
| Output | `tElapsed`   | `TIME` |
| Output | `xTimeError` | `BOOL` |


---

# 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/time/stopwatchext.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.
