MODBUS command includes read command and write command. Different types of registers, such as analog input registers, holding registers, coil input registers and holding registers, have different reading and writing instructions, including univariate reading and writing instructions and continuous multivariable reading and writing instructions. The general format of MODBUS instruction, the first byte is the device ID, the second byte is the instruction code, the third and fourth bytes are the offset, and the fifth and sixth bytes are the number of reading and writing registers. If it is a read instruction, the seventh and eighth paragraphs are CRC 16 check codes, which are converted from the first six bytes and arranged in the order of high bytes and low bytes. If it is a write instruction, the first six bytes are arranged.
If MODBUS protocol is used for communication, RTU mode can be used, but not ASCII mode, because the amount of communication data in ASCII mode will double, which will affect communication efficiency. The reading and writing operation that can be realized by one instruction should not be divided into several instructions, but also improve the reading and writing efficiency.