An RS-485 bus polling optimization method and system for DCIM data center infrastructure monitoring scenarios

By introducing a data transfer adapter into the RS-485 bus to perceive data changes at the edge, the problems of low bus utilization and polling latency in DCIM data center infrastructure monitoring are solved, achieving efficient communication optimization and real-time performance improvement, and possessing good compatibility and reliability.

CN123123069APending Publication Date: 2026-11-17BEIJING ZHONGYI YUETAI SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611260464.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-19
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

The existing RS-485 bus has problems in DCIM data center infrastructure monitoring scenarios, such as low bus utilization, polling latency worsening with the number of devices, and lack of change perception capability at the edge, resulting in insufficient communication bandwidth utilization and difficulty in meeting real-time requirements.

Method used

By introducing a data relay adapter, data changes are detected at the edge. The current full data is compared with historical data using an independent collection cycle. The device with data changes is filtered out using the flag query command. Only the device with the change is read in full, reducing redundant communication.

Benefits of technology

It significantly reduces communication polling latency, improves system real-time performance and bus bandwidth utilization, has excellent compatibility and reliability with existing equipment, reduces technology upgrade costs, and enhances system scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123123069A_ABST
    Figure CN123123069A_ABST
Patent Text Reader

Abstract

This invention discloses an RS-485 bus polling optimization method and system for DCIM data center infrastructure monitoring scenarios, belonging to the field of industrial IoT communication technology. The method includes: on the data relay adapter side, actively collecting full data from slave devices according to a collection cycle independent of the master controller, and comparing it with historical data to update the local change flag register status; on the master controller side, prioritizing sending a flag bit query instruction with an extremely short frame length to the adapter, and only initiating a full data read instruction and a reset instruction when the flag register status indicates that the data has changed, otherwise skipping the device and proceeding to the next polling. This invention, by introducing a data relay adapter with edge computing capabilities, achieves decentralized data change awareness and a low-overhead two-level polling mechanism, significantly reducing polling communication latency and greatly improving the effective utilization rate and real-time performance of the RS-485 bus without changing the existing slave device protocol.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial automation and data center infrastructure monitoring technology, and in particular to an RS-485 bus polling optimization method and system for DCIM data center infrastructure monitoring scenarios. Background Technology

[0002] The RS-485 (TIA / EIA-485) bus is widely used in industrial automation, building automation, and data center infrastructure monitoring (DCIM) due to its balanced differential transmission and multi-node capability. Its typical network topology is a master-slave half-duplex architecture, where a master controller manages multiple slave devices on the bus sequentially through polling. In practical applications, the Modbus RTU protocol is typically used as the communication standard.

[0003] In traditional solutions, the master controller must initiate a complete "query-response" communication cycle for each slave device according to a preset slave device address order. Regardless of whether the slave device's data has changed, the master controller needs to send a complete query frame and receive a complete data frame. This "blind polling" mode has the following significant drawbacks:

[0004] Extremely low bus utilization: In DCIM scenarios, the data change frequency of devices such as temperature and humidity sensors and asset positioning tags is extremely low, with the stable period often exceeding 90%. A large amount of communication bandwidth is used to repeatedly transmit redundant data that has not changed, resulting in an effective data transmission rate of less than 20%.

[0005] Polling latency deteriorates linearly with the number of devices: As the number of devices connected to a single bus increases (e.g., 32 devices), the accumulated communication latency causes the data refresh cycle of the entire monitoring system to increase linearly, making it difficult to meet the real-time requirements (e.g., refresh within 3000ms) of the DCIM centralized control system.

[0006] The edge side lacks change perception capabilities: existing standard RS-485 slave devices are mostly "dumb" devices, lacking the ability to proactively judge and notify of data changes. All change perception logic relies entirely on the main controller, leading to system rigidity.

[0007] Current optimization attempts mainly focus on shortening timeouts, event-driven reporting, or protocol upgrades. However, shortening timeouts is limited by the characteristics of physical signal transmission, leaving little room for improvement; event-driven reporting is prone to conflicts on RS-485 half-duplex buses; and protocol upgrades require modifications to existing equipment, which are extremely costly and difficult to achieve compatibility.

