Skip to main content

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

alt text

Parameter description

Parameter nameCategoryTypeMeaning
REQINPUTBOOLRising edge trigger initialization Modbus RTU RS485 serial port configuration
PARITYINPUTUSINTSelect parity (0: None, 1: Odd, 2: Even) The default value is 0
DATA_BITSINPUTUSINTThe data is, valid values ​​​​5, 6, 7, 8. The default value used is 8
STOP_BITSINPUTUSINTStop bit, 1 or 2. The default value used is 1
BAUDINPUTUDINTBaud rate, the default value is B9600
RETRIESINPUTUINTNumber of retries made by the master before returning error code "0x8019 No Response"
RESP_TOINPUTUINTResponse 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_GAPINPUTUINTThe 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_ARGINPUTUINTReserved parameter position
COM_RSTINOUTBOOLReset the serial port configuration when TRUE, update to FALSE after calling
DONEOUTPUTBOOLTRUE: Initialization completed, no errors, maintained for one cycle
ERROROUTPUTBOOLTRUE: An error occurred during the initialization process. For specific reasons, refer to STATUS. Maintain a cycle
STATUSOUTPUTWORDStatus code/error code

Status code description

Status codeMeaningSolution
0x0000Initial state, no tasks
0x7000Initialization successful
0x8001Failed to bind serial portSystem internal error
0x8002Failed to set baud rateSystem internal error
0x8003Failed to set serial port configuration parametersSystem internal error
0x8004Failed to close serial portSystem internal error
0x8005The current serial port connection configuration is in useWhen 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 codeMeaningSolution
0x8030The check digit parameter is invalidPlease enter the correct check digit parameter. For details, refer to the above parameter description
0x8031Invalid data bit parametersPlease enter the correct data bit parameters, refer to the above parameter description for details
0x8032The stop bit parameter is invalidPlease enter the correct stop bit parameter. For details, refer to the above parameter description
0x8033The baud rate parameter is invalidPlease enter the correct baud rate parameter. For details, refer to the above parameter description