7.15.11 MODBUS_RTU_MASTER
Function
- The Modbus_RTU_Master instruction can communicate as a Modbus master through the port configured by the Modbus_RTU_Config instruction.
warning
- Unable to retain the instance data block of the Modbus_RTU_Master instruction
LD graphics

Parameter description
| Parameter name | Category | Type | Description |
|---|---|---|---|
| REQ | INPUT | BOOL | TRUE: Send a request to the Modbus Slave and wait for the response. |
| MB_ADDR | INPUT | USINT | Modbus RTU slave address. |
| MODE | INPUT | USINT | Mode (read/write). 0: Read, corresponding to function codes 0x01 ~0x04. 1: Write, corresponding to function codes 0x05, 0x06, 0x15, 0x16. |
| START_ADDR | INPUT | UINT | Start address in the slave. Coil: 1 ~ 9999 Discrete input: 10001 ~ 19999 Input register: 30001 ~ 39999 Holding register: 40001 ~ 49999 |
| DATA_LEN | INPUT | UINT | Data length, that is, the number of words or bits accessed. |
| DATA_PTR | INOUT | ANY_TYPE | points to the address of the data block to be written or read. |
| MB_RTU_CONFIG | INOUT | Modbus_RTU_CONFIG | Points to the bound Modbus RTU serial port configuration |
| DONE | OUTPUT | Bool | Request processing ended without error. maintain a cycle. |
| BUSY | OUTPUT | Bool | The request is being processed. |
| ERROR | OUTPUT | Bool | An error occurred during the request. For the specific error reason, refer to STATUS. Maintain a cycle |
| STATUS | OUTPUT | WORD | Status code |
Status code description
| Status code | Meaning | Solution |
|---|---|---|
| 0x0000 | Initial state, no tasks | |
| 0x7000 | Request successful | |
| 0x7002 | Request timed out, retrying until the number of RETRIES is reached |
| Parameter verification error code | Meaning | Solution |
|---|---|---|
| 0x8006 | The bound Modbus RTU serial port is not configured or has expired | Recall the MODBUS_RTU_CONFIG request to configure the serial port |
| 0x8007 | Other Modbus_RTU_Master instances are using this RTU_CONFIG | Retry after other instance requests are completed |
| 0x8008 | Invalid input request mode, supports 0 and 1 for reading and writing | Check input parameters |
| 0x8009 | Invalid request register/number of bits | Check input parameters |
| 0x800A | Invalid access slave starting address Coil: 1 ~ 9999 Discrete input: 10001 ~ 19999 Input register: 30001 ~ 39999 Holding register: 40001 ~ 49999 | Check input parameters |
| 0x800B | The combination of access slave address and mode is invalid. For example, use write mode to operate the input register at address 30001 | Check input parameters |
| 0x800C | Function code parsing failed | Check input parameters |
| 0x800D | The capacity of the bound data area is less than the space required by the request | Check input parameters |
| 0x800E | The request is too frequent and the interval is less than 3.5 characters + the time of the RTUConfig parameter REQ_GAP | Request |
| Request and response process error codes | Meaning | Solution |
|---|---|---|
| 0x8010 | Disconnected from serial port | Reconfigure serial port |
| 0x8011 | Failed to wait for response message | System internal error, reconfigure or try again |
| 0x8012 | Disconnected from serial port | Reconfigure serial port |
| 0x8013 | Failed to read response message | System internal error, reconfigure or try again |
| 0x8016~0x8017 | Failed to send request | Request again |
| 0x8019 | After retrying RETRIES times, receiving the response message times out | Request again, or try again after setting a reasonable timeout |
| 0x801A | The response message data exceeds the maximum length |
| Modbus_RTU_Master check response message content error code | Meaning | Solution |
|---|---|---|
| 0x801B | Response message slave address does not match | Request again |
| 0x801C | Response message check code does not match | Request again |
| 0x801D | The response message does not match the function code of the sent message | Request again |
| 0x801E | The response message is an exception message and the exception code is invalid | Request again |
| 0x801F | The response message does not match the data and address of the sent message | Request again |
| 0x8020 | The response message is illegal | Request again |
| Modbus RTU protocol exception error code | Meaning | Scheme |
|---|---|---|
| 0x8022 | Invalid function code | |
| 0x8023 | The requested address is invalid. For example, the slave station contains 128 holding registers and the requested access address is the register with address 130 | |
| 0x8024 | Invalid request data | |
| 0x8025~0x802C | Other exception codes responded by the slave |