# TrigGen

## `TrigGen` (FB)

FUNCTION\_BLOCK TrigGen

### Short description

> Pulse generation with adjustable time interval.

### Representation

<figure><img src="/files/26d617faa559b3f334ffdb1383adaccb2188064c" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name        | Data type | Value range | Initial value | Function                     |
| ----------- | --------- | ----------- | ------------- | ---------------------------- |
| *xEn*       | BOOL      |             |               | Enable input                 |
| *wInterval* | WORD      |             |               | Time value for time interval |
| *eTimeBase* | eTimeMS   |             |               | Time base for time interval  |
| *xEnImp*    | BOOL      |             |               | Option enable 1st pulse      |

#### Outputs

| Name       | Data type | Value range | Initial value | Function                        |
| ---------- | --------- | ----------- | ------------- | ------------------------------- |
| *xTrig*    | BOOL      |             |               | Pulse output                    |
| *tNextImp* | TIME      |             |               | Remaining time until next pulse |

### Functional description

#### General

At the pulse output *xTrig* pulses with a duration of one program cycle and a time interval of (*wInterval* multiplied by *eTimeBase*) are generated cyclically if the enable input *xEn* is active.

> **Limitation of the maximum time interval**
>
> The time interval is limited to a maximum of 48 days to avoid an internal value overflow.
>
> **Example for calculating the time interval**
>
> *wIntervall* = 1000, *eTimeBase* = Millisecond, pulses are generated at a time interval of 1000 ms.

#### Enable 1st pulse *xEnImp*

With the option active (*xEnImp* = TRUE) the 1st pulse is generated immediately after the enable *xEn* is activated.\
With the option not active (*xEnImp* = FALSE) the 1st pulse is generated after the enable *xEn* after the time interval has elapsed.

<figure><img src="/files/2cb59301111fce4d9e311b8a72ef79ca60625103" alt=""><figcaption></figcaption></figure>

#### Remaining time until next pulse *tNextImp*

This output shows the remaining time until the next pulse if the enable input (\*xEn = TRUE) is active.\
In all other situations the constant 0.0 is shown.

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

### Codesys

InOut:

| Scope  | Name        | Type    |
| ------ | ----------- | ------- |
| Input  | `xEn`       | `BOOL`  |
| Input  | `wInterval` | `WORD`  |
| Input  | `eTimeBase` | eTimeMS |
| Input  | `xEnImp`    | `BOOL`  |
| Output | `xTrig`     | `BOOL`  |
| Output | `tNextImp`  | `TIME`  |


---

# 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/binary/triggen.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.
