# PulseShift

## `PulseShift` (FB)

FUNCTION\_BLOCK PulseShift

### Short description

> Edge-controlled, delayed pulse generation with adjustable pulse duration.

### Representation

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

### Interfaces

#### Inputs

| Name     | Data type | Value range | Initial value | Function                     |
| -------- | --------- | ----------- | ------------- | ---------------------------- |
| *xIN*    | BOOL      |             |               | Binary input                 |
| *tShift* | TIME      |             | T#1s          | Delay time                   |
| *tPT*    | TIME      |             | T#1s          | Duration of the output pulse |

#### Outputs

| Name  | Data type | Value range | Initial value | Function                                                                          |
| ----- | --------- | ----------- | ------------- | --------------------------------------------------------------------------------- |
| *xQ*  | BOOL      |             |               | Pulse output                                                                      |
| *tET* | TIME      |             |               | Time difference between the target duration and the duration of the pulse at *xQ* |

#### Set values / parameters

| Name      | Data type | Value range | Initial value | Function                        |
| --------- | --------- | ----------- | ------------- | ------------------------------- |
| **xTest** | BOOL      |             | FALSE         | Test input to trigger the pulse |

### Function description

#### General

At the pulse output *xQ* is generated after a positive edge at the binary input *xIN* and a subsequent delay time *tShift* with a duration of *tPT* is generated.\
Alternatively, pulse generation without delay can also be triggered by the setpoint / parameter **xTest** is triggered.

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

#### Time output *tET*

When the pulse output is active *xQ* the time difference between the target duration *tPT* and the duration of the pulse at *xQ* is displayed.\
When the pulse output is inactive, *xQ* the value T#0s is always shown.

### CODESYS

InOut:

| Scope       | Name     | Type   | Initial    |
| ----------- | -------- | ------ | ---------- |
| Input       | `xIN`    | `BOOL` |            |
| Input       | `tShift` | `TIME` | TIME#1s0ms |
| Input       | `tPT`    | `TIME` | TIME#1s0ms |
| Input Const | `xTest`  | `BOOL` | FALSE      |
| Output      | `xQ`     | `BOOL` |            |
| Output      | `tET`    | `TIME` |            |
