# SimpleReadArray

## `SimpleReadArray` (FB)

FUNCTION\_BLOCK SimpleReadArray

### **Triggering of the transmission of Modbus data**

> The data transmission is triggered if at least one of the conditions described below is met:

> Prerequisite: A suitable array is connected at the 'InputArray' input. This is indicated by the output 'xInputArrayValid' (= TRUE).

> 1. after an edge change at the 'xUpdateActual' input ( FALSE >> TRUE ) ( one-time )
> 2. after the expiration of the duration 'tTimeUpdateActual' ( 'tTimeUpdateActual' > 0 ) ( cyclic )
> 3. after a change of the array at the 'InputArray' input ( data type, size ) ( one-time )
> 4. after a change of essential parameters ( 'byUnitId', 'wRegisterAddr', 'eFunctionCode' ) ( one-time )
> 5. after an edge change on the input 'xEn' ( FALSE >> TRUE ) ( one-time )
> 6. after every cold start ( one-time )

> After completion of the data transfer, the result is signalled ( 'xDataValid' = TRUE / FALSE ) and the transmitted data are stored in the 'InputArray' array.

> Note: As of 07.07.2023 the data type of the array at the 'InputArray' input cannot be detected and evaluated ( CDS-43675 Compiler, AnyType: Extension for Arrays needed ). The tooltip help for the 'InputArray' input shows the possible array data types depending on the chosen function code.

InOut:

| Scope       | Name                | Type                             | Initial                                      | Comment                                                                                                                            |
| ----------- | ------------------- | -------------------------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Input       | `xEn`               | `BOOL`                           | TRUE                                         | Enable / disable communication ( TRUE = enabled )                                                                                  |
| Input       | `byUnitId`          | `BYTE`                           | 0                                            | Modbus address of the device                                                                                                       |
| Input       | `InputArray`        | `__SYSTEM.AnyType`               |                                              | <p>Input for the array ( FC01/02: ARRAY OF BOOL, ARRAY OF<br>BYTE ) ( FC03/04: ARRAY OF INT, ARRAY OF UINT, ARRAY OF WORD<br>)</p> |
| Input       | `xUpdateActual`     | `BOOL`                           | FALSE                                        | <p>Update of actual values (on every rising edge<br>)</p>                                                                          |
| Input       | `xResError`         | `BOOL`                           | FALSE                                        | <p>Reinitialization of the outputs ‘eErrorCodeCom’ and<br>‘eErrorCodeDev’ to the error-free state (on every<br>rising edge)</p>    |
| Inout       | `ModbusClient`      | `ModbusClientBase`               |                                              | Client of the device                                                                                                               |
| Output      | `eFunctionCodeFb`   | ReadFunctionCodes                | ReadFunctionCodes.FC01\_ReadCoils            | Feedback - Modbus function code for the Modbus telegram                                                                            |
| Output      | `wRegisterAddrFb`   | `WORD`                           | 0                                            | <p>Feedback - start address of the register for the Modbus<br>telegram</p>                                                         |
| Output      | `diInputArrayNumb`  | `DINT`                           | 0                                            | <p>Number of array elements at the 'InputArray' input depending<br>on the Modbus function code</p>                                 |
| Output      | `xInputArrayValid`  | `BOOL`                           | FALSE                                        | <p>Validity of the array at the 'InputArray' input ( data type,<br>size ) ( FALSE = not valid, TRUE = valid )</p>                  |
| Output      | `xDataValid`        | `BOOL`                           | FALSE                                        | <p>Validity of the data in the 'InputArray' array ( FALSE = not<br>valid, TRUE = valid )</p>                                       |
| Output      | `xAlarm`            | `BOOL`                           | FALSE                                        | General fault ( TRUE = fault )                                                                                                     |
| Output      | `xAlarmCom`         | `BOOL`                           | FALSE                                        | General fault - communication ( TRUE = fault )                                                                                     |
| Output      | `eErrorCodeCom`     | ModbusErrorCode                  | ModbusErrorCode.NO\_ERROR                    | Error code - communication ( 0 = no error )                                                                                        |
| Output      | `eErrorCodeDev`     | SIMPLE\_READ\_ARRAY\_ERROR\_CODE | SIMPLE\_READ\_ARRAY\_ERROR\_CODE.NO\_ERROR   | Error code - device (0 = no error)                                                                                                 |
| Output      | `xBusy`             | `BOOL`                           | FALSE                                        | Communication indicator ( TRUE = communication )                                                                                   |
| Input Const | `eFunctionCode`     | ReadFunctionCodes                | ReadFunctionCodes.FC03\_ReadHoldingRegisters | Modbus function code for the Modbus telegram                                                                                       |
| Input Const | `wRegisterAddr`     | `WORD`                           |                                              | Start address of the register for the Modbus telegram                                                                              |
| Input Const | `tTimeUpdateActual` | `TIME`                           | TIME#3s0ms                                   | <p>Update interval for operations influenced by the input<br>'xUpdateActual'</p>                                                   |
