# Button4

## `Button4` (FB)

FUNCTION\_BLOCK Button4

### Short description

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

### Representation

<figure><img src="/files/00acac084b550289b99bcf494b8133745d8e98cb" 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 visual 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 priority, 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 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` |         |


---

# 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/button/button4.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.
