Protocol-based design scheme for improving real-time performance of RS 485 bus

Some existing studies have adopted hardware modification and CSMA/CD methods to make the system have a multi-master structure, thereby improving real-time performance, but the implementation is more complicated. A protocol-based design scheme for improving the real-time performance of the RS 485 bus is proposed. This scheme does not require hardware modification, requires no additional resources, and requires simple program modification. The experimental results show that the scheme can effectively improve the real-time performance of the system.

0 Preface

RS 485 bus has many advantages such as simple structure, low cost, high communication speed and long transmission distance, so it is widely used in factory automation, industrial control, security monitoring and other fields. RS 485 generally adopts half-duplex communication mode, that is, only one node can be in the transmitting state and send data to the bus at any time in the whole network. If two or more nodes send data to the bus at the same time, Causes all sent data to fail to be sent, a so-called bus collision.

In order to avoid bus collisions, the entire RS 485 communication system generally consists of one master node and multiple slave nodes. Data communication generally uses the way the primary node polls each slave node. Each slave node has its own communication address. Only when the address information in the polling frame of the master node is the same as its own address, the slave node will reply, and the other slave nodes ignore the frame and do nothing. This traditional master-slave scheduling method does not cause bus collisions, but it also has some limitations. The slave node needs to send data and waits until the master node polls itself. The communication efficiency of the system is low and the bus utilization rate is low. Each slave node only has one chance to send data in one polling cycle. The information with real-time requirements cannot be sent in time, and the real-time performance of the system is poor.

In order to improve the real-time performance of the RS 485 communication system, some research work has been carried out at home and abroad. Most of them use the software and hardware transformation of RS 485 to make it have a multi-master structure, so that the slave nodes can randomly transmit data. The proposed implementation method is to connect the data receiving pin of the RS 485 interface chip to the external interrupt pin of the CPU through an inverter, and determine whether there is data transmission on the bus by triggering the interrupt, and judging whether the bus is combined with the timer interrupt. Idle; if the bus is idle, the bus control right is sent to send data, and then the method of monitoring the data sent by itself is used to judge whether a bus collision occurs. If a collision occurs, the random delay is delayed for a period of time, and then the transmission is re-listened. The method is similar. These methods generally require additional hardware resources and require hardware modification of the original device. The collision handling mentioned in the method generally adopts the CSMA/CD random backoff algorithm, which is complicated to implement, and the time is unpredictable, and the real-time requirement cannot be guaranteed.

This paper proposes a new protocol-based method that does not require hardware modification and does not require additional resources. It requires only simple modifications to the software to upgrade the RS 485 communication system and improve the ability of the slave node to send data autonomously. System communication efficiency and real-time.

1 Working principle

The communication system still adopts the structure of one master node and multiple slave nodes. Each time the master node polls a slave node, it leaves a gap time for the slave node to actively upload information on demand. If the slave node needs to upload information with real-time requirements, it can upload it when the master node polls itself, and can also upload it when it is in the gap. Firstly, the order in which the slave nodes upload data in the gap, that is, the acquisition mechanism of the upload opportunity is specified. One method is to allocate the time slice according to the priority, and the slave node can only use the gap to upload data when the specified sending opportunity is acquired. If there are multiple slave nodes in a gap that need to upload data, the slave node needs to listen to the state of the bus while waiting for its own transmission opportunity. If it detects that there are other nodes on the bus for data transmission, the slave node You must give up this opportunity to upload the gap and wait for the next gap.

Through theoretical analysis, the real-time performance of the new method proposed in this paper and the traditional polling method can be compared. A transmission unit consists of 1 start bit, 8 data bits, 1 check bit, and 1 stop bit. The transmission time of a transmission unit is called byte time Tbyte and the baud rate is baudrate.

A transmission unit consists of 1 start bit, 8 data bits, 1 check bit, and 1 stop bit. The transmission time of a transmission unit is called byte time Tbyte and the baud rate is baudrate.

Let the length of the polling frame sent by the master node be Lmaster, the length of the data frame replied by the slave node is fixed to Lslave, and the number of slave nodes is N. It is assumed that all slave nodes are normal, and the time-effects such as transceiver state switching, frame interval, and program processing are removed. Then the ideal theoretical value of a polling cycle Tcycle is:

Then the ideal theoretical value of a polling cycle Tcycle

If the new method proposed in this paper is used, it is assumed that the information of the real-time requirements of the slave nodes requires an average of x (0 ? x ? N - 1) gaps to acquire the bus, and the response time Trespons' average is:

Then the response time Trespons' average is:

When x = N - 1, the response time Trespons' maximum is:

When x = N - 1, the response time Trespons' maximum is:

The real-time data with the new method has a shorter average response time and better real-time performance of the system.

It can be seen from equations (3) and (6) that the response time of the new method is longer than the worst case response time of the conventional polling method in the worst case, about twice. Based on the above analysis, the real-time performance of the new method and the traditional method is determined by the average required number of gaps x. The new method is applicable to the occasions where the time-required information of each slave node is relatively discrete and has few collisions.

WEICHAI Generator Set

Weichai Generator Set,Power Genset,Diesel Generator Set,Prime Power Genset

Yangzhou Hengyuan Electromechanical Equipment Co., Ltd. , https://www.lchypower.com