[0008] Therefore, there is an urgent need for a polling optimization scheme that can effectively reduce redundant data transmission without changing the existing slave device protocol and physical topology. Summary of the Invention

[0009] This invention aims to solve the above-mentioned technical problems and provides an RS-485 bus polling optimization method and system for DCIM data center infrastructure monitoring scenarios. Without changing the existing slave device communication protocol, it significantly reduces polling latency and improves bus utilization by sensing data changes at the edge.

[0010] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0011] In a first aspect, the present invention provides an RS-485 bus polling optimization method based on data change-driven operation, applied to an RS-485 bus communication system including a master controller, a data transfer adapter, and slave devices, wherein the data transfer adapter is connected in series between the master controller and the slave devices, and the method includes:

[0012] Steps performed on the data transfer adapter side:

[0013] S1. According to the preset independent acquisition cycle, send standard data reading instructions to the connected slave device and receive the current full data returned by the slave device. The independent acquisition cycle is decoupled from the polling cycle of the main controller.

[0014] S2. Compare the current full data with the historical full data stored locally to determine if the data has changed;

[0015] S3. If it is determined that the data has changed, the state of the locally set change flag register is set to the first state, and the historical data buffer is updated using the current full data; if it is determined that the data has not changed, the state of the change flag register is kept in the second state.

[0016] Steps performed on the main controller side:

[0017] S4. Send a flag query instruction to the target data relay adapter according to the polling scheduling strategy. The flag query instruction is a custom short frame, and its request frame length is less than the frame length of the standard full data read instruction.

[0018] S5. Receive the flag status response returned by the target data transfer adapter in response to the flag bit query instruction, and parse it to obtain the current state of the change flag register;

[0019] S6. Determine if the current state is the first state;

[0020] S7. If the current state is the first state, send a full data read instruction to the target data transfer adapter to obtain the data in the historical data buffer, and send a flag bit reset instruction to reset the change flag register to the second state;

[0021] S8. If the current state is the second state, skip the step of sending a full data read instruction to the target data relay adapter and directly poll the next target data relay adapter.

[0022] Furthermore, in step S2, the current full data is compared with the historical full data stored locally, specifically including:

[0023] Calculate the hash value of the current full data and compare it with the historical hash values ​​of the historical full data;

[0024] Alternatively, extract key fields from the current full data and determine whether the change in the current value of the key field relative to the historical value exceeds a preset threshold.

[0025] Furthermore, it also includes anomaly detection and fault tolerance steps:

[0026] The main controller counts the number of consecutive times the change flag register remains in the second state within a continuous polling cycle;

[0027] When the number of consecutive heartbeats reaches the preset heartbeat threshold, the current state of the change flag register is ignored, and a full data read command is forcibly sent to the target data relay adapter to verify the normality of the communication link.

[0028] Furthermore, in step S1, if the data transfer adapter does not receive a valid response within a preset waiting time after sending a standard data read instruction to the slave device, a communication failure is determined, and the state of the change flag register is set to the third state.

[0029] Step S6 is followed by: if the current state is the third state, the main controller generates and outputs communication fault alarm information for the slave device.

[0030] Furthermore, the data transfer adapter's response flag query instruction specifically includes:

[0031] The data transfer adapter parses the flag query instruction locally, directly reads the status bits of the change flag register, and constructs a response frame based on the status bits;

[0032] The generation of response frames does not depend on data interaction with slave devices.

[0033] Secondly, the present invention provides a data change-driven RS-485 bus polling optimization system, comprising:

[0034] The main controller is equipped with an optimized round-robin scheduling module, which is used to perform the following operations:

[0035] Send a flag query command to the data transfer adapter;

[0036] Receive the returned flag status response and parse the current state of the change flag register;

[0037] If the current state is the first state, a full data read instruction is sent to acquire data, and a flag reset instruction is sent; if the current state is the second state, the full data read operation is skipped.

