Modbus is an industrial communication protocol and a communication convention. The Modbus protocol includes RTU, ASCII, and TCP. MODBUS-RTU is the most commonly used, simple, easy to implement on a monolithic machine. Although RTU is simple, it is too professional to read protocol documents and manuals. Many contents are difficult to understand at first time.
What is the protocol? It's a mutual agreement. If you don't let anyone know it's a sign. Now define a new simplest protocol.
For example,
Protocol:
"A" -- "LED off"
"B" -- "Alarm"
"C" -- "LED on"
The DSP receives "A" control one LED Off, the DSP receives "B" control alarm, the single chip receives "A" control one LED ON. In this case, the corresponding action is performed when the corresponding information is received. This is the protocol, which is simple.
To analyze an MODBUS-RTU packet, perform the following steps: 01 06 00 01 00 17 98 04
01 06 00 01 00 17 98 04
Slave server address function number data address Data CRC verification code
This string of data means: Write the data 0x0017 (decimal 23) to the address 0x0001 data address of slave server 1.
MODBUS-RTU Function Code
Most commonly used function codes:
The following "coil" registers are actually the "bit variable" and "16-bit variable" respectively.
01 (0x01) read coil
02 (0x02) read dispersion input
03 (0x03) read hold register
04(0x04) read input register
05 (0x05) Write a single coil.
06 (0x06) Write a single register.
15 (0x0F) Write multiple coils.
16 (0x10) Write multiple registers.