# ModbusValue

## `ModbusValue` (FB)

`FUNCTION_BLOCK` ModbusValue

### **Representation**

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2FxRM98UThY5tMUD7lGMFN%2FModbusValue.png?alt=media&#x26;token=125aa56d-14ca-4a00-8c6e-0fed0642e390" alt=""><figcaption></figcaption></figure>

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><code>BOOL</code>, <code>WORD</code>, <code>INT</code>, 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 it is required</p>                               |
| Input  | `byFunctionCode`      | `BYTE`                  | 3                                    | <p>The modbus function code (3 = read input registern, 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 excange (<code>Modbus\_Read</code>,<br><code>Modbus\_Write</code> or <code>Modbus\_Bidir</code>)</p>                  |
| Input  | `eModRcvOpMode`       | MODRCV\_OPERATION\_CODE |                                      | <p>Operation Mode regarding to communication erros 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 ready successfully to 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                                                                                     |