[0038] The data transfer adapter connects the RS-485 bus to the slave device and integrates a device communication interface module, a change detection module, a change flag register, a historical data buffer, and a bus communication interface module.

[0039] The device communication interface module is used to actively collect all current data from the device according to an independent collection cycle;

[0040] The change detection module is used to compare the current full data with the historical full data in the historical data buffer, and update the change flag register according to the comparison result;

[0041] The bus communication interface module is used to respond to the main controller's commands; when a flag query command is detected, a response is generated based on the status of the locally stored change flag register; when a full data read command is detected, data in the historical data buffer is read and a response is generated.

[0042] Furthermore, the data transfer adapter also includes a hardware watchdog, which is used to monitor the operating status of the data transfer adapter;

[0043] When an abnormal reset is detected, the change flag register is initialized to the first state by default.

[0044] Furthermore, the flag query command and the full data read command are based on the Modbus RTU protocol. The flag query command uses a custom function code and the request frame length is 4 bytes.

[0045] The beneficial effects of this invention are:

[0046] Significantly reduces communication polling latency and improves system real-time performance:

[0047] This invention introduces a "lightweight tag query" mechanism, enabling the main controller to quickly filter data status. When data remains unchanged, the main controller only needs to complete a very short tag query interaction to skip that device, avoiding the need for a complete full data read process for unchanged devices. This strategy significantly reduces the effective time of a single polling cycle, allowing the system to complete the inspection of all devices within a shorter time window, thus significantly improving the system's real-time response speed.

[0048] Significantly improve the effective utilization of bus bandwidth:

[0049] This invention decentralizes the data change sensing and judgment logic to the edge-side data transfer adapter. By replacing the traditional "full data transport" with a "state probe," the amount of redundant data transmission on the bus is greatly reduced. In typical application scenarios where most device data is in a static state, the communication traffic carried by the bus mainly consists of extremely short instruction frames, thereby freeing up a large amount of valuable bus bandwidth resources and effectively alleviating the communication congestion problem of the RS-485 bus.

[0050] It possesses excellent compatibility with existing equipment and plug-and-play capabilities:

[0051] This invention achieves transparent relaying of the protocol through a cascaded data relay adapter. The adapter simulates a standard Modbus slave station upstream and a standard Modbus master station downstream. This dual-modal design allows the system to seamlessly integrate into existing RS-485 networks without requiring any hardware modifications or firmware upgrades to existing slave devices. This significantly reduces technology upgrade costs and implementation difficulty, protecting the user's existing investment.

[0052] Enhance system reliability and fault detection sensitivity:

[0053] This invention constructs a mechanism combining proactive edge monitoring with central fault tolerance. The data relay adapter continuously monitors the status of slave devices using an independent acquisition cycle, supplemented by a hardware watchdog and heartbeat detection mechanism, ensuring timely fault flag setting in the event of communication link interruption or device failure. This dual protection enables the main controller to quickly detect and locate abnormal devices, significantly improving the system's robustness and fault response sensitivity compared to traditional timeout-based passive detection methods.

[0054] Improve system scalability:

[0055] Because this invention effectively reduces the average communication time per polling cycle, the number of devices that can be connected to a single RS-485 bus increases significantly while maintaining the same time accuracy requirements. This provides feasible infrastructure support for building large-scale, high-density IoT monitoring systems. Attached Figure Description

[0056] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0057] Figure 1 A flowchart of the polling optimization method provided in an embodiment of the present invention.

[0058] Figure 2 The overall architecture diagram of the RS-485 bus polling optimization system provided in the embodiments of the present invention is shown.

[0059] Figure 3 This is a structural diagram of the internal functional modules of the data transfer adapter in an embodiment of the present invention.

[0060] Figure 4 This is a schematic diagram comparing the communication timing of the embodiments of the present invention with that of the traditional polling method. Detailed Implementation

[0061] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0062] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0063] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0064] Reference Figures 1-4 This is one embodiment of the present invention, which provides a data change-driven RS-485 bus polling optimization method applied to an RS-485 bus communication system including a master controller, a data transfer adapter, and slave devices. The data transfer adapter is connected in series between the master controller and the slave devices. The method includes:

