> 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/hvac-library/functionblocks/counter/impulsecounter.md).

# ImpulseCounter

## `ImpulseCounter` (FB)

FUNCTION\_BLOCK ImpulseCounter

### Kurzbeschreibung

> Zähler für Eingangsimpulse mit Rücksetzeingang und einstellbarer Reduktion

### Darstellung

<figure><img src="https://879424349-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>

### Schnittstellen

#### Eingänge

| Name       | Datentyp | Wertebereich | Initialwert | Funktion        |
| ---------- | -------- | ------------ | ----------- | --------------- |
| *xImpulse* | BOOL     |              |             | Zählereingang   |
| *xReset*   | BOOL     |              | FALSE       | Rücksetzeingang |

#### Ausgänge

| Name                | Datentyp        | Wertebereich | Initialwert | Funktion                                           |
| ------------------- | --------------- | ------------ | ----------- | -------------------------------------------------- |
| *udiImpulseCounter* | UDINT           |              |             | Impulszähler                                       |
| *udiEnergy*         | UDINT           |              |             | Impulszähler nach Reduktion                        |
| *dtLastImpulse*     | DATE\_AND\_TIME |              |             | Datum/-zeitpunkt des Ende des letzten Zählimpulses |

#### Sollwerte / Parameter

| Name                | Datentyp | Wertebereich | Initialwert | Funktion         |
| ------------------- | -------- | ------------ | ----------- | ---------------- |
| **udiEnergyFactor** | UDINT    |              | 1           | Reduktionsfaktor |

### Funktionsbeschreibung

#### Allgemeines

Dieser Funktionsbaustein dient zur Zählung der Impulse (= ansteigende Flanken) am Zähler-Eingang *xImpulse* im Rahmen der technischen Grenzen.\
Der Zählerstand wird am Ausgang *udiImpulseCounter* angezeigt.\
\
Überschreitet / erreicht der Zählerstand *udiImpulseCounter* den Grenzwert **udiEnergyFactor**, so wird der der Ausgang *udiEnergy* inkrementiert.\
Anschließend wird der Ausgang *udiImpulseCounter* auf 0 zurück gesetzt.\
\
Die Ausgänge *udiImpulseCounter* und **udiEnergy** werden auf 0 zurück gesetzt, solange am Eingang *xReset* eine ansteigende Flanke erkannt wird.\
\
Am Ausgang *dtLastImpulse* steht nach jeder ansteigenden Flanke am Eingang *xImpulse* das aktuelle Datum / die aktuelle Uhrzeit zur Verfügung.\
Am Ausgang *dtLastImpulse* steht bei allen anderen Zuständen am Eingang *xImpulse* das Datum / die Uhrzeit am Ende der letzten ansteigenden Flanke zur Verfügung.\
Am Ausgang *dtLastImpulse* wird vor der ersten ansteigenden Flanke der Initialisierungswert DT#1970-1-1-0.0.0 ausgegeben.

> **Wertebereiche der Ausgänge&#x20;*****udiImpulseCounter*****&#x20;und&#x20;*****udiEnergy***
>
> Gültige Zählerstände befinden sich innerhalb der Grenzen 0 und 4294967295.\
> Die Inkrementierung des Zählerstandes 4294967295 setzt den Zählerstand auf 0 zurück.\
> Anschliessend wird der Zählerstand wieder fortlaufend inkrementiert.
>
> **Reduktionsfaktor udiEnergyFactor**
>
> Der Reduktionsfaktor **udiEnergyFactor** wird nach jeder Eingabe des Wertes 0 mit dem Wert 1 überschrieben.
>
> **Beispiel - Reduktionsfaktor**
>
> *udiImpulseCounter* = 9, **udiEnergy** = 0, **udiEnergyFactor** = 10\
> \
> Nach einer ansteigenden Flanke am Eingang *xImpulse* verändern sich die Zählerstände wie folgt:\
> \
> *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/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.
