Data Collision Communication Method Based on RS485 Communication in Automatic Measurement

By using the MCU interrupt handler function on the PA board to handle data packet loss and storing data in global variables, the problem of RS485 bus data packets being scrambled during RRU automatic polling was solved, thus achieving real-time performance and stability of RS485 communication.

CN116708072BActive Publication Date: 2026-03-06深圳市佳贤通信科技股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310689225.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-12
Publication Date
2026-03-06
Estimated Expiration
2043-06-12

AI Technical Summary

Technical Problem

When the RRU periodically and automatically queries the downlink terminal equipment parameters, the data packets on the RS485 bus are easily disrupted due to timeout response packets, leading to communication abnormalities.

Method used

The MCU on the PA board sends a response in the interrupt handler function, closes the polling packet thread on the sending end, saves data through global variables, and responds to parameter setting commands in the main loop task to ensure the real-time nature of the response.

Benefits of technology

It achieves real-time performance and stability of RS485 communication, avoids data packet collisions on the bus, shortens the response time, and improves communication efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116708072B_ABST
    Figure CN116708072B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of RS485 wired communication technology, specifically relating to a data conflict communication method based on RS485 communication in automatic measurement. This invention aims to solve the problem that when the RRU polls data from the MCU on the PPA board, the MCU on the PA board always returns a packet within a fixed time frame, while the RS485 packet return time is unpredictable, leading to unstable data transmission. This invention provides a data conflict communication method based on RS485 communication in automatic measurement. Specifically, the MCU on the PA board periodically collects the initial data of the data packet through a main loop function and saves this data in a global variable. It periodically updates the collected initial data and saves it to the global variable, determining if there is a serial port interrupt. When the MCU on the PA board receives a data packet from the RRU via a serial port interrupt, it determines whether the data packet is a polling packet through protocol parsing. In the main loop task, the global variable flag is checked to ensure that the RS485 data bus is not disrupted by delayed data packets, thus providing a data conflict communication method based on RS485 communication in automatic measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of RS485 wired communication technology, specifically relating to a data conflict communication method based on RS485 communication in automatic measurement. Background Technology

[0002] Both the host computer and the terminal device are configured manually. Due to the long delay time, RS485 data conflicts will not occur.

[0003] However, once the host computer is changed to an RRU or other upper-layer devices that periodically and automatically query the parameters of the downlink terminal devices through different threads, the data on the RS485 bus will be disrupted due to a timeout response from a certain device, causing all data packets on the bus to be jumbled and subsequent communication to be abnormal. Summary of the Invention

[0004] The technical problem solved by this invention is to address the issue that when the RRU polls for data from the MCU on the PPA board, the MCU on the PA board always responds with packets within a fixed timeframe, while the RS485 response time is unpredictable, leading to unstable data transmission. To prevent the RS485 data bus from being disrupted by delayed data packets, the following solution is implemented on the MCU side of the PA board:

[0005] The MCU on the PA board sends a response packet in the interrupt handling function, and only responds to the function action after the interrupt receiving function exits; the sending end (RRU) prioritizes setting parameter commands in the data packets sent by the serial port, and closes the polling query packet thread before sending the setting parameter commands.

[0006] The data collision communication method based on RS485 communication in automatic measurement specifically includes:

[0007] Step 1:

[0008] The MCU on the PA board periodically collects the initial data of the data packet through the main loop function and saves the data in a global variable. It also periodically updates the collected initial data and saves it in the global variable, and determines whether there is a serial port interrupt reception.

[0009] Step Two:

[0010] When the MCU serial port interrupt on the PA board receives a data packet sent by the RRU, it determines whether the data packet is a polling packet through protocol parsing.

[0011] If the polling packet is complete and correct, the MCU on the PA board parses different query IDs, groups the packets, calls the data collected by the RAM global variables, and then replies with the data packet in the interrupt; proceed to step one;

[0012] If it's a parameter setting packet instead of a polling packet, immediately respond with a reply packet in the interrupt function.

[0013] By defining a global variable `flag` and setting it, and then modifying the setting parameter in the RAM global variable,

[0014] After the interruption, return to step one. In the main loop task, check the global variable `flag` to see if the `Flag` flag is set to 1.

[0015] Yes, then it is used to issue control commands for hardware setting actions. After the action is completed, the flag is cleared and the process proceeds to step 3. This ensures the real-time performance of the MCU's return data on the PA board.

[0016] Step 3: Exit the hardware setup program and enter the main loop.