[0065] Steps performed on the data transfer adapter side:

[0066] S1. According to a preset independent acquisition cycle, send a standard data read command to the connected slave device and receive the current full data returned by the slave device, wherein the independent acquisition cycle is decoupled from the polling cycle of the main controller:

[0067] This step specifically includes:

[0068] After the data transfer adapter is powered on and initialized, the microcontroller unit inside S1.1 is configured with an independently running hardware timer, and its overflow interrupt time is set to a preset high-frequency time interval (e.g., 500 milliseconds), thereby establishing a "shadow polling" clock source that does not depend on the main loop cycle of the main controller.

[0069] S1.2 When the timer overflow interrupt is triggered, the adapter, as a "shadow master", automatically constructs a standard data read instruction frame conforming to the Modbus RTU protocol (such as function code 0x03) and physically sends the instruction to the connected slave device through its downlink RS-485 interface, requesting the slave device to return the data of all its current registers.

[0070] The S1.3 adapter's communication module immediately starts receiving and listening after sending the command, capturing the complete response frame returned from the device, which includes the device address, function code, data content, and checksum. It then performs CRC verification internally, and after the verification passes, it temporarily stores the current full data in the receive buffer in the random access memory (RAM).

[0071] S2. Compare the current full data with the historical full data stored locally to determine whether the data has changed:

[0072] This step specifically includes:

[0073] S2.1 The adapter calls the data processing subroutine to preprocess the current full data in the receive buffer. Specifically, this includes calculating the CRC32 or MD5 hash value of the data segment, or extracting key analog fields to generate a feature code or numerical sequence that can represent the characteristics of the current data.

[0074] The S2.2 adapter compares the generated current data feature code bit by bit with the historical full data feature code pre-stored in non-volatile memory or a specific RAM area, or directly performs a bitwise XOR operation on the current data packet and the historical data packet to detect whether there is a bit difference.

[0075] S2.3 Generate a status flag signal based on the comparison or operation result. If the feature codes are inconsistent or the XOR result is non-zero, it is determined that the data has changed and a "changed" signal is generated; if the feature codes are consistent or the XOR result is zero, it is determined that the data has not changed and a "no change" signal is generated.

[0076] S3. If it is determined that the data has changed, the state of the locally set change flag register is set to the first state, and the historical data buffer is updated using the current full data; if it is determined that the data has not changed, the state of the change flag register is maintained in the second state.

[0077] This step specifically includes:

[0078] S3.1 When the data changes, the adapter copies the current full data in the receive buffer to the historical data buffer to update the local cache, ensuring that the latest state is stored. At the same time, it writes a preset high-level logic value (e.g., logic 1) to the specified "change flag register" memory address to set the state to the first state.

[0079] S3.2 When it is determined that the data has not changed, the adapter keeps the contents of the historical data buffer unchanged and does not perform data overwrite operation to reduce memory consumption. At the same time, it keeps the "change flag register" at a preset low logic value (e.g., logic 0), that is, it keeps the second state.

[0080] S3.3 Regardless of whether the data changes, the adapter completes the status update operation for this round of data acquisition, and then enters low-power standby mode or waits for the next timer interrupt to maintain real-time synchronization of the data status on the edge side.

[0081] S4. Send a flag bit query instruction to the target data relay adapter according to the polling scheduling strategy. The flag bit query instruction is a custom short frame, and its request frame length is less than the frame length of the standard full data read instruction.

[0082] This step specifically includes:

[0083] The scheduling module of the S4.1 main controller prepares to poll the current target address according to the preset device address list order. First, it constructs a very short "mark bit query instruction". This instruction only contains the target address, a custom function code (such as 0x41) and a check code, without a data field, and the total length is compressed to 4 bytes.

[0084] The S4.2 master controller sends the constructed flag query command to the bus via its uplink RS-485 interface. This command acts as a low-overhead heartbeat probe to quickly detect whether new data has been generated inside the target data transfer adapter, without requesting a specific value.

