MODBUS FUNCTION CODES
Modbus basic commands allow the control of a device to change the value of its registers (memory slot) or to request the
content of these registers, depending on the codes:
MODBUS COMMANDS
The format of the commands for the read/write operations is as follows (8 byte):
Slave address
1 byte
•
Slave address Defines the system to access. A Modbus command contains the Modbus address of the device it is
intended for (1 to 247). 0 address is reserved for a transmission to all devices (broadcast).
•
Operation code. Specifies the operation to be performed.
•
Register address. Specifies the operation to be accessed. In commands to be performed in multiple registers,
defines the boot log, from which you want to operate consecutively.
•
Data. Formed by 2 bytes (simple operations) or a set of 2 bytes (multiple operations) that contain the information
in the command.
•
CRC. Two bytes are added to the end of the stream in order to detect transmission o reception errors. This action is
done using the Cyclic Redundant Code.
•
Generator polynomial: CRC-16 = x
WRITE COMMANDS
Write a single holding register
The response, as long as there is no error type, must be exactly the same format as the write command.
6
Code
Function:
03
04
06
Preset/write single holding register
16
Preset/write multiple holding registers
Operation code
Register address
1 byte
16
+ x
15
+ x
2
+ 1.
Byte
Field
0
Address of the slave (1-247) (0: Broadcast)
1
Write single register (6)
2
Register address
3
4
Data to be written
5
6
CRC
7
Read holding registers
Read input registers
Data
1 byte
1...2·N bytes
CRC
2 bytes