# SimpleReadCoilInput

## `SimpleReadCoilInput` (FB)

`FUNCTION_BLOCK` SimpleReadCoilInput

### Representation

<figure><img src="/files/5cd9de1f1b9614c7f19f5d9eec6b856584b0a606" alt=""><figcaption></figcaption></figure>

### Evaluation of the actual values for function codes 01 (Read Coils) or 02 (Read Discrete Inputs)

When evaluating the actual values, only the output `arxValue` must be considered. This is an array with 64 elements of type `BOOL` (1 - 64 Coils / Inputs).

The specification of the bits to be transmitted is primarily determined by the choice of the function code (eFunctionCode), the start address (wStartAddr) and the desired number of Coils / Inputs (`wNumberOfCoils`) in the range 1 - 64.

The actual values are available as follows:

The first element `arxValue[0]` contains the state of the coil with the number `wStartAddress` The second element `arxValue[1]` contains the state of the coil with the number `wStartAddress` + 1 The third element `arxValue[2]` contains the state of the coil with the number `wStartAddress` + 2, etc. Unused elements of `arxValue` are described with FALSE.

Task: Read the actual value of coil 17

Settings: eFunctionCode: ReadFunctionCodesCoilInput.FC01\_ReadCoils wStartAddr = 17 wNumberOfCoils = 1

`arxValue[0]`: Actual value of coil 17 `arxValue[1]`: FALSE `arxValue[2]`: FALSE … `arxValue[63]`: FALSE

### CODESYS

InOut:

| Scope       | Name                | Type                                   | Initial                                      | Comment                                                                                                                                              |
| ----------- | ------------------- | -------------------------------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Input       | `xEn`               | `BOOL`                                 | TRUE                                         | Enable / disable communication (TRUE = enable)                                                                                                       |
| Input       | `byUnitId`          | `BYTE`                                 | 0                                            | Device address                                                                                                                                       |
| Input       | `xUpdateActual`     | `BOOL`                                 | FALSE                                        | Update of actual values (on every rising edge)                                                                                                       |
| Input       | `xResError`         | `BOOL`                                 | FALSE                                        | <p>Reinitialization of the outputs <code>eErrorCodeCom</code> or<br><code>eErrorCodeDev</code> to the error-free state (on every<br>rising edge)</p> |
| Inout       | `ModbusClient`      | `ModbusClientBase`                     |                                              | Client of the device                                                                                                                                 |
| Output      | `eFunctionCodeFb`   | ReadFunctionCodesCoilsInputs           |                                              | Feedback - Modbus function code for the Modbus telegram                                                                                              |
| Output      | `wStartAddrFb`      | `WORD`                                 |                                              | Feedback - Start address of the coils/inputs to be read                                                                                              |
| Output      | `wNumberOfCoilsFb`  | `WORD`                                 |                                              | Feedback - Number of coils/inputs to be read (1 - 64)                                                                                                |
| Output      | `arxValue`          | `ARRAY` \[0 .. 63] `OF` `BOOL`         |                                              | Array with the current coil/input states                                                                                                             |
| Output      | `xAlarm`            | `BOOL`                                 |                                              | Collective fault (TRUE = fault)                                                                                                                      |
| Output      | `xAlarmCom`         | `BOOL`                                 |                                              | Collective fault - communication (TRUE = fault)                                                                                                      |
| Output      | `eErrorCodeCom`     | ModbusErrorCode                        |                                              | Error code - communication (0 = no error)                                                                                                            |
| Output      | `eErrorCodeDev`     | SIMPLE\_READ\_COIL\_INPUT\_ERROR\_CODE |                                              | Error code - device (0 = no error)                                                                                                                   |
| Output      | `xBusy`             | `BOOL`                                 |                                              | Communication indicator (TRUE = communication)                                                                                                       |
| Input Const | `wNumberOfCoils`    | `WORD`                                 | 1                                            | Number of coils/inputs to be read (1 - 64)                                                                                                           |
| Input Const | `eFunctionCode`     | ReadFunctionCodesCoilsInputs           | ReadFunctionCodesCoilsInputs.FC01\_ReadCoils | Modbus function code for the Modbus telegram                                                                                                         |
| Input Const | `wStartAddr`        | `WORD`                                 |                                              | Start address of the coils/inputs to be read                                                                                                         |
| Input Const | `tTimeUpdateActual` | `TIME`                                 | TIME#3s0ms                                   | <p>Update interval for the processes influenced by the input<br><code>xUpdateActual</code> influenced</p>                                            |


---

# 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-modbus-library/functionblocks/generic/simplereadcoilinput.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.