[0085] The S4.3 main controller starts a microsecond-level timeout timer while sending the command, preparing to receive the data relay adapter's immediate response to the query command, ensuring the efficiency and timeliness of the communication process.

[0086] S5. Receive the flag status response returned by the target data transfer adapter in response to the flag query instruction, and parse it to obtain the current state of the change flag register:

[0087] This step specifically includes:

[0088] The serial port interrupt service routine of the S5.1 main controller captures the response frame data stream returned by the data relay adapter. This response frame is generated by the adapter directly reading the local register, contains status information and is extremely short. The main controller performs CRC check on it to eliminate bus noise interference.

[0089] The S5.2 main controller parses the response frame after the verification is passed, extracts the data field bytes, and directly maps these bytes to the real-time logic value of the "change flag register" at the data transfer adapter end.

[0090] The S5.3 main controller performs state decoding based on the extracted logic values, converting binary values ​​into explicit internal system state identifiers. For example, it decodes the value "1" as "data updated" and the value "0" as "data at rest", providing input parameters for subsequent decision-making steps.

[0091] S6. Determine whether the current state is the first state:

[0092] This step specifically includes:

[0093] The logic judgment unit of the S6.1 main controller performs a strict equality comparison between the decoded current state identifier and the preset "first state" identifier, performs Boolean logic judgment operations, and determines whether a data update event exists.

[0094] S6.2 Determine the program execution branch based on the Boolean operation result. If the comparison result is true, it is determined that there is new data on the device side, and the program jumps to the data reading subroutine. If the comparison result is false, it is determined that there is no new data on the device side, and the program jumps to the polling skip subroutine.

[0095] S7. If the current state is the first state, then send a full data read instruction to the target data transfer adapter to obtain the data in the historical data buffer, and send a flag reset instruction to reset the change flag register to the second state:

[0096] This step specifically includes:

[0097] S7.1 When the first state is determined, the main controller reconstructs a standard full data read instruction (such as function code 0x03) containing a complete data field request and sends it to the adapter. Then, it receives the updated historical buffer data forwarded by the adapter and parses and stores it in the application layer database of the main controller.

[0098] After successfully acquiring and storing all the data, the main controller sends a special "flag reset instruction" (such as custom function code 0x42 or write register instruction) to instruct the adapter to clear the logical value of the change flag register to zero, resetting it to the second state to eliminate the flag of this change.

[0099] After the S7.3 main controller completes the read and write operations on the current target device, it updates the last communication timestamp of the device and returns control to the polling scheduling module, preparing to end the polling process of the current device.

[0100] S8. If the current state is the second state, skip the step of sending the full data read instruction to the target data relay adapter, and directly poll the next target data relay adapter:

[0101] This step specifically includes:

[0102] S8.1 When the second state is determined, the main controller triggers the filtering logic to directly suppress the sending program of the standard full data read command for the device and prohibit the communication interface from sending long frame data requests, thereby saving bus time.

[0103] The pointer management logic of the S8.2 main controller directly increments the current polling address pointer by one, pointing to the next target data transfer adapter in the address list, and immediately prepares to initiate a query for the flag bit of the next device, thus achieving seamless switching.

[0104] The S8.3 main controller marks the currently skipped device as "static polling passed" and records a polling event with no data change for subsequent statistical analysis of device activity or heartbeat timeout checks, and then seamlessly enters the next loop.

[0105] Furthermore, in step S2, the current full data is compared with the historical full data stored locally, specifically including:

[0106] Calculate the hash value of the current full data and compare it with the historical hash values ​​of the historical full data;

[0107] Alternatively, extract key fields from the current full data and determine whether the change in the current value of the key field relative to the historical value exceeds a preset threshold.

[0108] In this embodiment, the specific algorithm for data comparison can be implemented in two ways. The first method is hash comparison: After receiving the current full data frame from the slave device, the data relay adapter calculates the hash value of the data segment using CRC32 or MD5 algorithms. Simultaneously, it reads the hash value of the previous frame from the local historical data buffer and compares the two values. If the values ​​differ, it is determined that the data has changed. The second method is threshold comparison: The adapter extracts key numerical fields from the data frame, such as the temperature value, calculates the absolute value of the difference between the current temperature value and the historical temperature value, and compares this difference with a preset threshold (e.g., 0.5 degrees). If the difference exceeds the threshold, it is determined that the data has changed.

