RS485 And Modbus Communication Protocol Tutorial
Modbus communication rotocol
Modbus protocol is a common language applied to electronic controllers. Through this protocol, controllers can communicate with each other, controllers via a network (e.g., Ethernet), and devices. It has become a common industry standard. With it, control equipment produced by different manufacturers can be connected to an industrial network for centralized monitoring.
This protocol defines a message structure that the controller can recognize and use, describes the process of the controller requesting access to other devices, how to respond to requests from other devices, and how to detect and log errors. It establishes a common format for the format and content of message fields.
1、Modbus has the following features:
1) Standard and open, users can use the Modbus protocol for free and with confidence, without paying license fees and without infringing intellectual property rights. At present, there are more than 400 manufacturers supporting Modbus, and more than 600 products supporting Modbus.
2) Modbus can support a variety of electrical interfaces, such as RS-232, RS-485, etc., and can also be transmitted on various media, such as twisted pair, optical fiber, wireless, etc.
3)The frame format of Modbus is simple, compact, and easy to understand. It is easy for users to use and easy for manufacturers to develop.
2、Description of Modbus Register Types
1) Coil status: output port, the output status of the port can be set, and the output status of the bit can also be read.
2) Discrete input state: input port, change the input state through external setting, readable but not writable.
3) Holding register: some parameters that are set when the controller is running can be read and written.
4) Input register: Some parameters obtained from external devices when the controller is running can be read but not writable.
4、Brief description of Modbus function code
The function code can be divided into bit operation and byte operation. The minimum unit of bit operation is Bit, and the minimum unit of byte operation is 2 bytes (Byte).
(1) Bit operation instructions: read coil state 01H, read discrete input state 02H, write single coil 05H, write multiple coils 0FH.
(2) Byte operation instructions: read save register 03H, read input register 04H, write single save register 06H, write multiple save registers 10H.