> 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/impulsecounter.md).

# ImpulseCounter

## `ImpulseCounter` (FB)

FUNCTION\_BLOCK ImpulseCounter

### Short description

> Counter for input pulses with reset input and adjustable reduction

### Representation

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

### Interfaces

#### Inputs

| Name       | Data type | Value range | Initial value | Function      |
| ---------- | --------- | ----------- | ------------- | ------------- |
| *xImpulse* | BOOL      |             |               | Counter input |
| *xReset*   | BOOL      |             | FALSE         | Reset input   |

#### Outputs

| Name                | Data type       | Value range | Initial value | Function                                        |
| ------------------- | --------------- | ----------- | ------------- | ----------------------------------------------- |
| *udiImpulseCounter* | UDINT           |             |               | Pulse counter                                   |
| *udiEnergy*         | UDINT           |             |               | Pulse counter after reduction                   |
| *dtLastImpulse*     | DATE\_AND\_TIME |             |               | Date/time of the end of the last counting pulse |

#### Setpoints / Parameters

| Name                | Data type | Value range | Initial value | Function         |
| ------------------- | --------- | ----------- | ------------- | ---------------- |
| **udiEnergyFactor** | UDINT     |             | 1             | Reduction factor |

### Functional description

#### General

This function block serves to count the pulses (= rising edges) at the counter input *xImpulse* within the technical limits.\
The counter value is displayed at the output *udiImpulseCounter* displayed.\
\
If the counter value exceeds / reaches *udiImpulseCounter* the limit value **udiEnergyFactor**, then the output *udiEnergy* incremented.\
Subsequently, the output *udiImpulseCounter* is reset to 0.\
\
The outputs *udiImpulseCounter* and **udiEnergy** are reset to 0 as long as at the input *xReset* a rising edge is detected.\
\
At the output *dtLastImpulse* after each rising edge at the input *xImpulse* the current date / current time is available.\
At the output *dtLastImpulse* is available in all other states at the input *xImpulse* the date / time at the end of the last rising edge is available.\
At the output *dtLastImpulse* before the first rising edge, the initialization value DT#1970-1-1-0.0.0 is output.

> **Value ranges of the outputs&#x20;*****udiImpulseCounter*****&#x20;and&#x20;*****udiEnergy***
>
> Valid counter values are within the limits 0 and 4294967295.\
> Incrementing the counter value 4294967295 resets the counter value to 0.\
> Afterwards, the counter value is incremented continuously again.
>
> **Reduction factor udiEnergyFactor**
>
> The reduction factor **udiEnergyFactor** is overwritten with the value 1 after each input of the value 0.
>
> **Example - reduction factor**
>
> *udiImpulseCounter* = 9, **udiEnergy** = 0, **udiEnergyFactor** = 10\
> \
> After a rising edge at the input *xImpulse* the counter values change as follows:\
> \
> *udiImpulseCounter* = 0, **udiEnergy** = 1, **udiEnergyFactor** = 10

### CODESYS

InOut:

| Scope       | Name                | Type    | Initial |
| ----------- | ------------------- | ------- | ------- |
| Input       | `xImpulse`          | `BOOL`  |         |
| Input       | `xReset`            | `BOOL`  | FALSE   |
| Input Const | `udiEnergyFactor`   | `UDINT` |         |
| Output      | `udiImpulseCounter` | `UDINT` |         |
| Output      | `udiEnergy`         | `UDINT` |         |
| Output      | `dtLastImpulse`     | `DT`    |         |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