[0109] Furthermore, it also includes anomaly detection and fault tolerance steps:

[0110] The main controller counts the number of consecutive times the change flag register remains in the second state within a continuous polling cycle;

[0111] When the number of consecutive heartbeats reaches the preset heartbeat threshold, the current state of the change flag register is ignored, and a full data read command is forcibly sent to the target data relay adapter to verify the normality of the communication link.

[0112] In this embodiment, to prevent the communication link status from becoming unknown due to prolonged periods without data changes from a device, a heartbeat detection mechanism is introduced. During the polling process, the main controller maintains a counter for each device. When the main controller detects that a device's change flag register has repeatedly (e.g., 10 times) returned "second state" (no change), the system determines that a preset heartbeat threshold has been reached. At this point, the main controller ignores the current flag state and forcibly sends a standard full data read command to the device's data relay adapter. The purpose of this forced read is not to obtain changed data, but to trigger a complete handshake communication to verify whether the physical link between the slave device and the adapter is functioning properly, thereby ensuring communication reliability.

[0113] Furthermore, in step S1, if the data transfer adapter does not receive a valid response within a preset waiting time after sending a standard data read instruction to the slave device, a communication failure is determined, and the state of the change flag register is set to the third state.

[0114] Step S6 is followed by: if the current state is the third state, the main controller generates and outputs communication fault alarm information for the slave device.

[0115] In this embodiment, the detection logic for communication faults is as follows: After the data relay adapter sends a standard data read command to the slave device according to the independent acquisition cycle, it starts an internal timeout timer. If the adapter fails to receive any valid response signal from the slave device within a preset waiting time (e.g., 100 milliseconds), or if the received signal verification fails, the adapter determines that the slave device is offline or faulty. At this time, the adapter sets the state of its internal change flag register to a special "third state" (e.g., set to 2). Subsequently, when the master controller polls the device and sends a flag query command, the parsed current state is "third state". After recognizing this state, the master controller no longer attempts to read data, but instead generates a communication fault alarm message for the slave device in the human-machine interface or monitoring log, prompting maintenance personnel to perform maintenance.

[0116] Furthermore, the data transfer adapter's response flag query instruction specifically includes:

[0117] The data transfer adapter parses the flag query instruction locally, directly reads the status bits of the change flag register, and constructs a response frame based on the status bits;

[0118] The generation of response frames does not depend on data interaction with slave devices.

[0119] In this embodiment, the data relay adapter employs a differentiated local processing mechanism for command responses. Specifically, when the adapter's bus communication interface module receives a command frame from the master controller and parses it to reveal the function code as "flag query," the adapter immediately stops forwarding the command to downstream slave devices. The adapter's central processing unit directly accesses the change flag register in its memory, reads the current 0 or 1 state, and encapsulates it into a response frame according to the Modbus protocol format. The entire response process is completed locally by the adapter, without sending any signals to the slave devices or waiting for their responses. This mechanism ensures that even if the slave devices respond slowly or malfunction, the master controller can obtain status information extremely quickly.

[0120] Secondly, the present invention provides a data change-driven RS-485 bus polling optimization system, comprising:

[0121] The main controller is equipped with an optimized round-robin scheduling module, which is used to perform the following operations:

[0122] Send a flag query command to the data transfer adapter;

[0123] Receive the returned flag status response and parse the current state of the change flag register;

[0124] If the current state is the first state, a full data read instruction is sent to acquire data, and a flag reset instruction is sent; if the current state is the second state, the full data read operation is skipped.

[0125] The data transfer adapter connects the RS-485 bus to the slave device and integrates a device communication interface module, a change detection module, a change flag register, a historical data buffer, and a bus communication interface module.

[0126] The device communication interface module is used to actively collect all current data from the device according to an independent collection cycle;

