code. If the CRC check is incorrect, no information will be sent to the host.
d) Address code
The address code is the first byte (8 bits) of the information frame of each
communication from 0 to 32. This byte indicates that the slave device set
before the user will receive information from the master.
Each slave device must have a unique address code.
If the address code of the slave device matches the address code sent by the
master device, the master device can read the command and send back a
return message.
The address code sent by the slave to the master indicates the master's
address, so that it can identify where the feedback is coming from.
e) Function code
The function code is sent in the second byte of the frame. The function codes
that can be defined in the Modbus communication protocol are 1 to 127.
With the function code, the master device sends what task it wants the slave
device to perform.
The response from the slave device returns the same function code,
indicating that it has responded to the master device and performed the
function-related operations.
The following table provides examples of Modbus protocol function codes.
Function
code
03H
06H
10H
f)
Data area
The data area contains information about what should be returned from the
slave or what actions should be performed.
The information can be data ( digital inputs/outputs, analog inputs/outputs,
registers, etc.), reference address, etc. E.g. the master sends the slave a
command to return a register value ( including the starting address and the
length of the register to be read) via function code:
03, then the returned data includes both the length and data content of the
register. For different slave devices, the address and data information are
different.
Definition
Reading data from a
register
Write a single register
Write multiple registers
Operation (binary)
Read data from one or more
registers
Write a set of data into a single
register
Write multiple binary data sets
to multiple registers