laitimes

The difference between MODBUS and RS485

author:A sprouted potato

1. RS485 introduction

In industrial control occasions, RS485 bus has been widely used because of its simple interface, convenient networking, and long transmission distance. RS485 and RS232 are the same communication interface based on serial port, and the operation of data sending and receiving is the same, so the underlying driver of the same WinCE is used. But they have a big difference in the communication mode in practical application, RS485 interface is a half-duplex data communication mode, and RS232 interface is a full-duplex data communication mode, data sending and receiving can not be carried out at the same time, in order to ensure that the data sending and receiving does not conflict, the hardware is realized by the direction switching, and the corresponding software must be strictly separated from the process of sending and receiving.

RS485 is a physical interface

1. Serial communication can be realized, and it is often used to connect scanners, barcode readers, field instruments and inverters that support Modbus protocol and other devices with serial ports.

2. Taking the CM1241 (RS422/485) communication module of S7-1200 series as an example, the communication distance is up to 1000m, the communication rate is up to 115.2K, and the RS485 bus supports up to 32 devices, while the CM1241 (RS232) has a communication distance of up to 10m and can only be connected to 1 device.

The difference between MODBUS and RS485

RS485 pin wiring diagram

The half-duplex network composed of RS485 interface is generally a two-wire system (there was a four-wire system connection method before, which can only realize point-to-point communication, and is rarely used now), and most of them use shielded twisted pair transmission. This wiring method is a bus topology, and up to 32 nodes can be attached on the same bus. In the RS485 communication network, the master-slave communication mode is generally adopted, that is, a master with multiple slaves.

Features of RS485:

1. The electrical characteristics of RS-485: logic "0" is represented by the voltage difference between two wires is +(2-6)V, and logic "1" is represented by the voltage difference between two wires is -(2-6)V. The interface signal level is lower than that of RS-232, so it is not easy to damage the chip of the interface circuit, and the level is compatible with the TTL level, which can be easily connected with the TTL circuit.

2. The maximum data transmission rate of RS-485 is 10Mbps.

3. The RS-485 interface is a combination of balanced driver and differential receiver, and the anti-common-mode interference ability is enhanced, that is, the anti-noise interference is good.

4. The maximum transmission distance of the RS-485 interface is 4000 feet (about 1219 meters), in fact, it can reach 3000 feet, and the RS-232 interface is only allowed to connect 1 transceiver on the bus, that is, the single-station capability. The RS-485 interface on the bus allows up to 128 transceivers to be connected. That is, it has multi-station capability, so that users can easily set up a network of devices with a single RS-485 interface.

The difference between MODBUS and RS485

RS-232 to RS-485/422 converter

2. Introduction to MODBUS

Invented in 1979 by Modicon (now a brand of Schneider Electric), Modbus was the world's first truly industrial bus protocol.

The ModBus network is an industrial communication system consisting of a programmable controller with an intelligent terminal and a computer connected by a public line or a local dedicated line. The system architecture includes both hardware and software. It can be used for a variety of data acquisition and process monitoring.

Modbus is a communication protocol

1. It has two serial transmission modes: Modbus ASCIl and Modbus RTU

2. Modbus RTU communication transmits data in the master-slave mode, and the Modbus RTU master is the active party in the transmission process, that is, the master sends a data request packet to the slave, and the Modbus RTU slave returns a response packet.

3. S7-1200 and S7-1500 do not have Modbus ASCI1 communication related instructions, if necessary, they can be programmed according to point-to-point or PtP Communication communication instruction set.

Modbus TCP communication

Modbus TCP communication is a type of Ethernet communication, which is the application of the Modbus protocol on TCP. This can be implemented using the Ethernet interface on the S7-1200 and S7-1500 CPU bodies.

ModBus 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 that support Modbus, and more than 600 products that support 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 simple for manufacturers to develop.

MODBUS communication transmission mode

The communication transmission is divided into separate message headers, and the encoded data sent. The following definitions of communication transmission methods are also compatible with the MODBUSRTU communication protocol:

The difference between MODBUS and RS485

Initial structure = ≥4 bytes of time

Address code = 1 byte

Function code = 1 byte

Data area = N bytes

Error check = 16-digit CRC code

End structure = ≥4 bytes of time

Address code: The address code is the first byte of the communication. This byte indicates that the slave with the address code set by the user will receive the message sent by the master. And each slave has a unique address code, and the response return starts with its own address code. The address code sent by the master indicates the slave address to which it will be sent, and the address code sent by the slave indicates the slave address that is sent back.

Function code: The second byte of the communication transmission. The ModBus protocol defines function numbers from 1 to 127. This instrument only makes use of some of the function codes. It is sent as a master request and tells the slave what action to perform through the function code. As a slave response, the function code sent by the slave is the same as the function code sent from the master, and indicates that the slave has responded to the master to perform the operation. If the highest digit of the function code sent by the slave is 1 (for example, the function code is large and 127 at the same time), it means that the slave does not respond to the operation or sends an error.

Data area: The data area is different according to different function codes. A datazone can be an actual numeric value, a setpoint, an address from the host to the slave or the slave to the host.

CRC code: A two-byte error detection code.

The difference between MODBUS and RS485

3. The difference between RS485 and MODBUS

RS485 is a physical interface, simply put, hardware.

MODBUS is an international standard communication protocol, which is used to exchange data between devices of different manufacturers (generally for industrial purposes);

In general, the two devices transmit data via the MODBUS protocol.

The earliest is to use RS232C as a hardware interface, (that is, the serial communication port (serial port)) on ordinary computers, there are also RS422, there are also commonly used RS485, this kind of interface has a long transmission distance, and is used more in general industrial sites.

The MODBUS protocol is divided into three modes: MODBUS RTU, MODBUS ASCII and later developed MODBUS TCP: the first two (MODBUS RTU, MODBUS ASCII) use serial (Serial) communication ports (RS232, RS422, RS485).

MODBUS TCP is to adapt to the development trend of today's world, and anything can be connected to the Ethernet network or the Internet to transmit data. Therefore, it is also known as MODBUS TCP mode, and the hardware interface of this mode is the Ethernet port, which is the network port generally used on our computers.