[0127] The change detection module is used to compare the current full data with the historical full data in the historical data buffer, and update the change flag register according to the comparison result;

[0128] The bus communication interface module is used to respond to the main controller's commands; when a flag query command is detected, a response is generated based on the status of the locally stored change flag register; when a full data read command is detected, data in the historical data buffer is read and a response is generated.

[0129] In this embodiment, the system hardware architecture is divided into two main parts. The main controller internally runs an optimized polling scheduling software module, responsible for executing the aforementioned polling strategy. The data relay adapter is an embedded intelligent device, internally divided into five functional units through circuit integration and software configuration: a device communication interface module responsible for physically connecting the slave devices below and driving data acquisition; a change detection module responsible for running the data comparison algorithm; a change flag register used to store the comparison result status; a historical data buffer used to temporarily store the latest data; and a bus communication interface module responsible for physically connecting the RS-485 bus above. During operation, the device communication interface module continuously sends the acquired data to the change detection module, which updates the flag register and buffer. When the bus communication interface module hears a flag query command from the main controller, it directly reads the value of the change flag register to reply; when it hears a full read command, it directly extracts data from the historical data buffer, encapsulates it into a frame, and replies, thus achieving a fast local response.

[0130] Furthermore, the data transfer adapter also includes a hardware watchdog, which is used to monitor the operating status of the data transfer adapter;

[0131] When an abnormal reset is detected, the change flag register is initialized to the first state by default.

[0132] In this embodiment, to improve the system's anti-interference capability and stability, the data transfer adapter's circuit design includes a hardware watchdog chip. This watchdog chip runs independently of the adapter's main control program and continuously monitors the main control program's "feed" signal. If the adapter is subjected to strong electromagnetic interference, causing the program to crash or deadlock and failing to feed the watchdog in time, the hardware watchdog will force a reset of the adapter's central processing unit. In the adapter's startup initialization code, a piece of logic is set: after a reset and restart, the default value of the change flag register is forcibly initialized to "first state". The purpose of this is that when the main controller polls the device again, it will find the state is "changed," thereby forcing the main controller to reread the data and reset the state. This is equivalent to an implicit system self-check and synchronization recovery process, avoiding data update stagnation caused by state loss after the adapter restarts.

[0133] Furthermore, the flag query command and the full data read command are based on the Modbus RTU protocol. The flag query command uses a custom function code and the request frame length is 4 bytes.

[0134] In this embodiment, the communication protocol is based on the standard Modbus RTU protocol, but with modifications and extensions. Both the flag query instruction and the full data read instruction follow the Modbus RTU frame structure, including the slave address, function code, data field, and checksum. To further shorten communication time, the flag query instruction is designed with a custom function code (e.g., 0x41), and its data field is empty, containing only the address, function code, and checksum, making the entire request frame only 4 bytes long. This extremely short frame structure minimizes bus occupancy time, and combined with the master controller's fast polling strategy, significantly improves the overall system communication efficiency.

[0135] In summary, this invention achieves real-time pre-fetching and updating of edge-side data by actively collecting and caching slave device data in an independent cycle decoupled from the main controller through a data relay adapter. This eliminates the inherent delay caused by the main controller waiting for slave device responses during polling, thus ensuring data immediacy.

[0136] By comparing the current full data with historical data locally on the data transfer adapter and maintaining the change flag register, the edge of the data change perception logic is realized. This enables the main controller to quickly filter out active devices using extremely short instruction frames, without having to perform invalid protocol interactions with static devices.

[0137] By prioritizing the sending of flag bit query commands by the main controller and skipping the full data reading step directly when it is confirmed that the data has not changed, the amount of redundant data transmission on the RS-485 bus is greatly reduced, thereby significantly shortening the polling cycle of the entire system and greatly improving the effective communication bandwidth utilization of the bus.

[0138] By utilizing the local storage of historical data buffers to directly respond to the master controller's full data read request, it is possible to eliminate the need to wake up or access the slave device again when the master controller requests data, thereby further reducing the communication time and system power consumption of a single data interaction.

