A polling frequency adjustment method, a communication method, a communication system, and an electronic device.
By adjusting the polling frequency of slave devices in the Modbus network and periodically adjusting it according to the message data change rate p, the problems of data real-time performance and reliability caused by the large number of slave devices are solved, and the effect of quickly acquiring changing data is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-28
- Publication Date
- 2026-03-10
AI Technical Summary
In Modbus networks, the large number of slave devices and the long polling time result in low data real-time performance and affect the reliability of serial bus communication.
By adjusting the polling frequency of the master-slave protocol network, the polling frequency of each slave is periodically adjusted according to the message data change rate p of each slave. Slaves with a larger message data change rate p have a larger polling frequency, while slaves with a smaller change rate p have a smaller polling frequency. This reduces the number of individual query requests to all slaves and improves data real-time performance.
It enables rapid acquisition of slave device data with large message data change rates, ensuring the real-time performance of slave device data in the serial bus network and improving communication reliability.
Smart Images

Figure CN116846703B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data interaction technology, specifically relating to a polling frequency adjustment method, a communication method, a communication system, and an electronic device. Background Technology
[0002] The Modbus communication protocol, invented by Modicon (now a brand of Schneider Electric) in 1979, is a universal protocol used in electronic controllers. Upon its introduction, its simple and open communication method quickly made it a popular standard in industrial systems. This protocol defines a message structure that a controller can recognize, regardless of the network over which communication occurs. Therefore, the underlying communication method can use serial links such as RS232 and RS485, or TCP / IP Ethernet links. When communicating on a Modbus network, the master device must know the addresses of other slave devices in the network to recognize messages sent by those addresses and take appropriate actions. Through this protocol, multiple devices in an industrial field can be connected to form an industrial network for unified centralized control.
[0003] The Modbus communication protocol is a master-slave communication protocol. The master sends a data query request to the slave, and the slave returns a message data to the master. The communication between them is a question-and-answer format. Due to the limitations of unbalanced transmission characteristics, serial buses widely use the master-slave Modbus protocol. When the master queries data from each slave on the bus, it needs to initiate a data query request to each slave node individually. In practical applications, this is called Modbus bus data polling. When there are many slaves, polling will take a long time, making it impossible to guarantee data real-time performance, resulting in low reliability of serial bus communication. Summary of the Invention
[0004] The purpose of this invention is to provide a polling frequency adjustment method, a communication method, a communication system, and an electronic device to solve the problem that when using serial bus communication, the large number of slave devices leads to a long polling time, which cannot guarantee data real-time performance and thus results in low reliability of the serial bus communication method.
[0005] To address the aforementioned technical problems, this invention provides a method for adjusting the polling frequency in a master-slave protocol network, comprising the following steps:
[0006] 1) Initialize the polling frequency for each slave device in the master-slave protocol network; the polling frequency refers to the proportion of the number of times a slave device receives a data query request sent by the master device in the master-slave protocol network in each round of polling to the total number of polling in the corresponding round;
[0007] 2) The master polls all slaves at the polling frequency corresponding to each slave, and obtains the rate of change p of the message data corresponding to each slave after the end of the polling round; p is the ratio of the number of changes in the message data corresponding to the slave in the polling round to the total number of messages corresponding to the slave.
[0008] 3) Determine the preset rate of change interval to which the rate of change p of the message data corresponding to each slave belongs, and use the polling frequency corresponding to the rate of change interval as the polling frequency of the corresponding slave to perform a new round of polling; the larger the minimum value in the rate of change interval, the larger the polling frequency corresponding to the rate of change interval.
[0009] Its beneficial effects are as follows: The master-slave protocol network polling frequency adjustment method of the present invention periodically adjusts the polling frequency of each slave based on the rate of change p of the message data corresponding to each slave. The polling frequency is determined according to the interval to which the rate of change p of the message data belongs, enabling rapid and quantitative adjustment of the polling frequency corresponding to each slave. This ensures that slaves with a larger rate of change p of the message data have a higher polling frequency, while slaves with a smaller rate of change p of the message data have a lower polling frequency. A new polling cycle begins based on the adjusted polling frequency of each slave and a preset number of polling attempts. This results in fewer data query requests from the master to slaves with a smaller rate of change p of the message data within the polling cycle, and fewer requests to slaves with a larger rate of change p of the message data. Since the number of data query requests sent by the slave devices is relatively large, the method no longer initiates data query requests for each slave device node on the serial bus individually during each polling, greatly reducing the polling time. This enables the rapid acquisition of data from slave devices whose message data is more likely to change, thereby ensuring the real-time performance of message data from slave devices in the serial bus network and improving the reliability of the serial bus communication method. In addition, the method of this invention uses the message change rate rather than the number of message changes to adjust the polling frequency of each slave device. This ensures that when the number of data changes for devices with lower polling frequencies increases, the value of their message change rate will increase significantly, thereby increasing their corresponding polling frequency and enabling timely acquisition of changed data.
[0010] Preferably, the method for obtaining the rate of change p of the message data corresponding to each slave after a certain round of polling is:
[0011] 2.1) Initialize the total number of messages n and the number of message data changes c for each slave device to zero. After each poll in this round of polling, update the values of the total number of messages n and the number of message data changes c for each slave device. The update method is as follows: if this poll is the first poll experienced by the slave device, increment the value of the total number of messages n by one, and keep the value of the number of message data changes c unchanged; if this poll is not the first poll, compare the message data sent by the slave device in this poll with the message data sent by the slave device in the last poll. If they are different, increment the value of c and the value of n by one; if they are the same, keep the value of c unchanged and increment the value of n by one.
[0012] 2.2) After the polling round is completed, calculate the quotient of the number of message data changes c for each slave and the total number of messages n for the corresponding slave, which gives the rate of change p of the message data for each slave.
[0013] Its beneficial effect is that this method can quickly and accurately obtain the rate of change p of the message data corresponding to each slave device.
[0014] Preferably, in step 1), the initial value of the polling frequency corresponding to each slave is set to 100%.
[0015] To address the aforementioned technical problems, the present invention also provides a serial bus communication method with adaptive polling frequency, characterized by comprising the following steps:
[0016] A. Import the device information of each slave device in the serial bus into the master device of the serial bus; initialize the communication link configuration information of the serial bus, and configure the device information and device address of each slave device in the serial bus into the communication link; initialize the polling frequency corresponding to each slave device in the master-slave protocol network; the polling frequency refers to the proportion of the number of times the slave device receives data query requests sent by the master device of the master-slave protocol network in each round of polling to the total number of polling in the corresponding round;
[0017] B, causes the host to poll all slaves according to the polling frequency corresponding to each slave, and obtains the change rate p of the message data corresponding to each slave after the end of the polling round; p is the ratio of the number of changes in the message data corresponding to the slave in the polling round to the total number of messages corresponding to the slave;
[0018] C determines the preset rate of change interval to which the rate of change p of the message data corresponding to each slave device belongs, and uses the polling frequency corresponding to the rate of change interval as the polling frequency corresponding to the corresponding slave device to perform a new round of polling; the larger the minimum value in the rate of change interval, the larger the polling frequency corresponding to the rate of change interval.
[0019] Its beneficial effects are as follows: The serial bus communication method of the present invention periodically adjusts the polling frequency of each slave based on the rate of change p of the message data corresponding to each slave, so that the slave with a larger rate of change p of the message data has a larger polling frequency, and the slave with a smaller rate of change p of the message data has a smaller polling frequency. A new polling cycle begins based on the adjusted polling frequency of each slave and a preset number of polling times. This results in the master sending fewer data query requests to slaves with smaller rate of change p of the message data and more data query requests to slaves with larger rate of change p of the message data within the polling cycle. Furthermore, during each polling cycle, the serial bus communication frequency is no longer adjusted. All slave device nodes on the row bus initiate data query requests one by one, greatly reducing the polling time. This enables rapid acquisition of data from slaves whose message data is more likely to change, ensuring the real-time performance of slave message data in the serial bus network and improving the reliability of the serial bus communication method. Furthermore, the serial bus communication method of this invention uses the message change rate rather than the number of message changes to adjust the polling frequency of each slave. This ensures that when the number of data changes for devices with lower polling frequencies increases, their message change rate will increase significantly, thereby increasing their corresponding polling frequency and enabling timely acquisition of changed data.
[0020] Preferably, the method for obtaining the rate of change p of the message data corresponding to each slave after the entire polling process is completed is as follows:
[0021] Set the initial values of the total number of messages n and the number of message data changes c for each slave device to zero; after each poll in this round of polling, update the values of the total number of messages n and the number of message data changes c for each slave device.
[0022] After the polling round is completed, the quotient of the number of message data changes c for each slave device and the total number of messages n for the corresponding slave device is calculated, which gives the rate of change p of the message data for each slave device.
[0023] Preferably, the device information includes the slave device's name, function code, register address, data type, coefficients, and bit information.
[0024] Preferably, the communication link configuration information includes the link number, baud rate, parity check, and port number.
[0025] Preferably, the host is equipped with a current message indication flag pt corresponding to each slave device. After receiving the message data sent by the slave device, the host saves it to the current message indication flag pt corresponding to the slave device.
[0026] To address the aforementioned technical problems, this invention also provides a serial bus communication system with adaptive polling frequency, comprising a master unit and several slave units, each communicatively connected to the master unit. The master unit and the slave units communicate using the following method:
[0027] A. Import the device information of each slave device in the serial bus into the master device of the serial bus; initialize the communication link configuration information of the serial bus, and configure the device information and device address of each slave device in the serial bus into the communication link; initialize the polling frequency corresponding to each slave device in the master-slave protocol network; the polling frequency refers to the proportion of the number of times the slave device receives data query requests sent by the master device of the master-slave protocol network in each round of polling to the total number of polling in the corresponding round;
[0028] B, causes the host to poll all slaves according to the polling frequency corresponding to each slave, and obtains the change rate p of the message data corresponding to each slave after the end of the polling round; p is the ratio of the number of changes in the message data corresponding to the slave in the polling round to the total number of messages corresponding to the slave in the polling round.
[0029] C. Determine the preset rate of change interval to which the rate of change p of the message data corresponding to each slave device belongs, and use the polling frequency corresponding to the rate of change interval as the polling frequency corresponding to the corresponding slave device to perform a new round of polling; the larger the minimum value in the rate of change interval, the larger the polling frequency corresponding to the rate of change interval.
[0030] Its beneficial effects are as follows: The polling frequency adaptive serial bus communication system of the present invention periodically adjusts the polling frequency of each slave device according to the rate of change p of the message data corresponding to each slave device. The polling frequency is determined based on the interval to which the rate of change p of the message data belongs, enabling rapid and quantitative adjustment of the polling frequency corresponding to each slave device. This results in a higher polling frequency for slave devices with a larger rate of change p of the message data, and a lower polling frequency for slave devices with a smaller rate of change p of the message data. A new polling cycle begins based on the adjusted polling frequency corresponding to each slave device and a preset number of polling cycles. This ensures that within the polling cycle, the master sends fewer data query requests to slave devices with a smaller rate of change p of the message data, and sends more data query requests to slave devices with a larger rate of change p of the message data. By eliminating the need to initiate data query requests to each slave device node on the serial bus during each polling cycle, the polling time is significantly reduced. The serial bus communication system with adaptive polling frequency of this invention can quickly obtain data from slaves whose message data is more likely to change, thereby ensuring the real-time performance of message data from slaves in the serial bus network and improving the reliability of the serial bus communication system. In addition, the serial bus communication system with adaptive polling frequency of this invention uses the message change rate rather than the number of message changes to adjust the polling frequency of each slave. This ensures that when the number of data changes for devices with lower polling frequencies increases, the value of their message change rate will increase significantly, causing their corresponding polling frequency to increase, thus enabling timely acquisition of changed data.
[0031] To address the aforementioned technical problems, the present invention also provides an electronic device, including a memory and a processor. The memory stores a computer program, which, when executed by the processor, implements the master-slave protocol network polling frequency adjustment method of the present invention. Attached Figure Description
[0032] Figure 1 This is a schematic diagram of the method steps of the present invention;
[0033] Figure 2 This is a flowchart of the master-slave protocol network polling frequency adjustment method of the present invention. Detailed Implementation
[0034] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0035] Example of a serial bus communication method with adaptive polling frequency:
[0036] Due to the limitations of its unbalanced transmission characteristics, serial buses widely employ master-slave communication protocols. In a master-slave communication protocol, the master sends a data query request to the slave, and the slave returns a data message to the master; the communication is a question-and-answer format. When the master queries data from each slave on the bus, it needs to initiate a request to each device node individually, a process known as bus data polling.
[0037] like Figure 1 As shown, the polling frequency adaptive serial bus communication method of the present invention includes the following steps:
[0038] Step 1: Import the device information of each slave device in the serial bus into the master device of the serial bus, and set the initial polling frequency for each slave device in the serial bus.
[0039] First, a device information template can be constructed to store device information for all slave devices. This template is then imported into the host machine. Next, based on the information in the device point table corresponding to each slave device, the device information for each slave device is retrieved and configured into the device information template. The slave device information includes its name, function code, register address, data type, coefficients, and bit information. All slave device information is recorded in a configuration point table. The initial polling frequency for each slave device is set to 100%. The polling frequency refers to the proportion of times a slave device receives a data query request from the host in the master-slave protocol network in each round of polling, relative to the total number of polling rounds corresponding to the number of polling rounds (n).
[0040] Step 2: Initialize the communication link configuration information of the serial bus, and configure the device information and corresponding device address of each slave device in the serial bus into the communication link.
[0041] Read the serial bus link configuration file and initialize the link information, including the link number, baud rate, parity, and port number.
[0042] Step 3: The master polls all slave devices on the serial bus according to the polling frequency corresponding to each slave device, sends data query requests to the corresponding slave devices, receives the corresponding message data sent by the slave devices, and obtains the change rate p of the message data returned by each slave device after the polling is completed. p is the ratio of the number of changes in the message data corresponding to the slave device in this round of polling to the total number of messages corresponding to the slave device.
[0043] The host can set the current message indication flag bit pt for each slave device. pt is used to store the latest message data of the corresponding slave device. The initial state of pt is empty. In each polling, the data of the current message indication flag bit pt for the corresponding slave device is updated to the latest message data according to the received message data.
[0044] like Figure 2As shown, the specific method for obtaining the rate of change p of the message data returned by each slave device is as follows:
[0045] 3.1) Set the initial values of the total number of messages n and the number of message data changes c for each slave device to zero; after each polling, update the values of the total number of messages n and the number of message data changes c for each slave device.
[0046] The method for updating the total number of packets n and the number of packet data changes c of a certain slave device after a certain polling cycle is as follows: If the packet data stored in its corresponding pt is empty, it means that this is the first polling cycle. The packet data received by the master in this cycle is saved to the current packet indicator flag pt of the corresponding slave device, and the value of the total number of packets n of the slave device is incremented by one, while the value of the number of packet data changes c remains unchanged; if the packet data previously stored in the current packet indicator flag pt of the corresponding slave device is not empty, ... The host then compares the message data received from the slave in this poll with the message data previously saved in the current message indicator flag pt of the slave. If the message data previously saved in pt is different from the message data received from the slave this time, it indicates that the slave's state has changed. In this case, the value of c is incremented by one, the value of n is incremented by one, and pt is updated to reflect the latest message data received this time. If the message data previously saved in pt is the same as the message data received from the slave this time, the value of c remains unchanged, and the value of n is incremented by one.
[0047] 3.2) After the host finishes polling according to the preset number of polling cycles, it calculates the rate of change p of the message data for each slave based on the total number of messages n and the number of message data changes c. The formula for p is:
[0048]
[0049] Using this method, the rate of change p of the message data corresponding to each slave device can be obtained quickly and accurately.
[0050] Step 4: Set the polling frequency of each slave device according to the value of the change rate p of the message data corresponding to each slave device, and return to Step 3.
[0051] The rate of change p of the message data can be divided into multiple intervals from 0 to 100%, with different intervals corresponding to different polling frequencies. The polling frequency is determined based on the interval to which the rate of change p belongs; the larger the minimum value within an interval, the higher the corresponding polling frequency. For example, three ranges of change rate p can be set: [0, 40%], [40%, 70%], and [70%, 100%]. For slave devices with a rate of change p greater than 70%, the polling frequency remains at 100%; for slave devices with a rate of change greater than 40% and less than 70%, the polling frequency is reduced to 66.7%; for the remaining devices, their polling frequency is adjusted to 33.3%. The adjustment strategy is shown in Table 1.
[0052] Table 1
[0053]
[0054] Using the message change rate instead of the number of message changes to adjust the polling frequency of each slave device ensures that when the number of data changes increases for devices with lower polling frequencies, their message change rate will increase, allowing them to increase their polling frequency in a timely manner and thus obtain the changed data promptly.
[0055] The polling frequency is determined by the interval to which the rate of change p of the message data belongs. This allows for rapid and quantitative adjustment of the polling frequency of the slave device. The larger the value of the left endpoint of the interval, the higher the polling frequency of that interval. This saves polling time and allows for the rapid acquisition of data from slave devices whose message data is more likely to change.
[0056] With limited bandwidth resources, the method of this invention can ensure the real-time performance of messages from devices with faster update frequencies, while also ensuring that devices with lower update frequencies can promptly increase their polling frequency when data changes.
[0057] The serial bus communication method of this invention periodically adjusts the polling frequency of each slave device based on the rate of change p of the message data corresponding to each slave device. This results in a higher polling frequency for slave devices with a larger rate of change p, and a lower polling frequency for slave devices with a smaller rate of change p. A new polling cycle begins based on the adjusted polling frequency for each slave device and a preset number of polling attempts. This ensures that within each polling cycle, the master device sends fewer data query requests to slave devices with smaller rate of change p and more data query requests to slave devices with larger rate of change p. Furthermore, during each polling attempt, the serial bus is no longer targeted. Each slave device node initiates a data query request sequentially, significantly reducing the polling time. This enables rapid acquisition of data from slaves whose message data is more likely to change, ensuring the real-time performance of slave message data in the serial bus network and improving the reliability of the serial bus communication method. Furthermore, the serial bus communication method of this invention uses the message change rate rather than the number of message changes to adjust the polling frequency of each slave. This ensures that when the number of data changes for devices with lower polling frequencies increases, their message change rate will significantly increase, leading to an increase in their corresponding polling frequency and enabling timely acquisition of changed data.
[0058] Example of a method for adjusting the polling frequency in a master-slave protocol network:
[0059] The master-slave protocol network polling frequency adjustment method of the present invention includes:
[0060] 1) Initialize the polling frequency for each slave device in the master-slave protocol network to a certain value; the polling frequency refers to the proportion of the number of times a slave device receives a data query request sent by the master device in the master-slave protocol network in each round of polling to the total number of polling in the corresponding round;
[0061] 2) The master polls all slaves at the polling frequency corresponding to each slave, and obtains the rate of change p of the message data corresponding to each slave after the end of the polling round; p is the ratio of the number of changes in the message data corresponding to the slave in the polling round to the total number of messages corresponding to the slave.
[0062] 3) Determine the preset rate of change interval to which the rate of change p of the message data corresponding to each slave device belongs, and use the polling frequency corresponding to the rate of change interval as the polling frequency corresponding to the corresponding slave device to perform a new round of polling; the larger the minimum value in the rate of change interval, the larger the polling frequency corresponding to the rate of change interval.
[0063] The specific details of the master-slave protocol network polling frequency adjustment method of the present invention have been described in detail in the serial bus communication method with adaptive polling frequency, and will not be repeated here.
[0064] The master-slave protocol network polling frequency adjustment method of the present invention periodically adjusts the polling frequency of each slave based on the rate of change p of the message data corresponding to each slave. The polling frequency is determined according to the interval to which the rate of change p of the message data belongs. This enables rapid and quantitative adjustment of the polling frequency corresponding to each slave, ensuring that slaves with a larger rate of change p of message data have a higher polling frequency, and slaves with a smaller rate of change p of message data have a lower polling frequency. A new polling cycle begins based on the adjusted polling frequency of each slave and a preset number of polling attempts. This ensures that within the polling cycle, the master sends fewer data query requests to slaves with a smaller rate of change p of message data, and fewer requests to slaves with a larger rate of change p of message data. The method sends a large number of data query requests, but instead of initiating data query requests for each slave device node on the serial bus individually during each polling, it significantly reduces the polling time. This enables the rapid acquisition of data from slave devices whose message data is more likely to change, thereby ensuring the real-time performance of slave message data in the serial bus network and improving the reliability of the serial bus communication method. Furthermore, the method of this invention uses the message change rate rather than the number of message changes to adjust the polling frequency of each slave. This ensures that when the number of data changes for devices with lower polling frequencies increases, their message change rate will increase significantly, leading to an increase in their corresponding polling frequency, thus enabling timely acquisition of changed data.
[0065] Example of a serial bus communication system with adaptive polling frequency:
[0066] The polling frequency adaptive serial bus communication system of the present invention includes a master and several slaves, and the method for communication between the master and the slaves includes:
[0067] A. Import the device information of each slave device in the serial bus into the master device of the serial bus; initialize the communication link configuration information of the serial bus, and configure the device information and device address of each slave device in the serial bus into the communication link; initialize the polling frequency corresponding to each slave device in the master-slave protocol network; the polling frequency refers to the proportion of the number of times the slave device receives data query requests sent by the master device of the master-slave protocol network in each round of polling to the total number of polling in the corresponding round;
[0068] B, causes the host to poll all slaves according to the polling frequency corresponding to each slave, and obtains the change rate p of the message data corresponding to each slave after the end of the polling round; p is the ratio of the number of changes in the message data corresponding to the slave in the polling round to the total number of messages corresponding to the slave in the polling round.
[0069] C. Determine the preset rate of change interval to which the rate of change p of the message data corresponding to each slave device belongs, and use the polling frequency corresponding to the rate of change interval as the polling frequency corresponding to the corresponding slave device to perform a new round of polling; the larger the minimum value in the rate of change interval, the larger the polling frequency corresponding to the rate of change interval.
[0070] The polling frequency adaptive serial bus communication system of the present invention periodically adjusts the polling frequency of each slave device based on the rate of change p of the message data corresponding to each slave device. The polling frequency is determined according to the interval to which the rate of change p of the message data belongs, enabling rapid and quantitative adjustment of the polling frequency corresponding to each slave device. This results in a higher polling frequency for slave devices with a larger rate of change p of the message data, and a lower polling frequency for slave devices with a smaller rate of change p of the message data. A new polling cycle begins based on the adjusted polling frequency of each slave device and a preset number of polling cycles. This ensures that within each polling cycle, the master sends fewer data query requests to slave devices with a smaller rate of change p of the message data, and sends more data query requests to slave devices with a larger rate of change p of the message data. In each polling cycle... The polling frequency adaptive serial bus communication system of this invention eliminates the need to initiate data query requests to each slave device node on the serial bus individually, significantly reducing the polling time. This system enables rapid acquisition of data from slave devices whose message data is more likely to change, thus ensuring the real-time performance of slave message data in the serial bus network and improving the reliability of the serial bus communication system. Furthermore, the system uses the message change rate rather than the number of message changes to adjust the polling frequency of each slave. This ensures that when the number of data changes for devices with lower polling frequencies increases, their message change rate will significantly increase, leading to an increase in their corresponding polling frequency and enabling timely acquisition of changed data.
[0071] The specific details of the communication method between the master and slave devices in the polling frequency adaptive serial bus communication system of the present invention have been described in detail in the polling frequency adaptive serial bus communication method, and will not be repeated here.
[0072] Electronic device example:
[0073] The electronic device of the present invention includes a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, it implements the master-slave protocol network polling frequency adjustment method of the present invention.
[0074] The processor can be a microprocessor (MCU), a programmable logic device (FPGA), or other processing devices.
[0075] A memory can be any type of memory that uses electrical energy to store information.
Claims
1. A master-slave protocol network polling frequency adjustment method, characterized by, The method comprises the following steps: 1) initializing the polling frequency of each slave in the master-slave protocol network as 100%; the polling frequency refers to the proportion of the number of data query requests received by the slave in each round of polling to the polling number of the corresponding round; 2) polling all the slaves by the master according to the polling frequency corresponding to each slave, and obtaining the change rate p of the message data corresponding to each slave after the end of the round of polling; p is the ratio of the number of changes of the message data corresponding to the slave to the total number of messages corresponding to the slave in the round of polling, and the obtaining method is as follows: setting the initial value of the total number of messages n and the number of changes of message data c of each slave as zero; after each polling in the round of polling, the values of n and c of each slave are updated as follows: if the polling is the first polling experienced by the slave, the n of the slave is increased by one and the c is unchanged; if the polling is not the first polling, the message data sent by the slave in the polling is compared with the message data sent by the slave last time, if the two are different, the c and the n are both increased by one, if the two are the same, the c is unchanged and the n is increased by one; after the end of the round of polling, the quotient of c and n of each slave is calculated, that is, the p corresponding to each slave is obtained; 3) judging the value of p corresponding to each slave to belong to which preset change rate interval, taking the polling frequency corresponding to the change rate interval as the polling frequency of the corresponding slave to perform a new round of polling; the greater the minimum value in the change rate interval is, the greater the polling frequency corresponding to the change rate interval is.
2. The master-slave protocol network polling frequency adjustment method of claim 1, wherein, The communication form between the master and the slave is a question and answer form.
3. The master-slave protocol network polling frequency adjustment method of claim 1 or 2, wherein, The preset change rate interval has three.
4. A polling frequency adaptive serial bus communication method, characterized by, The method comprises the following steps: A, importing the device information of each slave in the serial bus into the master of the serial bus; initializing the communication link configuration information of the serial bus, and configuring the device information and device address of each slave in the serial bus to the communication link; initializing the polling frequency of each slave in the master-slave protocol network as 100%; the polling frequency refers to the proportion of the number of data query requests received by the slave in each round of polling to the polling number of the corresponding round; B, polling all the slaves by the master according to the polling frequency corresponding to each slave, and obtaining the change rate p of the message data corresponding to each slave after the end of the round of polling; p is the ratio of the number of changes of the message data corresponding to the slave to the total number of messages corresponding to the slave in the round of polling, and the obtaining method is as follows: setting the initial value of the total number of messages n and the number of changes of message data c of each slave as zero; after each polling in the round of polling, the values of n and c of each slave are updated as follows: if the polling is the first polling experienced by the slave, the n of the slave is increased by one and the c is unchanged; if the polling is not the first polling, the message data sent by the slave in the polling is compared with the message data sent by the slave last time, if the two are different, the c and the n are both increased by one, if the two are the same, the c is unchanged and the n is increased by one; after the end of the round of polling, the quotient of c and n of each slave is calculated, that is, the p corresponding to each slave is obtained; C, respectively determine the preset change rate interval to which the value of p corresponding to each slave belongs, and take the polling frequency corresponding to the change rate interval as the polling frequency corresponding to the corresponding slave to perform a new round of polling; the greater the minimum value in the change rate interval, the greater the polling frequency corresponding to the change rate interval.
5. The polling frequency adaptive serial bus communication method of claim 4, wherein, The device information includes the name, function code, register address, data type, coefficient and bit information of the slave.
6. The polling frequency adaptive serial bus communication method of claim 4, wherein, The communication link configuration information includes the link number, baud rate, parity check and port number.
7. A polling frequency adaptive serial bus communication method as claimed in any one of claims 4 to 6, characterized in that, The host is provided with a current message indication flag bit pt corresponding to each slave, and the host saves the message data sent by the slave to the current message indication flag bit pt corresponding to the corresponding slave after receiving the message data.
8. The polling frequency adaptive serial bus communication method of claim 4, wherein, The communication form between the host and the slave is a question and answer form.
9. A polling frequency adaptive serial bus communication system, characterized by The host and the slave are in communication connection, and the host and the slave communicate by using the method in claim 4.
10. An electronic device comprising a memory and a processor, said memory having stored therein a computer program, characterized in that, The computer program is executed by the processor to realize the polling frequency adjustment method of the master-slave protocol network in any one of claims 1-3.
Citation Information
Patent Citations
ARIMA-based adaptive low-cost SDN service flow throughput measuring method and system
CN108600038A
Transaction processing method and system, electronic equipment and readable storage medium
CN116184885A