# Limiter

## `Limiter` (FB)

FUNCTION\_BLOCK Limiter

### Short description

> Limit monitoring of an analog value

### Representation

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

### Interfaces

#### Inputs

| Name  | Data type | Value range | Initial value | Function           |
| ----- | --------- | ----------- | ------------- | ------------------ |
| *rIn* | REAL      |             | 0             | Analog value input |

#### Outputs

| Name   | Data type | Value range | Initial value | Function                                                                                                |
| ------ | --------- | ----------- | ------------- | ------------------------------------------------------------------------------------------------------- |
| *rOut* | REAL      |             |               | Analog value output                                                                                     |
| *xErr* | BOOL      |             |               | <p>\* <strong>FALSE:</strong><br>no limit violation<br>\* <strong>TRUE:</strong><br>limit violation</p> |

#### Setpoints / Parameters

| Name                   | Data type    | Value range                                                  | Initial value | Function                                                                        |
| ---------------------- | ------------ | ------------------------------------------------------------ | ------------- | ------------------------------------------------------------------------------- |
| **rReplacementValue**  | REAL         |                                                              | 0             | value at the output *rOut* when limit is violated and option ‘ReplacementValue’ |
| **rReplacementOption** | eLimiterMode | InpultValue, MinValue, MaxValue, LastValue, ReplacementValue | InputValue    | selection of the value at the output *rOut* depending on the chosen option      |
| **rMaxLimit**          | REAL         |                                                              | 150           | upper limit                                                                     |
| **rMinLimit**          | REAL         |                                                              | -50           | lower limit                                                                     |

### Function description

#### Analog value output *rOut*

the analog value output *rOut* follows the analog value input *rIn*, as long as the analog value input *rIn* does not violate either of the two limits **rMinLimit** and **rMaxLimit** is violated.\
A limit violation occurs whenever the analog value input *rIn* is less than the limit **rMinLimit** or greater than the limit **rMaxLimit** is.\
In the event of a limit violation, the analog value output will be *rOut* determined depending on the selected option **rReplacementOption** (eLimiterMode).\\

| *rIn* | **ReplacementOption** | *rOut*                                          | Notes                                                                               |
| ----- | --------------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------- |
| X     | InputValue            | *rIn*                                           | option ‘InpultValue’                                                                |
| X     | MinValue              | **rMinLimit**                                   | option ‘MinValue’                                                                   |
| X     | MaxValue              | **rMaxLimit**                                   | option ‘MaxValue’                                                                   |
| X     | LastValue             | last state of *rOut* before the limit violation | option ‘LastValue’ Warning: The last value is not saved on a cold start of the PLC! |
| X     | ReplacementValue      | **rReplacementValue**                           | option ‘ReplacementValue’                                                           |

Legend: X = any

#### Digital output *xErr*

The digital output *xErr* signals an active limit violation.\\

| limit violation | *xErr* | Notes              |
| --------------- | ------ | ------------------ |
| FALSE           | FALSE  | no limit violation |
| TRUE            | TRUE   | limit violation    |

Legend: X = any

### CODESYS

InOut:

| Scope       | Name                 | Type         | Initial                 |
| ----------- | -------------------- | ------------ | ----------------------- |
| Input       | `rIn`                | `REAL`       | 0                       |
| Input Const | `rReplacementValue`  | `REAL`       | 0                       |
| Input Const | `rReplacementOption` | eLimiterMode | eLimiterMode.InputValue |
| Input Const | `rMaxLimit`          | `REAL`       | 150                     |
| Input Const | `rMinLimit`          | `REAL`       | -50                     |
| Output      | `rOut`               | `REAL`       |                         |
| Output      | `xErr`               | `BOOL`       |                         |
| Output      | `xAlarmHigh`         | `BOOL`       |                         |
| Output      | `xAlarmLow`          | `BOOL`       |                         |
