7.15.10 MODBUS_RTU_CONFIG
Function
- The Modbus_RTU_Config instruction configures the communication module through the Modbus RTU protocol.
- After configuring a port for the Modbus RTU protocol, it can only be used by the Modbus_RTU_Master command. If you need to change communication parameters such as data transfer rate or parity, just run trigger Modbus_RTU_Config again
warning
Unable to retain instance data block for Modbus_RTU_Config instruction
LD graphics

Parameter description
| Parameter name | Category | Type | Meaning |
|---|---|---|---|
| REQ | INPUT | BOOL | Rising edge trigger initialization Modbus RTU RS485 serial port configuration |
| PARITY | INPUT | USINT | Select parity (0: None, 1: Odd, 2: Even) The default value is 0 |
| DATA_BITS | INPUT | USINT | The data is, valid values 5, 6, 7, 8. The default value used is 8 |
| STOP_BITS | INPUT | USINT | Stop bit, 1 or 2. The default value used is 1 |
| BAUD | INPUT | UDINT | Baud rate, the default value is B9600 |
| RETRIES | INPUT | UINT | Number of retries made by the master before returning error code "0x8019 No Response" |
| RESP_TO | INPUT | UINT | Response timeout: The time the Master waits for the slave to respond. After the timeout, the Master will repeat the request, or cancel the request and report an error after repeating it a specified number of times (RETIES). Unit millisecond |
| REQ_GAP | INPUT | UINT | The character space delay between characters is used to increase the prediction time between received bytes. Add this parameter time to the Modbus RTU standard value of 3.5 characters. Unit millisecond |
| RESERVE_ARG | INPUT | UINT | Reserved parameter position |
| COM_RST | INOUT | BOOL | Reset the serial port configuration when TRUE, update to FALSE after calling |
| DONE | OUTPUT | BOOL | TRUE: Initialization completed, no errors, maintained for one cycle |
| ERROR | OUTPUT | BOOL | TRUE: An error occurred during the initialization process. For specific reasons, refer to STATUS. Maintain a cycle |
| STATUS | OUTPUT | WORD | Status code/error code |
Status code description
| Status code | Meaning | Solution |
|---|---|---|
| 0x0000 | Initial state, no tasks | |
| 0x7000 | Initialization successful | |
| 0x8001 | Failed to bind serial port | System internal error |
| 0x8002 | Failed to set baud rate | System internal error |
| 0x8003 | Failed to set serial port configuration parameters | System internal error |
| 0x8004 | Failed to close serial port | System internal error |
| 0x8005 | The current serial port connection configuration is in use | When trying to update or reset the serial port, the Modbus_RTU_Master instance is using the serial port configuration for communication. Retry after the communication is completed |
| Parameter verification error code | Meaning | Solution |
|---|---|---|
| 0x8030 | The check digit parameter is invalid | Please enter the correct check digit parameter. For details, refer to the above parameter description |
| 0x8031 | Invalid data bit parameters | Please enter the correct data bit parameters, refer to the above parameter description for details |
| 0x8032 | The stop bit parameter is invalid | Please enter the correct stop bit parameter. For details, refer to the above parameter description |
| 0x8033 | The baud rate parameter is invalid | Please enter the correct baud rate parameter. For details, refer to the above parameter description |