Serial protocol--RS-485 protocol

RS-485 multi-machine communication networking method
Typical bus communication method
Insert image description here
Daisy chain multi-machine communication method
Each node intelligently receives the data sent by the previous node and can only send data to the next node.

Star RS-485 multi-machine communication method
To realize star networking, an RS-485 hub (HUB) must be used to ensure that damage to one or more RS-485 buses will not affect the normal communication of other buses.

Insert image description here
Single-loop self-healing RS-485 multi-machine communication method
The single-ring self-healing RS-485 networking method greatly increases the communication reliability of the bus and solves the problems of communication interruption caused by bus disconnection and weak wiring structure.
Single loop: Although there are two RS-485 signal lines, they are actually one loop of RS485 signals.
Self-healing: When the RS-485 signal is disconnected, the signal from any slave computer is still connected to the input interface of the converter through the other part that is not disconnected.
Insert image description here


Networking method of serial fiber optic multi-machine communication
In order to achieve reliable remote communication of serial ports, users often use optical fiber. As a transmission medium, optical fiber has the advantages of high isolation voltage, anti-electromagnetic interference, anti-lightning strike, etc. Each branch and collection of optical fiber should go through a dedicated optical fiber converter. Therefore, the networking method of optical fiber communication depends on the optical fiber. converter functions,

Simple one-to-one serial fiber optic communication method
Insert image description here

Bus type serial port fiber optic multi-machine communication method
Insert image description here
Here you need to use the RS-232/RS-485 optical fiber interrupt converter, which can realize the interruption of RS-232/485 optical fiber communication, that is, extend the serial optical fiber communication distance, realize bus-type serial optical fiber multi-machine communication, and connect multiple RS- 232 or 485 interface is connected to the same bus-type serial port optical fiber communication network.

Ring serial port optical fiber multi-machine communication method
Insert image description here


Serial fiber optic multi-machine communication method
Insert image description here
This networking method is more flexible, but cannot be cascaded at multiple levels.
No. 2 is the serial port/fiber optic converter.


Implementation of address serial port conversion
Use of address serial port converter
For serial port multi-machine communication, the lower computer required for communication must have an address. During communication, the host computer first sends the address of a certain slave computer. All slave computers located on the same network read this address at the same time, and then compare it with its own address. If the address is the same, the subsequent data will be received. If the data is different, The subsequent data will not be accepted.
In most cases, the lower computer does not have the function of setting the address, or the address format is different, so the address serial port must be converted.
The principle of the address serial port converter is to use the two serial ports of the converter to become the upper computer serial port and the lower computer serial port, and automatically add the set address. The processing of the address includes two parts: ① Remove the address from the data received by the serial port of the upper computer and send it out from the serial port of the lower computer.
② Add the address to the data received by the serial port of the lower computer and send it out from the serial port of the upper computer.
Pure hardware jumper settings, no software settings required
Insert image description here
A1/B1 is the main serial port, and the main serial port data = address code + slave serial port data. The specific form of the address code is: "###1:", the data bit is "12345", and the main serial port data is "###1:12345", that is, the frame header needs to be removed before sending data.
In the same RS232/RS-485 bus, you can add up to 8 DIZ485 products at the same time. When using, set these 8 products to 0~7 different address characters respectively, and connect the main serial ports of all DIZ products together. on a bus and connected to the host computer.
The advantage of the address serial port converter is that it is simple and convenient to use. The disadvantage is that it can only convert addresses without converting data bits, stop bits, and check bits. Uncommon address conversion requires customization.


The pure software implementation of address serial port conversion
uses the two serial ports of the computer, namely the upper computer serial port and the lower computer serial port, and uses pure software plus a manually set address. Remove the address from the data received by the serial port of the upper computer and send it out from the serial port of the lower computer. Add the address to the data received by the serial port of the lower computer and send it out from the serial port of the upper computer.
The setting process is: ① baud rate setting, including the baud rate of each of the two serial ports; ② select the format of sending data, including hexadecimal and character format, suitable for software such as Modbus; ③ set the address code, including the address code prefix , address value, address code suffix. in:

The upper computer serial port sends data = address code + the lower computer serial port receives data


Breaking through the limit of node number and distance of RS-485
The prerequisite for breaking through the limit of node number and distance is to use a serial port converter with relay function.
Insert image description here

The specifically implemented RS-232/RS-485 relay converter (model 485A2) has one DB-9 female end RS-232 and two RS-485 with terminal blocks. The DB-9 hole end is used to connect RS-232, and the DB-9 pin end is connected to RS-485.485A2 through the terminal board. There are 5 terminals (A1, B1, GND, B2, A2) on the terminal board. RS-485, sharing GND. A1, B1 and A2, B2 have exactly the same functions, regardless of direction. Two RS-485 have the function of relaying each other. If the distance of each RS-485 section is 1200m and 128, the distance of the entire RS-485 system reaches (NX1200 m) and the number of nodes reaches (Nx128). It can be seen that the RS-485 bus wiring using 485A2 is extremely simple. You can use 485A or 485A2 at the farthest ends. Note that the entire RS-485 system shares GND.
Limited by the performance of the RS-485 interface chip, each segment of RS-485 can currently connect up to 128 nodes, so to reach the limit of 256, at least one 485A2 relay converter should be connected.
Assuming the baud rate is 9600b/s, the time to transmit one byte is 0.001146s. During this period, the transmission distance of electromagnetic waves is 345.5km. That is, the theoretical maximum transmission distance is 345.5Km, which requires 286.26 repeaters. Beyond this distance, multiple slave responses at the same time will cause the host to read data errors.
This limit distance has nothing to do with the propagation medium or protocol, and is proportional to the number of data bits.

Guess you like

Origin blog.csdn.net/Wangwenshuaicsdn/article/details/129981463