RS-485 bus technology only specifies the electrical standard of the interface, but does not specify the cable, plug-in and communication protocol of RS-485 interface. It is only a standard of physical layer in OSI specification. Because RS-485 bus adopts differential balanced transmission mode, shielded twisted pair is recommended for commonly used cables, so that 485 + and 485 – are twisted in pairs, and shielding layer is used outside to shield external electromagnetic interference, However, in the field construction, some people use parallel line, which is also suitable for RS-485 bus cable, but the anti-interference ability is poor, the transmission distance is not far and the communication quality is not stable, so it is generally recommended to use shielded twisted pair. As RS-485 bus generally uses 485 +, 485 – and GND wires, there is no rigid interface definition form. Generally, the common interface forms on the market include RJ45 interface, industrial terminal interface, DB9 serial terminal and RJ11 telephone line interface. Generally speaking, the use of industrial terminals is more appropriate, because if you need to access the terminal resistance, the use of industrial terminals is very good access, and access to shielded twisted pair is more convenient.
Because there is no communication protocol in RS-485 bus, many manufacturers have developed their own communication protocol based on RS-485 bus, among which the most famous one is Modbus protocol introduced by Modicon company. The protocol has two versions, one is Modbus RTU and the other is MODBUS ASCII.
Because RS-485 Bus supports point to multipoint communication mode, and it has no data conflict detection and resolution mechanism, the problem of data conflict is solved by the host computer. The host computer controls the whole system in an all-round way to avoid data conflict, Communication based on RS-485 bus can only support one master and multiple slaves.
Because RS-485 Bus supports the communication mode of one master and multiple slaves, the master needs to be able to identify multiple slave devices, so the slave device must have a unique address code in the 485 network, just like assigning student numbers to students in a class, the name of students may be repeated, but the student number must be unique in the class. The teacher only needs to call the student’s student number and ask the students to answer questions or do corresponding actions. In the same way, the 485 communication host controls the related actions of the 485 communication slave by calling the address code of the 485 communication slave.
When the 485 communication network starts to communicate, it will poll the devices of the whole network, that is to ask the 485 communication slaves one by one to confirm whether the device exists in the network and whether the device can operate normally. Just like the teacher will roll call the class before the formal teaching to confirm whether someone is absent from class. Once someone is absent from class, mark it to ensure that the absent student number will not be counted when asking questions in class, so as to avoid wasting time.
The 485 communication host sends the instruction in the form of broadcast. The 485 communication slave receives the relevant instruction and corresponds the address code in the instruction with its own address code. If it finds that the instruction is sent to itself, it immediately executes the relevant instruction. After executing the relevant instruction, it sends the corresponding status code to the 485 communication host, indicating that it can continue the next instruction. Otherwise, the instruction will be discarded and wait for the next instruction of 485 communication host. In the same way, when a teacher asks a question to a student, other students can’t speak during this period. Only the student who is asked answers the question. When the student answers the question, he says that the answer is finished. Then everyone waits for the teacher’s next question or lecture.
Generally speaking, the teacher’s teaching is a person in the classroom, but in some special cases, two or more teachers are required to teach in one classroom at the same time, so a coordination mechanism is needed to coordinate the teaching of multiple teachers. In the 485 communication network, there may be multiple RS-485 communication hosts coexisting in the same RS-485 communication network. In this case, the 485 sharer is used to meet these needs. There are two types of 485 sharers: preemptive mode and priority mode. Preemptive mode is first come first served, just like when a teacher is teaching, The other teachers can’t interrupt his teaching when he is teaching. Only after he has finished the paragraph and stopped for a certain period of time, can the other teachers start their own teaching. Similarly, the first come first served, the first to speak, the first to teach, and then fight for control again after the paragraph is finished. The priority mode is to define the corresponding priority. For example, the priority of the department head is higher than that of the ordinary teacher, even when the teacher teaches normally.
There is also the problem of 485 communication line. When the transmission distance is too long or the external interference is too large, resulting in too much noise, the 485 communication signal will have a certain attenuation, just like the larger classroom and the noisy situation outside the classroom. The students behind can not clearly hear the relevant content. Add a 485 repeater in the middle to reshape, restore and amplify the attenuated 485 signal, So that the remote 485 communication slave can recognize the 485 signal. In addition, when the classroom is large, mixing may occur in the classroom. By reasonably placing multiple speakers in the classroom, just like the 485 bus is connected to a star topology, signal reflection is generated, which leads to unstable communication quality. Using 485 hub to isolate each 485 bus from each other and drive independently can effectively solve similar problems.
Several topologies of RS-485 bus
The RS-485 bus wiring specification stipulates that it must be a bus topology, that is, if it is hand-in-hand chrysanthemum chain wiring mode, but in the actual construction process, the distribution of RS-485 devices on the site will not always follow the linear distribution, but may be scattered in different locations, or in a grid distribution, or in a tree distribution, Bus topology is not only a waste of wire, but also a more complex topology, which is easy to cause the communication quality instability of RS-485 bus system. Generally, it is necessary to arrange star topology or tree topology with the help of some corresponding equipment to facilitate the field wiring construction and later field maintenance.
1. Bus topology. Bus topology is the wiring specification of RS-485 bus. Bus topology is actually a special tree topology, but the distance between branch lines of bus topology is very short. In RS-485 bus wiring, it is recommended that the distance between branch lines should not exceed 0.5m. Generally, it is recommended to connect directly hand in hand with chrysanthemum chain without leaving branches, This ensures that there is no signal reflection problem. And the so-called hand-in-hand chrysanthemum chain connection mode is: A, B, C three RS-485 devices, 485 + of a device is connected to 485 + of B device, 485 + of B device is connected to 485 + of C device, if there are more devices, and so on, the connection mode of 485 – is the same as that of 485 +.
2. Star topology, RS-485 Bus supports point-to-multipoint communication mode, that is, a master 485 device controls multiple slave 485 devices, and the master control devices are mostly placed in the center. If the bus topology is used for wiring, the 485 line needs to be wired around the master 485 device, and the wiring mode is complex and waste wire, Using 485 hub layout into star topology structure, the wiring structure is simple, construction and maintenance will be very convenient.
3. Tree topology. In the case of field wiring, RS-485 devices may be distributed on both sides of a trunk line. If the hand-in-hand wiring mode is adopted, it will go back and forth, resulting in waste and complex wiring structure. Therefore, it is reasonable to lay the tree topology. The difference of tree topology domain bus topology is that the branch distance of tree topology is long. Once the branch distance of RS-485 bus is long, it is very easy to form signal reflection, which leads to communication instability. Using 485 repeater as isolation can effectively ensure the stability of RS-485 bus communication.