[0017] Preferably, the initial data includes reverse power, standing wave ratio, temperature, insertion loss, current, voltage, and alarm information.

[0018] Preferably, in step two, when the RRU's query thread and setting thread communicate with the MCU on the PA board, a data conflict occurs on the RS485 bus. In the process, the RRU's configuration parameter setting packet takes priority.

[0019] Step S21: PA serial port interrupt, when RRU receives the configuration command packet sent by BBU,

[0020] If the RRU configuration thread acquires the mutex lock in advance, it will disable the periodic polling of the MCU on the PA board to send tasks, and will only release the mutex lock after the PA configuration packet reply packet is received. At this time, the RRU will be allowed to send periodic polling to query the PA parameters again.

[0021] Preferably, a sequence number is added to the communication data packet protocol; the data packet issued by the RRU contains the specified sequence number information, and the MCU on the PA board specifies the sequence number in the data packet when returning the packet, ensuring the uniqueness of the MCU's return packet on the PA board; otherwise, a retransmission mechanism is initiated.

[0022] The present invention also provides a computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described above.

[0023] The beneficial effects of this invention are:

[0024] When automatically measuring terminal data, the RRU needs to periodically poll and read the PA's status parameters to ensure the real-time performance and responsiveness of the RS485 response packets.

[0025] The RS485 bus data was disrupted due to a timeout response from a device followed by the automatic transmission of the next query packet. Furthermore, while the RRU was polling the MCU status parameters on the PA board, other threads of the RRU simultaneously sent commands to set the MCU's parameters on the PA board (such as numerical control attenuation, calibration values, alarm clearing, power amplifier switching, etc.). In communication base stations, RS485 communication technology is used to ensure timely communication between any data acquisition center equipment and terminal equipment in automatic control applications. Attached Figure Description

[0026] Figure 1 This is a flowchart of the MCU's own task processing and RRU data packet receiving process on the PA board of the present invention.

[0027] Figure 2 This is a flowchart of the two threads that send serial port data packets from the RRU device of the present invention to the MCU on the PA board. Detailed Implementation

[0028] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Example 1

[0029] The commonly used mechanisms for software defects are as follows:

[0030] One approach involves receiving data via a software serial port interrupt, parsing the received data packet within the interrupt function, and then using the command ID to manipulate the hardware before sending back the data packet. However, this method suffers from drawbacks because different hardware operations take varying amounts of time. This can lead to some data packets taking too long to process, causing excessive interrupt handling and potentially resulting in a system crash.

[0031] Another method is to receive a data packet via an interrupt, determine whether it is a complete and qualified data packet, set a flag, exit the interrupt, and in the main loop task function, check the flag status to determine whether it is a qualified data packet. If it is, then parse the data packet, execute the command, and send back a packet. Enter the protocol parsing task to complete the packet return and hardware operations, and clear the flag. If it is not a complete and qualified data packet, exit the protocol parsing task function and loop to check whether the flag status needs to enter the protocol parsing task function.

[0032] However, this increases the packet return time of the MCU on the PA board, reduces the communication efficiency of RS485, and in the main loop task, parsing data packets, executing data packets, controlling hardware, and then reassembling and returning packets; due to the inconsistency in the time spent controlling different hardware, the MCU on the PA board will return "late data packets" that conflict with the RRU issuing the next polling packet, thus disrupting the entire RS485 bus.

[0033] In addition, while the upper-layer device periodically sends polling packets, the BBU also sends configuration commands. At this time, the simultaneous sending of data packets by the two threads will disrupt the data on the RS485 bus.

[0034] For example, in the field of communications, a pico base station communicates with an RF power amplifier module, that is, the RRU communicates with the MCU device on the PA board.

[0035] One scenario for data conflict is as follows: When the RRU (RemoteRadioUnit) needs to periodically poll and read the status parameters (forward power, reverse power, VSWR, temperature, insertion loss, current, voltage, alarm information, etc.) of the MCU on the PA board, the MCU on the PA board receives the query data packet, then parses the data packet, receives the query forward power parameter ID, and then performs AD acquisition, data processing and conversion, and packet assembly and reply. This process is time-varying, and it may happen that during the polling period, the MCU on the PA board has not yet replied with a data packet for this round. At this time, the BBU issues a command to configure the MCU parameters on the PA board. At this time, other Linux threads of the RRU trigger commands to set the MCU parameters on the PA board (numerical control attenuation, calibration, power amplifier switch, etc. setting commands). As a result, the parameter setting packets issued by the RRU and the PA reply packets will be mixed up on the bus.

