# Trig

## `Trig` (FB)

FUNCTION\_BLOCK Trig

### Short description

> Edge detection on a binary input signal.\
> Pulse generation on rising / falling or both edges.

### Representation

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

### Interfaces

#### Inputs

| Name  | Data type | Value range | Initial value | Function            |
| ----- | --------- | ----------- | ------------- | ------------------- |
| *xIn* | BOOL      |             |               | Binary input signal |

#### Outputs

| Name     | Data type | Value range | Initial value | Function                                |
| -------- | --------- | ----------- | ------------- | --------------------------------------- |
| *xTrigH* | BOOL      |             |               | Pulse output for rising edges           |
| *xTrigL* | BOOL      |             |               | Pulse output for falling edges          |
| *xTrig*  | BOOL      |             |               | Pulse output for rising / falling edges |

### Function description

#### General

The binary input signal *xIn* is continuously monitored for rising and falling edges.\
On each rising edge, a pulse with a duration of one program cycle is generated at the output. *xTrigH* a pulse with a duration of one program cycle is generated at the output.\
On each falling edge, a pulse with a duration of one program cycle is generated at the output. *xTrigL* a pulse with a duration of one program cycle is generated at the output.\
On each rising / falling edge, a pulse with a duration of one program cycle is generated at the output. *xTrig* a pulse with a duration of one program cycle is generated at the output.

### CODESYS

InOut:

| Scope  | Name     | Type   |
| ------ | -------- | ------ |
| Input  | `xIn`    | `BOOL` |
| Output | `xTrigH` | `BOOL` |
| Output | `xTrigL` | `BOOL` |
| Output | `xTrig`  | `BOOL` |