[0139] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A RS-485 bus polling optimization method based on data change driven, characterized in that, An RS-485 bus communication system comprising a master controller, a data transfer adapter, and slave devices, wherein the data transfer adapter is connected in series between the master controller and the slave devices, the method comprising: Steps performed on the data transfer adapter side: S1. According to a preset independent acquisition cycle, send a standard data reading command to the connected slave device and receive the current full data returned by the slave device, wherein the independent acquisition cycle is decoupled from the polling cycle of the main controller; S2. Compare the current full data with the historical full data stored locally to determine whether the data has changed; S3. If it is determined that the data has changed, the state of the locally set change flag register is set to the first state, and the historical data buffer is updated using the current full data; if it is determined that the data has not changed, the state of the change flag register is kept in the second state. Steps performed on the main controller side: S4. Send a flag bit query instruction to the target data relay adapter according to the polling scheduling strategy. The flag bit query instruction is a custom short frame, and its request frame length is less than the frame length of the standard full data read instruction. S5. Receive the flag status response returned by the target data transfer adapter in response to the flag query instruction, and parse it to obtain the current state of the change flag register; S6. Determine whether the current state is the first state; S7. If the current state is the first state, then send a full data read instruction to the target data transfer adapter to obtain the data in the historical data buffer, and send a flag bit reset instruction to reset the change flag register to the second state; S8. If the current state is the second state, skip the step of sending the full data read instruction to the target data relay adapter and directly poll the next target data relay adapter.

2. The method of claim 1, wherein, In step S2, comparing the current full data with the historical full data stored locally specifically includes: Calculate the hash value of the current full data and compare it with the historical hash value of the historical full data; Alternatively, extract key fields from the current full data and determine whether the change in the current value of the key field relative to the historical value exceeds a preset threshold.

3. The method of claim 1, wherein, It also includes anomaly detection and fault tolerance steps: The main controller counts the number of consecutive times the change flag register remains in the second state within a continuous polling cycle; When the number of consecutive beats reaches a preset heartbeat threshold, the current state of the change flag register is ignored, and the full data read instruction is forcibly sent to the target data relay adapter to verify the normality of the communication link.

4. The method of claim 1, wherein, In step S1, if the data relay adapter does not receive a valid response within a preset waiting time after sending a standard data read instruction to the slave device, a communication failure is determined, and the state of the change flag register is set to the third state. Step S6 is followed by: if the current state is the third state, the main controller generates and outputs communication fault alarm information for the slave device.

5. The method of claim 1, wherein, The data relay adapter's response to the flag query instruction specifically includes: The data relay adapter parses the flag query instruction locally, directly reads the status bit of the change flag register, and constructs a response frame based on the status bit; The generation process of the response frame does not depend on data interaction with the slave device.

6. A data change driven RS-485 bus polling optimization system, comprising: include: The main controller is equipped with an optimized round-robin scheduling module, which is used to perform the following operations: Send a flag query command to the data transfer adapter; Receive the returned flag status response and parse the current state of the change flag register; If the current state is the first state, a full data read instruction is sent to acquire data, and a flag reset instruction is sent; if the current state is the second state, the full data read operation is skipped. The data transfer adapter connects the RS-485 bus to the slave device and integrates a device communication interface module, a change detection module, a change flag register, a historical data buffer, and a bus communication interface module. The device communication interface module is used to actively collect the current full data of the slave device according to an independent collection cycle; The change detection module is used to compare the current full data with the historical full data in the historical data buffer, and update the change flag register according to the comparison result; The bus communication interface module is used to respond to the instructions of the main controller; when the flag query instruction is detected, a response is generated based on the status of the locally stored change flag register; when the full data read instruction is detected, data in the historical data buffer is read and a response is generated.

7. The system of claim 6, wherein, The data transfer adapter also includes a hardware watchdog, which is used to monitor the operating status of the data transfer adapter; When an abnormal reset is detected, the change flag register is initialized to the first state by default.

8. The system of claim 6, wherein, The flag bit query instruction and the full data read instruction are based on the Modbus RTU protocol. The flag bit query instruction uses a custom function code and the request frame length is 4 bytes.