> For the complete documentation index, see [llms.txt](https://support.powerio.com/hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/counter/operatinghours.md).

# OperatingHours

## `OperatingHours` (FB)

FUNCTION\_BLOCK OperatingHours

### Short description

> Counter for operating hours and switch-on events

### Representation

<figure><img src="/files/50bd05c3b8fcb04615d90d027e4c69c5f2724146" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name     | Data type | Value range | Initial value | Function               |
| -------- | --------- | ----------- | ------------- | ---------------------- |
| *xFb*    | BOOL      |             |               | Counter - input        |
| *xReset* | BOOL      |             | FALSE         | Enable - input - reset |

#### Outputs

| Name                | Data type       | Value range | Initial value | Function                                          |
| ------------------- | --------------- | ----------- | ------------- | ------------------------------------------------- |
| *udiOperatingHours* | UDINT           |             |               | Counter - output - operating hours                |
| *udiCountFb*        | UDINT           |             |               | Counter - output - switch-ons                     |
| *dtLastFb*          | DATE\_AND\_TIME |             |               | Date/time of the end of the last counting process |

### Function description

#### General

This function block is used to record the operating hours and switch-on events at the counter input *xFb*.\
The outputs *udiOperatingHours* and *udiCountFb* are reset to 0 as soon as a rising edge is detected at the input *xReset* A counting process is active as long as the counter input *xFb* is TRUE.\
The output *udiOperatingHours* shows the cumulative duration of the counting processes since the last reset operation in hours.\
The output *udiCountFb* is incremented with each rising edge at the input *xFb* is incremented.\
\
At the output *dtLastFb* the current date / time is available during the counting process.\
At the output *dtLastFb* the date / time at the end of the last counting process is available outside the counting process.\
At the output *dtLastFb* the initialization value DT#1970-1-1-0.0.0 is output before the first counting process.

> **Value ranges of the outputs&#x20;*****udiOperatingHours*****&#x20;and&#x20;*****udiCountFb***
>
> Valid counter values are within the limits 0 and 4294967295.\
> Incrementing the counter value 4294967295 resets the counter value to 0.\
> Subsequently the counter value is incremented continuously again.
>
> **Prerequisite for the use of the OperatingHours function block**
>
> The use of the TimeRead2 function block is required for correct operation.
>
> **Write access to the counter values**
>
> Via the path 'InstanceName.\_OperatingHours.udiOperatingHours' or 'InstanceName.\_OperatingHours.udiCountFb' write access to both counters is possible.

### CODESYS

InOut:

| Scope  | Name                | Type    | Initial |
| ------ | ------------------- | ------- | ------- |
| Input  | `xFb`               | `BOOL`  |         |
| Input  | `xReset`            | `BOOL`  | FALSE   |
| Output | `udiOperatingHours` | `UDINT` |         |
| Output | `udiCountFb`        | `UDINT` |         |
| Output | `dtLastFb`          | `DT`    |         |

Methods:

> mReset

Structure:

* mReset (Method)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/counter/operatinghours.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