[0036] like Figure 1-2 As shown, this embodiment provides a data conflict communication method based on RS485 communication in automatic measurement. Specifically, the MCU on the PA (Power Amplifier, RF power amplifier module) board cyclically collects forward power, reverse power, VSWR, temperature, insertion loss, current, voltage, and alarm information, and stores these parameters in global variables. When the UART interrupt receives the automatic polling measurement parameter ID sent by the RRU, the MCU on the PA board parses the data packet and directly calls the value in the global variable to assemble a response packet, shortening the response delay. By replying to the data packet during the interrupt, the PA can ensure that the response packet is received within a few microseconds, guaranteeing the real-time performance of the response. However, previously, after receiving serial port data in an interrupt or serial port polling, the main function only entered the protocol processing task after polling and finding the correct protocol packet. This time was uncertain and could be between 10 and 30 milliseconds. Then, in the protocol processing, different message types were used...

[0037] For example, the power is only read after the parsing is complete. The power reading process includes AD sampling, data processing, and data conversion, which may take 80-200 milliseconds. Then, the data is reassembled and reported back. This results in the RRU receiving the report from the MCU on the PA board in 90-230 milliseconds. The packet reception time is highly uncertain and not real-time. This can easily cause data conflicts on the RS485 bus.

[0038] Similarly, if there is a parameter setting packet, it is first sent back during the interrupt. Only after exiting the interrupt does the setting action issued by the RRU to control the RF device occur in the loop task, ensuring the real-time performance of the RS485 packet return. This prevents RS485 bus data conflicts caused by the unpredictable time taken for the MCU on the PA board to process data due to the control of a specific ID parameter on the hardware, or by packet return delays.

[0039] Specific experimental results are shown in the following examples:

[0040] Before modification: The response time after the host computer sends a packet is unpredictable, ranging from 500ms to 100ms.

[0041]

[0042] Data packets are scrambled during RRU automatic measurement due to RS485 polling:

[0043]

[0044] After modification: A response will be sent every time within 20ms after the packet is sent.

[0045] ,

[0046] In the above examples, the reaction time can be significantly shortened.

[0047] In communication base stations, any automatic control of data acquisition center equipment and terminal equipment can be applied as long as RS485 communication is used.

[0048] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A data collision communication method in automatic measurement based on RS485 communication, characterized in that, Specifically comprising: Step one: The MCU on the PA board collects the initial data of the data packet through the main loop function and saves the data in the global variable, updates the collected initial data and saves it to the global variable, and determines whether there is a serial port interrupt reception; Step two: When the MCU on the PA board receives the data packet sent by the RRU through the serial port interrupt, it is determined whether the data packet is a polling packet through protocol analysis; If it is a polling packet, the PA board MCU parses different query IDs, divides and groups packets, calls the data collected by the RAM global variable, and then replies to the data packet in the interrupt; enter step one; If it is not a polling packet, it is a parameter setting packet. First, reply to the data packet in the interrupt function, set a global variable flag, and change the setting parameter to the RAM global variable. After the interrupt, return to step one. In the main loop task, judge the global variable flag. If the flag is 1, it is used to control the setting action of the hardware. After the action is completed, clear the flag, and enter step three, which can ensure the real-time of the PA board MCU's reply data. Step three: exit the hardware setting program and enter the main loop; The initial data includes reverse power, standing wave, temperature, insertion loss, current, voltage and alarm information; In step two, when the RRU query thread and the setting thread communicate with the MCU on the PA board, data conflict occurs on the RS485 bus. In the process, the RRU parameter setting packet is given priority. Step S21: PA serial port interrupt, when the RRU receives the configuration command packet issued by the BBU, if yes, the RRU configuration thread acquires the mutual exclusion lock in advance. At this time, the timing cycle polling PA board MCU issuing task is closed, and the mutual exclusion lock is released after the PA configuration packet reply packet. At this time, the RRU is allowed to issue the timing polling query PA parameter packet again. Add the sequence number of the data packet in the communication data packet protocol. The data packet sent by the RRU contains the specified sequence number information, and the MCU on the PA board specifies the sequence number when replying to the packet, which ensures the uniqueness of the PA board MCU reply packet, otherwise the retransmission mechanism is started.

2. A computer storage medium having stored thereon a computer program, characterized in that The program is executed by the processor to realize the steps of the method of claim 1.

Citation Information

Patent Citations

  • RS485-based polling communication method

    CN105007209A

  • Wireless communication method and system based on LoRa technology, and communication equipment

    CN112863158A