In the field of industrial control, electric power communication, intelligent meter, etc., serial communication is usually used for data exchange. The initial method used is the RS232 interface, due to the complexity of the industrial site, a variety of electrical equipment will produce more electromagnetic interference in the environment, which can lead to signal transmission errors.
In 1979, Schneider Electric developed a bus protocol for industrial field Modbus protocol, now used in industrial RS485 communication occasions many are using Modbus protocol, so today we come to understand the RS485 communication and Modbus communication protocol.
First, the introduction of RS485
In the industrial control occasions, RS485 bus because of its simple interface, easy networking, transmission distance and other characteristics are widely used.
RS485 and RS232 are based on the same serial communication interface, the operation of data sending and receiving is the same, so the use of the same WinCE underlying driver. But they are in the actual application of the communication mode has a big difference, RS485 interface for half-duplex data communication mode, while the RS232 interface for full-duplex data communication mode, data can not be sent and received at the same time, in order to ensure that the data sent and received without conflict, the hardware is through the direction of switching to achieve, and accordingly also requires the software must be sent and received in the process of strict separation.
RS485 interface composed of half-duplex network, generally two-wire system (formerly four-wire connection, can only realize the point-to-point communication, now rarely used), more shielded twisted-pair cable transmission. This wiring for the bus topology in the same bus can be connected to a maximum of 32 nodes. In the RS485 communication network is generally used in the master-slave communication mode, that is, a host with more than one slave.
RS485 characteristics:
RS485 electrical characteristics: logic "0" to the voltage difference between the two lines for + (2-6) V said; logic "1" to the voltage difference between the two lines for - (2-6) V said. The logic "1" is indicated by a voltage difference of -(2-6) V between the two lines. Interface signal level is lower than RS232, it is not easy to damage the interface circuit chip, and the level is compatible with the TTL level, can be easily connected with TTL circuit.
The maximum data transfer rate of RS485 is 10Mbps.
RS485 interface is the use of balanced driver and differential receiver combination, anti-common-mode interference ability to enhance, that is, good anti-noise interference.
The maximum transmission distance of RS485 interface is standardized to 4000 feet (about 1219 meters), and in fact it can reach 3000 feet. In addition, RS232 interface allows only 1 transceiver to be connected to the bus, i.e., single station capability. The RS485 interface on the bus is allowed to connect up to 128 transceivers. That is, with multi-station capability, so that users can use a single RS485 interface to easily establish a network of devices.
Second, MODBUS introduction
Modbus was invented by Modicon (now a brand of Schneider Electric) in 1979, and is the world's first real bus protocol for industrial sites.
ModBus network is an industrial communication system, programmable controllers and computers with intelligent terminals are connected through common or localized dedicated lines. The system structure includes both hardware and software. It can be used for a variety of data acquisition and process monitoring applications.
ModBus features:
Standard, open, users can use the Modbus protocol free of charge, rest assured that there is no need to pay license fees, and will not infringe on intellectual property rights. Currently, there are more than 400 Modbus-supporting manufacturers and more than 600 Modbus-supporting products.
Modbus can support a variety of electrical interfaces, such as RS-232, RS-485, etc., and can also be transmitted over a variety of media, such as twisted pair, fiber optic, and wireless.
The frame format of Modbus is simple, compact and easy to understand. It is easy for users to use and simple for manufacturers to develop.
MODBUS communication transmission method:
Communication transmission is divided into independent information header, and encoded data sent. The following definitions of communication transmission methods are also compatible with the MODBUSRTU communication protocol:
Initial structure = ≥ 4 bytes of time
Address code = 1 byte
Function code = 1 byte
Data area = N bytes
Error check = 16-bit CRC code
End structure = ≥ 4 bytes of time
Address code: The address code is the first byte of the communication transmission. This byte indicates that the slave with the address code set by the user will receive the information sent by the master. Each slave has a unique address code, and the response back starts with the respective address code. The address code sent by the master indicates the address of the slave to which the message will be sent, and the address code sent by the slave indicates the address of the slave to which the message will be returned.
Function code: the second byte of the communication transfer The ModBus communication protocol defines function numbers from 1 to 127 The instrument utilizes only some of these function codes. Sent as a host request, the function code tells the slave what action to perform. Sent as a slave response, the function code sent by the slave is the same as that sent from the host and indicates that the slave has responded to the host to perform an action. If the highest bit of the function code sent by the slave is 1 (e.g., the function code is 127 at the same time as the function code is large), it indicates that the slave has not responded to the operation or has sent an error.
Data Area: The data area is different according to different function codes. The data area can be an actual value, a set point, an address sent from the host to the slave or from the slave to the host.
CRC code: two-byte error detection code.
Third, the difference between RS485 and MODBUS
RS485 is a physical interface, simply put, hardware.
MODBUS is an international standard communication protocol for the exchange of data between different manufacturers of equipment (generally industrial use); the so-called protocol, which can also be understood as the above, someone said "language", simply put, software.
In general, two devices through the MODBUS protocol to transmit data:
The earliest is to use RS232C as a hardware interface, (that is, the ordinary computer serial communications port (serial port)); also useful RS422, there are also commonly used RS485, this interface transmission distance, in general, the industrial field with more.
MODBUS protocol is divided into MODBUS RTU, MODBUS ASCII and the later development of MODBUS TCP three modes: the first two (MODBUS RTU, MODBUS ASCII) used in the physical hardware interface are serial (Serial) communication port (RS232, RS422, RS485).
MODBUS TCP is to comply with the trend of today's world development, what can be used Ethernet network or the Internet to connect and transmit data. So and MODBUS TCP mode, the mode of the hardware interface is Ethernet (Ethernet) port, that is, our computers are generally used on the network port.




