Skip to main content

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

alt text

Parameter description

Parameter nameCategoryTypeDescription
REQINPUTBOOLTRUE: Send a request to the Modbus Slave and wait for the response.
MB_ADDRINPUTUSINTModbus RTU slave address.
MODEINPUTUSINTMode (read/write).
0: Read, corresponding to function codes 0x01 ~0x04.
1: Write, corresponding to function codes 0x05, 0x06, 0x15, 0x16.
START_ADDRINPUTUINTStart address in the slave.
Coil: 1 ~ 9999
Discrete input: 10001 ~ 19999
Input register: 30001 ~ 39999
Holding register: 40001 ~ 49999
DATA_LENINPUTUINTData length, that is, the number of words or bits accessed.
DATA_PTRINOUTANY_TYPEpoints to the address of the data block to be written or read.
MB_RTU_CONFIGINOUTModbus_RTU_CONFIGPoints to the bound Modbus RTU serial port configuration
DONEOUTPUTBoolRequest processing ended without error. maintain a cycle.
BUSYOUTPUTBoolThe request is being processed.
ERROROUTPUTBoolAn error occurred during the request. For the specific error reason, refer to STATUS. Maintain a cycle
STATUSOUTPUTWORDStatus code

Status code description

Status codeMeaningSolution
0x0000Initial state, no tasks
0x7000Request successful
0x7002Request timed out, retrying until the number of RETRIES is reached
Parameter verification error codeMeaningSolution
0x8006The bound Modbus RTU serial port is not configured or has expiredRecall the MODBUS_RTU_CONFIG request to configure the serial port
0x8007Other Modbus_RTU_Master instances are using this RTU_CONFIGRetry after other instance requests are completed
0x8008Invalid input request mode, supports 0 and 1 for reading and writingCheck input parameters
0x8009Invalid request register/number of bitsCheck input parameters
0x800AInvalid access slave starting address
Coil: 1 ~ 9999
Discrete input: 10001 ~ 19999
Input register: 30001 ~ 39999
Holding register: 40001 ~ 49999
Check input parameters
0x800BThe combination of access slave address and mode is invalid. For example, use write mode to operate the input register at address 30001Check input parameters
0x800CFunction code parsing failedCheck input parameters
0x800DThe capacity of the bound data area is less than the space required by the requestCheck input parameters
0x800EThe request is too frequent and the interval is less than 3.5 characters + the time of the RTUConfig parameter REQ_GAPRequest
Request and response process error codesMeaningSolution
0x8010Disconnected from serial portReconfigure serial port
0x8011Failed to wait for response messageSystem internal error, reconfigure or try again
0x8012Disconnected from serial portReconfigure serial port
0x8013Failed to read response messageSystem internal error, reconfigure or try again
0x8016~0x8017Failed to send requestRequest again
0x8019After retrying RETRIES times, receiving the response message times outRequest again, or try again after setting a reasonable timeout
0x801AThe response message data exceeds the maximum length
Modbus_RTU_Master check response message content error codeMeaningSolution
0x801BResponse message slave address does not matchRequest again
0x801CResponse message check code does not matchRequest again
0x801DThe response message does not match the function code of the sent messageRequest again
0x801EThe response message is an exception message and the exception code is invalidRequest again
0x801FThe response message does not match the data and address of the sent messageRequest again
0x8020The response message is illegalRequest again
Modbus RTU protocol exception error codeMeaningScheme
0x8022Invalid function code
0x8023The requested address is invalid. For example, the slave station contains 128 holding registers and the requested access address is the register with address 130
0x8024Invalid request data
0x8025~0x802COther exception codes responded by the slave