
5.2
Modbus protocol
5.2.1
Frame
When data frame reaches the terminal unit, the unit removes the data frame's
header, reads the data; if there is no error, it then implements the data's task.
Afterwards, the unit puts its own data with the acquired header, and sends back the
frame to the sender. The response data frame contains: ID, Function code, Data and
CRC Check. Any error will cause a failure to respond.
ID
Function code
Data
CRC check (lo) CRC check (hi)
1 byte
1 byte
N byte
1 byte
1 byte
Table 5.1
5.2.2
ID field
The ID field is at the start of the frame. It is composed of 1 byte (8 bits); its decimal
value range is 0-255. A master addresses a slave by placing the slave ID in the ID field
of the message. When the slave sends its response, it places its own ID in this ID field
of the response to let the master know which slave is responding.
5.2.3
Function code field
When a message is sent from a master to a slave device, the function code field tells
the slave what kind of action to perform.
Function code (hex) Descriptions
03
Read register
10
Write register
Table 5.2
5.2.4
Data field
Data field contains the data that terminals need to complete the request and the
data that terminals respond to the request. This data may be a numerical value,
address or setting; refer to Section 5.3. For example, Function Code tells the terminal
to read one register; Data Field needs to specify reading from which register and how
many registers to read.