# ModbusValue

## `ModbusValue` (FB)

FUNCTION\_BLOCK ModbusValue

InOut:

| Scope  | Name                  | Type                    | Initial                              | Comment                                                                                                                                        |
| ------ | --------------------- | ----------------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| Input  | `xEn`                 | `BOOL`                  | FALSE                                | Enables/Disables the function block ( TRUE = Enable )                                                                                          |
| Input  | `Value`               | `__SYSTEM.AnyType`      |                                      | <p>The value to read/write. It can be any IEC data type such as<br>BOOL, WORD, INT, FLOAT…</p>                                                 |
| Input  | `byUnitId`            | `BYTE`                  | 1                                    | <p>In case of Modbus-RTU enter the slave ID. In case of Modbus-<br>TCP or Modbus-UDP the unit is required</p>                                  |
| Input  | `byFunctionCode`      | `BYTE`                  | 3                                    | <p>The modbus function code (3 = read input registers, 4 = read<br>holding registers…)</p>                                                     |
| Input  | `wRegisterAddress`    | `WORD`                  |                                      | The modbus register address (zero based)                                                                                                       |
| Input  | `eReadWriteType`      | Modbus\_ReadWrite       | Modbus\_Read                         | <p>The direction of data exchange (<code>Modbus\_Read</code>,<br><code>Modbus\_Write</code> or <code>Modbus\_Bidir</code>)</p>                 |
| Input  | `eModRcvOpMode`       | MODRCV\_OPERATION\_CODE |                                      | <p>Operation mode regarding communication errors concerning<br>Modbus-Receive-Telegrams</p>                                                    |
| Input  | `wNumberOfCoils`      | `WORD`                  | 0                                    | Number of Coils / Inputs ( only for FC01 and FC02 )                                                                                            |
| Inout  | `ModbusClient`        | `ModbusClientBase`      |                                      | <p>Instance of ModbusClient (<code>ModbusClient\_RTU</code>,<br><code>ModbusClient\_TCP</code>, <code>ModbusClient\_RTU</code>, …)</p>         |
| Output | `eError`              | ModbusErrorCode         | ModbusErrorCode.NO\_ERROR            | Current error code (0 = NO\_ERROR if data exchange succeeded)                                                                                  |
| Output | `xBusy`               | `BOOL`                  |                                      | TRUE during data exchange                                                                                                                      |
| Output | `xChanged`            | `BOOL`                  |                                      | <p>TRUE after data was successfully ready at the Value input<br>(only for one cycle). Use this output for any needed byte<br>manipulations</p> |
| Output | `eResponseState`      | Response\_State\_Code   | Response\_State\_Code.STATE\_INVALID |                                                                                                                                                |
| Output | `wModRcvActDevErrCnt` | `WORD`                  |                                      | Action for the device's Modbus communication error counter                                                                                     |
