# Button4

## `Button4` (FB)

FUNCTION\_BLOCK Button4

### Short description

> Switching element with four control inputs and four switching outputs.\
> In addition, an overall output is available.

### Representation

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

### Interfaces

#### Inputs

| Name         | Data type | Value range | Initial value | Function                                  |
| ------------ | --------- | ----------- | ------------- | ----------------------------------------- |
| *xButton1*   | BOOL      |             |               | Input Control button 1                    |
| *xButton2*   | BOOL      |             |               | Input Control button 2                    |
| *xButton3*   | BOOL      |             |               | Input Control button 3                    |
| *xButton4*   | BOOL      |             |               | Input Control button 4                    |
| *xButtonOff* | BOOL      |             |               | Input central deactivation of all outputs |

#### Outputs

| Name  | Data type | Value range | Initial value | Function           |
| ----- | --------- | ----------- | ------------- | ------------------ |
| *xQ1* | BOOL      |             |               | Switching output 1 |
| *xQ2* | BOOL      |             |               | Switching output 2 |
| *xQ3* | BOOL      |             |               | Switching output 3 |
| *xQ4* | BOOL      |             |               | Switching output 4 |
| *xQ*  | BOOL      |             |               | Overall output     |

#### Setpoints / parameters

| Name               | Data type | Value range | Initial value | Function                   |
| ------------------ | --------- | ----------- | ------------- | -------------------------- |
| **xButton1Visu**   | BOOL      |             | FALSE         | Function like *xButton1*   |
| **xButton2Visu**   | BOOL      |             | FALSE         | Function like *xButton2*   |
| **xButton3Visu**   | BOOL      |             | FALSE         | Function like *xButton3*   |
| **xButton4Visu**   | BOOL      |             | FALSE         | Function like *xButton4*   |
| **xButtonOffVisu** | BOOL      |             | FALSE         | Function like *xButtonOff* |

### Function description

#### General

The five inputs for the control buttons and the five visualization buttons are continuously monitored for rising edges ( = button pressed ).\
The switching outputs and the overall output are set depending on which input a rising edge was detected on.\
The input *xButton1* has the highest, the input *xButton2* the second highest priority, etc.\
If no rising edge is detected on any of the four inputs, the states of the outputs do not change.\
\\

#### Overall output *xQ*

The overall output is activated ( *xQ* = TRUE ) if at least one of the four switching outputs is active.\
It is not active ( *xQ* = FALSE ) if none of the four switching outputs is active\\

| *xButton1*       | *xButton2*       | *xButton3*       | *xButton4* | *xQ1* | *xQ2* | *xQ3* | *xQ4* | Note                 |
| ---------------- | ---------------- | ---------------- | ---------- | ----- | ----- | ----- | ----- | -------------------- |
| L/H              | X                | X                | X          | TRUE  | FALSE | FALSE | FALSE | Actuation - Button 1 |
| FALSE, TRUE, H/L | L/H              | X                | X          | FALSE | TRUE  | FALSE | FALSE | Actuation - Button 2 |
| FALSE, TRUE, H/L | FALSE, TRUE, H/L | L/H              | X          | FALSE | FALSE | TRUE  | FALSE | Actuation - Button 3 |
| FALSE, TRUE, H/L | FALSE, TRUE, H/L | FALSE, TRUE, H/L | L/H        | FALSE | FALSE | FALSE | TRUE  | Actuation - Button 4 |

Legend: X … not relevant, L/H … rising edge, H/L … falling edge\\

#### Central deactivation of all outputs *xButtonOff* or **xButtonOffVisu**

The outputs *xQ1* to *xQ4* are deactivated ( = FALSE ) if a rising edge is detected at input *xButtonOff* or at the setpoint / parameter **xButtonOffVisu**  (regardless of the current states at the control inputs) *xButton1* to *xButton4* ).\\

### CODESYS

InOut:

| Scope       | Name             | Type   | Initial |
| ----------- | ---------------- | ------ | ------- |
| Input       | `xButton1`       | `BOOL` |         |
| Input       | `xButton2`       | `BOOL` |         |
| Input       | `xButton3`       | `BOOL` |         |
| Input       | `xButton4`       | `BOOL` |         |
| Input       | `xButtonOff`     | `BOOL` |         |
| Input Const | `xButtonOffVisu` | `BOOL` | FALSE   |
| Input Const | `xButton4Visu`   | `BOOL` | FALSE   |
| Input Const | `xButton3Visu`   | `BOOL` | FALSE   |
| Input Const | `xButton2Visu`   | `BOOL` | FALSE   |
| Input Const | `xButton1Visu`   | `BOOL` | FALSE   |
| Output      | `xQ1`            | `BOOL` |         |
| Output      | `xQ2`            | `BOOL` |         |
| Output      | `xQ3`            | `BOOL` |         |
| Output      | `xQ4`            | `BOOL` |         |
| Output      | `xQ`             | `BOOL` |         |
