599
9
9 Communication
9.4 Modbus Protocol
3) Protocol description
Modbus instructions are valid on COM1. You can use Modbus instructions to program, and use the PLC as
a master station to communicate with the Modbus slave station.
Multiple Modbus instructions can be available and driven at a time. The instructions are executed in
sequence. According to Modbus protocols, the slave station must respond whether data is read or written
(except for broadcasts). It usually takes multiple scan cycles to execute one Modbus instruction. In one
scan cycle, the instruction is driven but not necessarily executed.
If multiple Modbus instructions exist, they are executed in the following order: the system scans the rst
driven Modbus instruction, records its parameters, and executes the instruction in the background. Then
the system returns to the user program, scans the next driven Modbus instruction in the position where the
previous instruction was executed, and executes the instruction.
● Instruction formats: Modbus (Addr&Cmd, RegAddr, RegLen, and DataBuf)
① Addr&Cmd indicates slave address and Modbus parameter number. Upper eight bits indicate the slave
address, namely the address of the target device. Lower eight bits indicate the Modbus parameter
number. Dened by a standard Modbus protocol, the bits support 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x0f, and 0x10. For denitions, see standard Modbus protocols or Modbus protocols for target devices.
② RegAddr indicates the address of the slave coil (1-bit) or register (16-bit) to be read or written.
Depending on Modbus slave protocols, the value can be indicated by an element or a constant.
③ RegLen indicates the number of slave coils or registers to be read or written. The value can be
indicated by an element or a constant.
④ DataBuf can be used for D elements only. It indicates the starting register for data storage, namely
the data buffer. The buffer length is correlated to RegLen. The value should be not less than 1. If the
Modbus instruction is to read data, after the instruction is executed, the system will read slave data to
the buffer. If the Modbus instruction is to write data, the system will send the buffer to the slave. During
programming, you need to calculate the buffer length to reserve enough registers as a buffer.
● State ags
① M8122: Indicates the state of instruction execution. OFF indicates that the instruction has been
executed; ON indicates that the instruction is being executed. If M8122 is OFF and the instruction
ow is active in a scan cycle, the system will set M8122 to ON, record parameters, and execute
the instruction in the background. After communication is nished, when the system returns to
the instruction, whether the instruction ow is active or not, the system will reset M8122 to OFF,
immediately scan the next instruction whose ow is active, record parameters, and execute the
instruction in the background.
② M8123: Indicates the state of communication. ON indicates abnormal communication, and OFF
indicates normal communication.
③ M8063: Indicates instruction errors. Error codes are stored in D8063.
④ D8063: Indicates error codes. See the list of communication error codes.
• In compliance with Modbus protocols, the H3U PLC can read a maximum of 125 registers and write a maximum of
123 registers at a time. If the number of registers to be read or written exceeds the limit, a parameter error will be
returned.
In compliance with Modbus protocols, the H3U PLC can read and write a maximum of 255