Bus communication method and device, equipment and storage medium
By determining whether to perform non-periodic communication based on the available remaining time of the non-periodic communication stage in the bus communication method of the industrial control system, the problem of non-periodic data transmission interrupting periodic data exchange is solved, and the timely transmission of periodic data and the improvement of system response speed is achieved.
Patent Information
- Application Number
- CN202411633168.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-14
AI Technical Summary
In industrial control systems, burst transmission of non-periodic data may interrupt periodic data exchange, resulting in periodic data transmission delays and jitter in polling periods.
By introducing a non-periodic communication stage into the bus communication method, it is judged whether an aperiodic communication can be completed based on the available remaining time of the non-periodic communication stage, and aperiodic communication can be performed if feasible to avoid delays in periodic data transmission.
This method effectively avoids the delay in periodic data transmission caused by non-periodic communication exceeding the maximum allowable time, ensures timely transmission of periodic data, and improves the response speed and stability of industrial control systems.
Smart Images

Figure CN119628992A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a bus communication method and apparatus, device and storage medium. Background Art
[0002] In addition to the core controller, multiple functional cards are required on the backplane or rack of the industrial control system, such as input cards, output cards, and dedicated interface cards. Input cards collect status signals or measurement values, and output cards drive actuators or indicating devices. Dedicated interface cards include intelligent modules, industry-customized interface cards, and remote I / O communication cards. These cards work together to enable the control system to accurately perceive the environment and respond in a timely manner, achieving efficient automated control.
[0003] In industrial control systems, the communication data between the master and slaves is divided into periodic data and non-periodic data. The master sends periodic request messages according to the preset polling cycle and receives periodic response messages from the slave to obtain periodic data, such as sensor perception data and actuator control data. Non-periodic data is used to transmit bursty information, such as device configuration, fault diagnosis, and operating status, and is usually triggered according to actual needs or specific events.
[0004] The burst transmission of non-periodic data may interrupt the periodic data exchange, resulting in a delay in the periodic data transmission, which in turn causes jitter in the polling cycle. Summary of the invention
[0005] In view of this, the embodiments of the present application are directed to providing a bus communication method and apparatus, a device and a storage medium, which can avoid transmission delay of periodic data when transmitting non-periodic messages.
[0006] According to a first aspect of an embodiment of the present application, a bus communication method is provided, wherein a polling cycle for data transmission between a master station and a slave station includes at least one of a periodic communication phase and an aperiodic communication phase; the method includes:
[0007] Determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase;
[0008] In the case that there is a slave station that needs to perform aperiodic communication, determining whether the available remaining time can complete the aperiodic communication once;
[0009] If the available remaining time is sufficient to complete the aperiodic communication once, the master station sends an aperiodic request message to the slave station, and receives an aperiodic response message fed back by the slave station.
[0010] Optionally, the polling cycle includes at least two of the periodic communication phase, the non-periodic communication phase and the idle phase;
[0011] In the case where there is a slave station that needs to perform aperiodic communication, after determining whether the available remaining time can complete the aperiodic communication once, the method further includes:
[0012] If the available remaining time cannot complete the non-periodic communication once, or there is no slave station that needs to perform non-periodic communication, the idle phase is entered; the length of the idle phase is determined based on the polling cycle, the first duration of the periodic communication phase and the second duration of the non-periodic communication phase; in the idle phase, the master station does not communicate with any slave station.
[0013] Optionally, before determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase, the method further includes:
[0014] Determining the polling period for data transmission between the master station and the slave station according to the communication period required by each slave station;
[0015] Calculate the duration of the periodic communication phase according to the number of slave stations and the communication cycle required by each of the slave stations;
[0016] The duration threshold of the non-periodic communication phase is calculated according to the polling cycle and the duration of the periodic communication phase.
[0017] Optionally, after calculating the duration threshold of the non-periodic communication phase according to the polling cycle and the duration of the periodic communication phase, the method further comprises:
[0018] Calculating the maximum number of aperiodic communications of aperiodic communications according to the difference between the duration of the polling cycle and the periodic communication phase, and the maximum frame length of the aperiodic communications;
[0019] The determining whether the available remaining time is capable of completing one non-periodic communication comprises:
[0020] According to whether the number of the aperiodic communications reaches the maximum number of aperiodic communications, it is determined whether the available remaining time can complete one aperiodic communication.
[0021] Optionally, before determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase, the method further includes:
[0022] According to the communication cycle required by each of the slave stations, the target slave station for periodic communication in the current periodic communication phase is determined; the polling cycle is determined according to the communication cycle required by each of the slave stations; the periodic communication includes the master station sending a periodic request message to the slave station, and the master station receiving a periodic response message fed back by the slave station in response to the periodic request message;
[0023] In the current periodic communication phase, the master station communicates periodically with each target slave station in turn.
[0024] Optionally, the slave station includes a fast slave station that periodically communicates with the master station in each polling cycle, and a slow slave station other than the fast slave station; the periodic communication phase includes a dedicated time segment occupied by a fast slave station in each polling cycle, and a shared time segment occupied by different slow slave stations in different polling cycles;
[0025] Determining the target slave station for periodic communication in the current periodic communication phase according to the communication cycle required by each slave station includes:
[0026] Determining, according to the communication cycle required by each of the slow slave stations, the target slow slave stations corresponding to each of the shared time segments in the current periodic communication phase;
[0027] The target slave station is obtained according to the fast slave station and the target slow slave station.
[0028] Optionally, the periodic communication phase includes a preset number of the shared time segments;
[0029] The step of determining, according to the communication cycle required by each of the slow slave stations, a target slow slave station corresponding to each of the shared time segments in the current periodic communication phase comprises:
[0030] The preset number of slow slave stations are selected in order from the slow slave station sequence to obtain the target slow slave station; the slow slave station sequence is obtained by sorting the slow slave stations in a preset order.
[0031] According to a second aspect of an embodiment of the present application, a bus communication device is provided, wherein a polling cycle for data transmission between a master station and a slave station includes a periodic communication phase and an aperiodic communication phase, including at least one of the periodic communication phase and the aperiodic communication phase; the device includes:
[0032] An available remaining time module, configured to determine the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase;
[0033] A judging module, used for judging whether the available remaining time can complete the aperiodic communication once when there is a slave station that needs to perform aperiodic communication;
[0034] The non-periodic communication module is used for, if the available remaining time can complete the non-periodic communication once, the master station sends an non-periodic request message to the slave station, and receives the non-periodic response message fed back by the slave station.
[0035] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; a memory for storing instructions executable by the processor; and the processor is used to execute the method described in any one of the above embodiments.
[0036] According to a fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the method described in any of the above embodiments.
[0037] The embodiment of the present application provides a bus communication method and apparatus, device and storage medium. In the scheme, the available remaining time of the non-periodic communication phase is determined according to the current duration and duration threshold of the non-periodic communication phase; when there is a slave station that needs to perform non-periodic communication, it is determined whether the available remaining time can complete a non-periodic communication; if the available remaining time can complete a non-periodic communication, the master station sends a non-periodic request message to the slave station and receives a non-periodic response message fed back by the slave station. By accurately calculating the available remaining time of the non-periodic communication phase and deciding whether to perform non-periodic communication based on it, the non-periodic communication phase is avoided from exceeding the maximum allowed time, which is helpful for the instant transmission of periodic data and helps to improve the response speed of industrial control systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 Shown is a schematic diagram of an implementation environment provided by an embodiment of the present application.
[0039] Figure 2 Shown is a flow chart of a bus communication method provided by an embodiment of the present application.
[0040] Figure 3 Shown is a flow chart of another bus communication method provided by an embodiment of the present application.
[0041] Figure 4 Shown is a flow chart of another bus communication method provided by an embodiment of the present application.
[0042] Figure 5 Shown is a block diagram of a bus communication device provided by an embodiment of the present application.
[0043] Figure 6 Shown is a structural block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] Application Overview
[0046] In addition to the core controller, multiple functional cards are required on the backplane or rack of the industrial control system. These functional cards include input cards, output cards, and other special interface cards. Input cards are responsible for collecting status signals or measurement values from external devices, while output cards are used to drive actuators or indicating devices. In addition, there are various special interface cards, such as intelligent modules for complex computing processing, interface cards customized for specific industries, and communication cards for connecting remote I / O devices. All these functional cards work together to enable the control system to accurately perceive environmental changes and respond in a timely manner, thereby achieving efficient automated control.
[0047] In industrial control systems, the communication data between the master and slave can generally be divided into periodic data and non-periodic data. The master sends periodic request messages to the slave according to the preset polling cycle, and obtains the periodic response messages fed back by the slave to obtain periodic data. Periodic data usually refers to information that needs to be exchanged at fixed time intervals, including sensor perception data, actuator control data, etc. Non-periodic data is usually used to transmit sudden and low-real-time information, such as equipment configuration, fault diagnosis, operating status, etc.; unlike periodic data, the transmission of non-periodic data is generally triggered by actual needs or the occurrence of specific events.
[0048] Aperiodic data covers information that does not need to be sent at fixed time intervals, such as device status reports, error messages, parameter settings, and other maintenance and monitoring information. The transmission of this data is often triggered by specific events or transmitted upon request. Although aperiodic data plays an indispensable role in maintaining the overall health and efficiency of the system, the real-time requirements of aperiodic data are generally lower than those of periodic data. Therefore, it is relatively flexible in network scheduling and resource allocation, and can tolerate a certain degree of delay.
[0049] Under normal operation, the master station will interact with each slave station periodically in turn - that is, the master station sends periodic request messages, and the slave station gives corresponding feedback based on these requests. The burst transmission of non-periodic data may disrupt the originally orderly periodic data exchange process, causing delays in the transmission of periodic data, and thus causing jitter in the polling cycle.
[0050] In order to solve the above problems, in the embodiment of the present application, the polling cycle is divided into two parts: a periodic communication phase and an aperiodic communication phase; when there is a slave station that needs to perform aperiodic communication, it is determined that the available remaining time in the aperiodic communication phase can complete a non-periodic communication; if the available remaining time can complete a non-periodic communication, the master station and the slave station perform a non-periodic communication. In this way, jitter of the polling cycle is avoided, and periodic data can be transmitted at preset time intervals, which helps to improve the stability and reliability of the entire industrial control system.
[0051] After introducing the basic principles of the present application, various non-limiting embodiments of the present application will be described in detail with reference to the accompanying drawings.
[0052] Exemplary Systems
[0053] Figure 1 The schematic diagram of an implementation environment provided by the embodiment of the present application is shown. The implementation environment may include a master station (i.e. Figure 1 Master) and multiple slaves ( Figure 1 Slave01, Slave02, ..., Slave N). The master station and the slave station can communicate with each other through the data bus. The polling cycle of data transmission between the master station and the slave station includes at least one of a periodic communication phase and an aperiodic communication phase. The periodic communication phase can be used for periodic communication to transmit periodic data; the aperiodic communication phase can be used for aperiodic communication to transmit aperiodic data.
[0054] Exemplary Methods
[0055] Figure 2 It is a flowchart of a bus communication method provided by an embodiment of the present application. Figure 2 The method described is executed by a computing device (eg, a server), but the embodiments of the present application are not limited thereto.
[0056] like Figure 2 As shown, the method includes the following contents:
[0057] Step S210: Determine the available remaining time of the aperiodic communication phase according to the current duration of the aperiodic communication phase and the duration threshold.
[0058] In an embodiment of the present application, the non-periodic communication phase can be used to perform non-periodic communication to transmit non-periodic data.
[0059] In the embodiment of the present application, the current duration may be the time that the non-periodic communication phase has lasted at the current moment.
[0060] In the embodiment of the present application, the duration threshold is used to indicate the maximum duration of the non-periodic communication phase.
[0061] In the embodiment of the present application, the available remaining time is used to represent the remaining duration of the aperiodic communication phase. It should be particularly noted that the available remaining time may be equal to or unequal to the actual remaining time of the aperiodic communication phase.
[0062] Step S220: When there is a slave station that needs to perform aperiodic communication, determine whether the available remaining time can complete the aperiodic communication once.
[0063] In practical applications, the sending of non-periodic data is often triggered by a specific event, or is transmitted upon request, that is, not every polling cycle needs to transmit non-periodic data, and not every polling cycle includes a non-periodic communication phase.
[0064] In the embodiment of the present application, the determining whether the available remaining time can complete the non-periodic communication once may include:
[0065] Determine whether the available remaining time is greater than or equal to the time required to complete the aperiodic communication once. The time required for the aperiodic communication once may be the time required for the next aperiodic communication, or may be the maximum time required for the aperiodic communication once. The maximum time required for the aperiodic communication once may be calculated based on the maximum frame length of the aperiodic data.
[0066] Step S230: If the available remaining time is sufficient to complete the aperiodic communication once, the master station sends an aperiodic request message to the slave station, and receives an aperiodic response message fed back by the slave station.
[0067] In the embodiment of the present application, the non-periodic request message may be an asynchronous request message.
[0068] (Asynchronous Request). The aperiodic response message may be an asynchronous response message (Asynchronous Response). The master station sends an aperiodic request message to the slave station, and receives an aperiodic response message fed back by the slave station. This process may be referred to as performing an aperiodic communication. The aperiodic request message may be used to request the slave station to return a response message carrying the target message, or to request the slave station to return a response message carrying the target message according to the aperiodic request message that has not been responded to in the previous polling cycle. The aperiodic response message may be used to feed back the target message, or to feed back to the master station that data transmission is not ready yet, and to request a response to the target message in a subsequent polling cycle.
[0069] In an embodiment of the present application, the available remaining time of the non-periodic communication phase is determined according to the current duration and duration threshold of the non-periodic communication phase; in the case where there is a slave station that needs to perform non-periodic communication, it is determined whether the available remaining time can complete a non-periodic communication; if the available remaining time can complete a non-periodic communication, the master station sends a non-periodic request message to the slave station and receives a non-periodic response message fed back by the slave station. By accurately calculating the available remaining time of the non-periodic communication phase and deciding whether to perform non-periodic communication accordingly, the non-periodic communication phase is avoided from exceeding the maximum allowed time, which helps to transmit periodic data in a timely manner and helps to improve the response speed of the industrial control system.
[0070] based on Figure 2 The method in this specification also provides some specific implementation plans of the method, which are described below.
[0071] Optionally, the polling cycle includes at least two of the periodic communication phase, the non-periodic communication phase and the idle phase;
[0072] In the case where there is a slave station that needs to perform aperiodic communication, after determining whether the available remaining time can complete the aperiodic communication once, the method further includes:
[0073] If the available remaining time cannot complete the non-periodic communication once, or there is no slave station that needs to perform non-periodic communication, the idle phase is entered; the length of the idle phase is determined based on the polling cycle, the first duration of the periodic communication phase and the second duration of the non-periodic communication phase; in the idle phase, the master station does not communicate with any slave station.
[0074] In the embodiment of the present application, in the idle phase, the master station does not communicate with any slave station. The idle phase can be used to wait for the current polling cycle to end in order to enter the next polling cycle.
[0075] In the embodiment of the present application, the first duration may be the time consumed by the periodic communication phase in the current polling cycle. The second duration may be the time consumed by the non-periodic communication phase in the current polling cycle.
[0076] In the embodiment of the present application, the length of the idle phase can be calculated by subtracting the time spent in the periodic communication phase and the non-periodic communication phase from the duration of the polling cycle.
[0077] In an embodiment of the present application, the polling cycle includes at least two of a periodic communication phase, an aperiodic communication phase, and an idle phase. In general, each polling cycle includes a periodic communication phase, and the duration of the periodic communication phase is less than the duration of the polling cycle. If no slave station needs to perform aperiodic communication, the master station enters the idle phase, and at this time, the polling cycle includes a periodic communication phase and an idle phase. Alternatively, if the available remaining time cannot complete the aperiodic communication once, the master station enters the idle phase, and at this time, the polling cycle includes the periodic communication phase, the aperiodic communication phase, and the idle phase.
[0078] In an embodiment of the present application, an idle phase is set in the polling cycle, and the length of the idle phase is determined based on the polling cycle, the first duration of the periodic communication phase and the second duration of the non-periodic communication phase; thereby, the length of the polling cycle is kept constant, communication jitter is reduced, and the stability and reliability of industrial control system communication are improved.
[0079] Figure 3 FIG. 2 is a flow chart of another bus communication method provided by an embodiment of the present application. Figure 3 As shown, the polling cycle includes a periodic communication phase, a non-periodic communication phase and an idle phase.
[0080] The periodic communication phase is the time period between time T0 and time T1. In the periodic communication phase, the master first sends a global control frame, then periodically communicates with each slave in turn, and sends a periodic request message (e.g. Figure 3 Preq To Slave1, Preq To Slave2, Preq To Slave n), receiving the periodic response message fed back by the slave station for the periodic request message (for example Figure 3Pres From Slave1, Pres FromSlave2, Pres From Slave). Among them, Preq To Slave is Periodic Request To Slave, a periodic request message; Pres From Slave is Periodic Response from Slave, a non-periodic request message. The non-periodic communication phase is the time period after time T1 and before the idle phase; the master station and the slave station perform non-periodic communication, that is, the master station sends a non-periodic request message (AsyncReq To Slave3, AsyncReq To SlaveN) to the slave station, and receives a non-periodic response message (AsyncResp From Slave 3, AsyncResp From SlaveN) fed back by the slave station. Among them, AsyncReq To Slave is Asynchronous Request To Slave, which means a periodic response message; AsyncResp From Slave is Asynchronous Response From Slave, which means a non-periodic response message.
[0081] During the idle phase, the master station does not communicate with any slave station. The sum of the durations of the periodic communication phase, the non-periodic communication phase and the idle phase is a fixed value, that is, the time period between time T0 and time T2 is a fixed value. When the communication connection is normal, the time period between time T0 and time T1 (i.e., the periodic communication phase) is approximately a fixed value, and the duration of the idle phase can be determined based on the duration between time T1 and time T2, and the actual duration of the non-periodic communication phase.
[0082] The bus communication method provided in the embodiments of the present disclosure can not only avoid the delay of periodic data transmission caused by the non-periodic communication stage exceeding the maximum allowed time in the normal state, but also can do so in the process of establishing a communication connection between the master station and the slave station.
[0083] Figure 4 Shown is a flow chart of another bus communication method provided by an embodiment of the present application. Figure 4 1, 2, and 3 respectively represent the three stages before, during, and after establishing a connection. Figure 4 There are N slaves in total (Slave 1, Slave 2, Slave 3...Slave N).
[0084] Phase 1: The master station has not detected any slave station. At this time, the periodic communication phase only sends global control frames (Global Control). It is impossible to communicate periodically with the slave station and directly jump to the non-periodic communication phase. The non-periodic communication phase uses non-periodic data to detect the slave station's presence and configure the data download process. After the non-periodic communication phase is completed, it enters the idle phase.
[0085] Phase 2: The master station has detected some slave stations, and these slave stations have downloaded configurations through non-periodic data. These slave stations (such as Slave 1) have entered the periodic communication phase; at this time, the master station sends global control frames and communicates periodically with these slave stations in the periodic communication phase; after the master station communicates periodically with these slave stations in turn, it enters the non-periodic communication phase and continues to perform in-place detection and data download configuration processes with slave stations that have not established connections (such as Slave 2, Slave 3...SlaveN). After the non-periodic communication phase is completed, it enters the idle phase.
[0086] Phase 3: The master station has detected all slave stations and configured data download, and has completed the establishment of all slave station connections; at this time, the time of the periodic communication phase is approximately fixed; after completing the periodic communication phase, it directly skips the non-periodic communication phase and enters the idle phase, waiting for the end of the polling cycle.
[0087] It is not difficult to see that before, during and after the master station and the slave station establish a communication connection, the delay of periodic data transmission caused by the non-periodic communication phase exceeding the maximum allowed time can be avoided, so that the length of the polling cycle remains constant.
[0088] Optionally, in the case where there is a slave station that needs to perform aperiodic communication, after determining whether the available remaining time can complete the aperiodic communication once, the method further includes:
[0089] If the available remaining time cannot complete the aperiodic communication once, or there is no slave station that needs to perform aperiodic communication, the periodic communication phase is entered.
[0090] In the disclosed embodiment, the polling cycle may include a non-periodic communication phase in addition to the periodic communication phase, and the duration of the non-periodic communication phase does not exceed the duration threshold. Thus, the duration of the polling cycle does not exceed the sum of the duration of the periodic communication phase and the duration threshold, so that the polling cycle fluctuates within the allowable range.
[0091] Optionally, before determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase, the method further includes:
[0092] Determining the polling period for data transmission between the master station and the slave station according to the communication period required by each slave station;
[0093] Calculate the duration of the periodic communication phase according to the number of slave stations and the communication cycle required by each of the slave stations;
[0094] The duration threshold of the non-periodic communication phase is calculated according to the polling cycle and the duration of the periodic communication phase.
[0095] In an embodiment of the present application, the communication cycle can be used to represent the frequency or interval of data exchange between the slave station and the master station. The communication cycle required by the slave station is determined according to its real-time requirements. Specifically, the communication cycle of the slave station can be determined according to its sampling cycle or control cycle. As the name implies, the sampling cycle is the time required to sample data such as voltage, current, and speed, and the control cycle is the time required to perform a complete control cycle on an actuator such as a stepper motor.
[0096] In practical applications, different slave stations generally require different communication cycles. For example, the control cycle of a stepper motor is generally much smaller than the communication cycle required by a temperature and humidity sensor or a signal light.
[0097] In the embodiment of the present application, determining the polling period for data transmission between the master station and the slave station according to the communication period required by each of the slave stations includes:
[0098] Determine the slave station with the shortest communication cycle and obtain the minimum communication cycle;
[0099] The polling period is obtained according to the minimum communication period; and the duration of the polling period is not greater than the minimum communication period.
[0100] In actual applications, after the master station and all slave stations establish communication connections, the data packet length of the periodic data between each slave station and the master station is a fixed value, and the time required for the master station to perform periodic communication with each slave station is also a fixed value.
[0101] In the embodiment of the present application, the duration of the periodic communication phase, that is, the time required for the periodic communication phase after the master station and all slave stations establish communication connections, is approximately a fixed value.
[0102] In an embodiment of the present application, the periodic communication phase may include multiple time segments, which may be divided into dedicated time segments used by a certain slave station in each polling cycle, or shared time segments used by different slave stations in different polling cycles. The master station needs to occupy a dedicated time segment or a shared time segment in the periodic communication phase for periodic communication with any slave station. At this time, the duration of the periodic communication phase is calculated based on the number of slave stations and the communication cycle required by each of the slave stations.
[0103] Optionally, the periodic communication phase includes dedicated time segments occupied by a fast slave station in each polling cycle, and shared time segments occupied by different slow slave stations in different polling cycles;
[0104] The step of calculating the duration of the periodic communication phase according to the number of slave stations and the communication cycle required by each slave station may include:
[0105] For each slave station, judging whether the slave station is a fast slave station according to the communication cycle required by the slave station, and obtaining the number of the fast slave stations and the number of slow slave stations other than the fast slave stations; the fast slave station is used to communicate with the master station in each polling cycle;
[0106] Determining the number of dedicated time slices according to the number of the fast slave stations;
[0107] Determine the number of shared time slices based on the number of slow slaves and their required communication cycles;
[0108] The duration of the periodic communication phase is calculated based on the sum of the number of dedicated time segments and shared time segments and the duration of each time segment.
[0109] See also Figure 4 ,Whenever the number of slave stations establishing communication connections with the master station changes, the duration of the next periodic communication phase and the duration threshold of the non-periodic communication phase will also change.
[0110] In the embodiment of the present application, the duration threshold of the non-periodic communication phase may be the difference between the duration of the polling cycle and the duration of the periodic communication phase.
[0111] In the embodiment of the present application, the polling cycle and the duration of the periodic communication phase are determined according to the communication cycle required by each slave station; the duration threshold of the non-periodic communication phase is calculated according to the polling cycle and the duration of the periodic communication phase. In this way, the polling cycle can meet the communication cycle required by each slave station, thereby meeting the real-time requirements of the industrial control system; on the other hand, under the premise of giving priority to the instant transmission of periodic data, the non-periodic data is transmitted as soon as possible, which helps to improve the stability and reliability of the communication of the industrial control system.
[0112] Optionally, after calculating the duration threshold of the non-periodic communication phase according to the polling cycle and the duration of the periodic communication phase, the method further comprises:
[0113] Calculating the maximum number of aperiodic communications of aperiodic communications according to the difference between the duration of the polling cycle and the periodic communication phase, and the maximum frame length of the aperiodic communications;
[0114] The determining whether the available remaining time is capable of completing one non-periodic communication comprises:
[0115] According to whether the number of the aperiodic communications reaches the maximum number of aperiodic communications, it is determined whether the available remaining time can complete one aperiodic communication.
[0116] In the embodiment of the present application, the maximum frame length of the non-periodic communication may be the byte length of the maximum data packet of the non-periodic communication.
[0117] In the embodiment of the present application, the maximum number of aperiodic communications may refer to the number of aperiodic communications performed in the aperiodic communication phase. The maximum number of aperiodic communications may be the integer quotient of the difference between the duration of the polling cycle and the periodic communication phase and the maximum frame length of the aperiodic communication.
[0118] In an embodiment of the present application, the maximum number of non-periodic communications of non-periodic communications is calculated based on the difference between the polling cycle and the periodic communication phase, and the maximum frame length of the non-periodic communication; based on whether the number of non-periodic communications reaches the maximum number of non-periodic communications, it is determined whether the available remaining time can complete one non-periodic communication; this helps to simplify the scheduling algorithm of the non-periodic communication phase and reduce the resources consumed by the scheduling algorithm.
[0119] Optionally, before determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase, the method further includes:
[0120] According to the communication cycle required by each of the slave stations, the target slave station for periodic communication in the current periodic communication phase is determined; the polling cycle is determined according to the communication cycle required by each of the slave stations; the periodic communication includes the master station sending a periodic request message to the slave station, and the master station receiving a periodic response message fed back by the slave station in response to the periodic request message;
[0121] In the current periodic communication phase, the master station communicates periodically with each target slave station in turn.
[0122] In the embodiment of the present application, the target slave station is a slave station that performs periodic communication with the master station in the current periodic communication phase.
[0123] In the embodiment of the present application, the polling period may be less than or equal to the minimum value of the communication periods required by each of the slave stations.
[0124] At present, in the universal standard fieldbus protocol, the master station generally communicates with each slave station periodically in turn. When there are too many slave stations, the polling cycle cannot meet the communication cycle required by each of the slave stations, and thus cannot meet the real-time requirements of the industrial control system. In order to meet the real-time requirements, a data bus is generally set up separately for slave stations with a short sampling cycle or a short control cycle.
[0125] Compared with periodic communication with each slave station, the embodiment of the present application determines the target slave station for periodic communication in the current periodic communication phase according to the communication cycle required by each slave station. On the one hand, this scheme increases the periodic communication frequency of slave stations with higher real-time performance, which helps key equipment that requires high-frequency data updates to get timely responses, thereby better meeting the real-time requirements of industrial control systems; on the other hand, it reduces the periodic communication frequency of slave stations with lower real-time performance, reducing the communication load of the industrial control system.
[0126] Optionally, determining the target slave station for periodic communication in the current periodic communication phase according to the communication cycle required by each slave station may include:
[0127] For each slave station, calculate the time interval between the current time and the last time the slave station performed periodic communication;
[0128] According to the time interval and the communication cycle required by the slave station, it is determined whether the slave station belongs to the target slave station.
[0129] Optionally, the periodic communication phase includes a first preset number of time segments; determining the target slave station for periodic communication in the current periodic communication phase according to the communication cycle required by each slave station includes: determining the slave station sequence corresponding to each time segment according to the communication cycle required by each slave station; for each time segment, determining the target slave station according to the slave station sequence corresponding to the time segment.
[0130] Optionally, the slave station includes a fast slave station that periodically communicates with the master station in each polling cycle, and a slow slave station other than the fast slave station; the periodic communication phase includes a dedicated time segment occupied by a fast slave station in each polling cycle, and a shared time segment occupied by different slow slave stations in different polling cycles;
[0131] Determining the target slave station for periodic communication in the current periodic communication phase according to the communication cycle required by each slave station includes:
[0132] Determining, according to the communication cycle required by each of the slow slave stations, the target slow slave stations corresponding to each of the shared time segments in the current periodic communication phase;
[0133] The target slave station is obtained according to the fast slave station and the target slow slave station.
[0134] In an embodiment of the present application, the periodic communication phase may include multiple time segments, which may be divided into dedicated time segments and shared time segments. The dedicated time segment is a time segment used by a certain slave station in each polling cycle. The duration of the dedicated time segment may be determined based on the frame length of the periodic data of the fast slave station occupying it, or may be determined based on the maximum frame length of the periodic communication phase. The shared time segment is a time segment occupied by different slave stations in turn in different polling cycles, and may be determined based on the maximum frame length of the periodic communication phase.
[0135] In the embodiment of the present application, the slave stations are divided into fast slave stations and slow slave stations according to the communication cycle required by each slave station. The fast slave station is a slave station that needs to communicate periodically with the master station in each polling cycle, that is, the fast slave station is a target slave station in each polling cycle. The slow slave station is a slave station with a longer communication cycle, and the slow slave station communicates periodically with the master station every several polling cycles; the target slow slave station is a slave station that communicates periodically in the current polling cycle. Figure 4 In the third phase, the fast slaves (Slave 1, Slave 2, Slave 3) have a dedicated time slice, and the slow slaves (i.e. Figure 4 Slave n in the example (which may be a slave other than a fast slave) can take turns to occupy the shared time slice in a multiplexing manner.
[0136] In an embodiment of the present application, the target slow slave stations corresponding to each of the shared time segments in the current periodic communication phase are determined based on the communication cycle required by each of the slow slave stations, including: for each slow slave station, calculating the time interval between the current moment and the last time the slave station performed periodic communication; based on the time interval and the communication cycle required by the slow slave station, determining the target slow slave stations corresponding to each of the shared time segments in the current periodic communication phase.
[0137] In the embodiment of the present application, the slave stations are divided into fast slave stations and slow slave stations according to the communication cycle; the periodic communication stage is divided into a dedicated time segment dedicated to the fast slave station and a shared time segment occupied by the slow slave stations in turn; the fast slave station and the target slow slave station corresponding to each of the shared time segments are used as the target slave station for periodic communication in the current periodic communication stage. In this way, the periodic communication stage is more effectively scheduled, ensuring that the fast slave station with higher real-time performance can respond in time and meet the real-time requirements of the industrial control system.
[0138] Optionally, the periodic communication phase includes a preset number of the shared time segments;
[0139] The step of determining, according to the communication cycle required by each of the slow slave stations, a target slow slave station corresponding to each of the shared time segments in the current periodic communication phase comprises:
[0140] The preset number of slow slave stations are selected in order from the slow slave station sequence to obtain the target slow slave station; the slow slave station sequence is obtained by sorting the slow slave stations in a preset order.
[0141] In the embodiment of the present application, the preset number is determined according to the number of slow slave stations and the communication cycles required by them.
[0142] In the embodiment of the present application, the preset order may be the address order of the slow slave stations. The slow slave station sequence is obtained by sorting the slow slave stations in any order, and no specific limitation is made to this.
[0143] In the embodiment of the present application, by setting a preset number of shared time segments so that the slow slave stations take turns to communicate periodically with the master station, the scheduling algorithm of the periodic communication stage is simplified, computing resources can be saved and communication efficiency can be improved.
[0144] Exemplary Devices
[0145] The device embodiments of the present application can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0146] Figure 5 The block diagram of a bus communication device provided by an embodiment of the present application is shown. The polling cycle of data transmission between the master station and the slave station includes a periodic communication phase and an aperiodic communication phase, including at least one of the periodic communication phase and the aperiodic communication phase;
[0147] like Figure 5 As shown, the device 500 includes:
[0148] The available remaining time module 510 is used to determine the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase;
[0149] The judging module 520 is used to judge whether the available remaining time can complete the aperiodic communication once when there is a slave station that needs to perform aperiodic communication;
[0150] The aperiodic communication module 530 is configured to cause the master station to send an aperiodic request message to the slave station and receive an aperiodic response message fed back by the slave station if the available remaining time is sufficient to complete the aperiodic communication once.
[0151] Optionally, the polling cycle includes at least two of the periodic communication phase, the non-periodic communication phase and the idle phase;
[0152] The device 500 further includes:
[0153] An idle module is used to enter the idle phase if the available remaining time cannot complete the non-periodic communication once, or there is no slave station that needs to perform non-periodic communication; the length of the idle phase is determined according to the polling cycle, the first duration of the periodic communication phase and the second duration of the non-periodic communication phase; in the idle phase, the master station does not communicate with any slave station.
[0154] Optionally, the device 500 further includes:
[0155] A polling cycle module, used to determine the polling cycle for data transmission between the master station and the slave station according to the communication cycle required by each of the slave stations;
[0156] A periodic communication module, used for calculating the duration of the periodic communication phase according to the number of slave stations and the communication cycle required by each of the slave stations;
[0157] The aperiodic communication module 530 is further configured to calculate the duration threshold of the aperiodic communication phase according to the polling cycle and the duration of the periodic communication phase.
[0158] Optionally, the aperiodic communication module 530 is further configured to calculate a maximum aperiodic communication number of aperiodic communications according to a difference between the duration of the polling cycle and the periodic communication phase, and a maximum frame length of the aperiodic communication;
[0159] The determination module 520 is further configured to determine whether the available remaining time is sufficient to complete one non-periodic communication according to whether the number of non-periodic communications reaches a maximum number of non-periodic communications.
[0160] Optionally, the periodic communication module is further used for:
[0161] According to the communication cycle required by each of the slave stations, the target slave station for periodic communication in the current periodic communication phase is determined; the polling cycle is determined according to the communication cycle required by each of the slave stations; the periodic communication includes the master station sending a periodic request message to the slave station, and the master station receiving a periodic response message fed back by the slave station in response to the periodic request message;
[0162] In the current periodic communication phase, the master station communicates periodically with each target slave station in turn.
[0163] Optionally, the slave station includes a fast slave station that periodically communicates with the master station in each polling cycle, and a slow slave station other than the fast slave station; the periodic communication phase includes a dedicated time segment occupied by a fast slave station in each polling cycle, and a shared time segment occupied by different slow slave stations in different polling cycles;
[0164] The periodic communication module is also used for:
[0165] Determining, according to the communication cycle required by each of the slow slave stations, the target slow slave stations corresponding to each of the shared time segments in the current periodic communication phase;
[0166] The target slave station is obtained according to the fast slave station and the target slow slave station.
[0167] Optionally, the periodic communication phase includes a preset number of the shared time segments;
[0168] The periodic communication module is further used to select the preset number of slow slave stations from the slow slave station sequence in order to obtain the target slow slave station; the slow slave station sequence is obtained by sorting the slow slave stations in a preset order.
[0169] Exemplary Electronic Devices
[0170] Below, reference Figure 6 To describe an electronic device according to an embodiment of the present application. Figure 6A block diagram of an electronic device according to an embodiment of the present application is illustrated.
[0171] like Figure 6 As shown, electronic device 600 includes one or more processors 610 and memory 620 .
[0172] The processor 610 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 600 to perform desired functions.
[0173] The memory 620 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 610 may run the program instructions to implement the bus communication method of each embodiment of the present application described above and / or other desired functions. Various contents such as category correspondences may also be stored in the computer-readable storage medium.
[0174] In one example, the electronic device 600 may further include: an input device 630 and an output device 640 , and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0175] In addition, the input device 630 may also include, for example, a keyboard, a mouse, etc. The output device 640 may output various information to the outside. The output device 640 may include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, etc.
[0176] Of course, to simplify, Figure 6 Only some of the components related to the present application in the electronic device 600 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device 600 may also include any other appropriate components.
[0177] Exemplary computer program products and computer-readable storage media
[0178] In addition to the above-mentioned methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the bus communication method according to various embodiments of the present application described in the above-mentioned "Exemplary Method" section of this specification.
[0179] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0180] In addition, an embodiment of the present application may also be a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the steps of a bus communication method according to various embodiments of the present application described in the above "Exemplary Method" section of this specification.
[0181] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0182] The basic principles of the present application are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present application are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present application. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, not for limitation, and the above details do not limit the present application to being implemented by adopting the above specific details.
[0183] The block diagrams of the devices, apparatuses, equipment, and systems involved in this application are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.
[0184] It should also be noted that in the apparatus, device and method of the present application, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present application.
[0185] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0186] It should be understood that the qualifiers "first", "second", "third", "fourth", "fifth" and "sixth" used in the description of the embodiments of the present application are only used to more clearly explain the technical solutions and cannot be used to limit the scope of protection of the present application.
[0187] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A bus communication method, characterized in that: The polling cycle for data transmission between the master station and the slave station includes at least one of a periodic communication phase and an aperiodic communication phase; the method includes: Determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase; In the case that there is a slave station that needs to perform aperiodic communication, determining whether the available remaining time can complete the aperiodic communication once; If the available remaining time is sufficient to complete the aperiodic communication once, the master station sends an aperiodic request message to the slave station, and receives an aperiodic response message fed back by the slave station.
2. The method according to claim 1, characterized in that The polling cycle includes at least two of the periodic communication phase, the non-periodic communication phase and the idle phase; In the case where there is a slave station that needs to perform aperiodic communication, after determining whether the available remaining time can complete the aperiodic communication once, the method further includes: If the available remaining time cannot complete the non-periodic communication once, or there is no slave station that needs to perform non-periodic communication, the idle phase is entered; the length of the idle phase is determined based on the polling cycle, the first duration of the periodic communication phase and the second duration of the non-periodic communication phase; in the idle phase, the master station does not communicate with any slave station.
3. The method according to claim 1, characterized in that Before determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase, the method further includes: Determining the polling period for data transmission between the master station and the slave station according to the communication period required by each slave station; The duration of the periodic communication phase is calculated according to the number of slave stations and the communication cycle required by each of the slave stations; The duration threshold of the non-periodic communication phase is calculated according to the polling cycle and the duration of the periodic communication phase.
4. The method according to claim 3, characterized in that: After calculating the duration threshold of the non-periodic communication phase according to the polling cycle and the duration of the periodic communication phase, the method further comprises: Calculating the maximum number of aperiodic communications of aperiodic communications according to the difference between the duration of the polling cycle and the periodic communication phase, and the maximum frame length of the aperiodic communications; The determining whether the available remaining time is capable of completing one non-periodic communication comprises: According to whether the number of the aperiodic communications reaches the maximum number of aperiodic communications, it is determined whether the available remaining time can complete one aperiodic communication.
5. The method according to claim 1, characterized in that Before determining the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase, the method further includes: According to the communication cycle required by each of the slave stations, the target slave station for periodic communication in the current periodic communication phase is determined; the polling cycle is determined according to the communication cycle required by each of the slave stations; the periodic communication includes the master station sending a periodic request message to the slave station, and the master station receiving a periodic response message fed back by the slave station in response to the periodic request message; In the current periodic communication phase, the master station communicates periodically with each target slave station in turn.
6. The method according to claim 5, characterized in that The slave stations include fast slave stations that perform periodic communication with the master station in each polling cycle, and slow slave stations other than the fast slave stations; The periodic communication phase includes a dedicated time segment occupied by a fast slave station in each polling cycle, and a shared time segment occupied by different slow slave stations in different polling cycles; Determining the target slave station for periodic communication in the current periodic communication phase according to the communication cycle required by each slave station includes: Determining, according to the communication cycle required by each of the slow slave stations, the target slow slave stations corresponding to each of the shared time segments in the current periodic communication phase; The target slave station is obtained according to the fast slave station and the target slow slave station.
7. The method according to claim 6, characterized in that The periodic communication phase includes a preset number of the shared time segments; The step of determining, according to the communication cycle required by each of the slow slave stations, a target slow slave station corresponding to each of the shared time segments in the current periodic communication phase comprises: The preset number of slow slave stations are selected in order from the slow slave station sequence to obtain the target slow slave station; the slow slave station sequence is obtained by sorting the slow slave stations in a preset order.
8. A bus communication device, characterized in that: The polling cycle for data transmission between the master station and the slave station includes at least one of a periodic communication phase and an aperiodic communication phase; the device includes: An available remaining time module, configured to determine the available remaining time of the aperiodic communication phase according to the current duration and the duration threshold of the aperiodic communication phase; A judging module, used for judging whether the available remaining time can complete the aperiodic communication once when there is a slave station that needs to perform aperiodic communication; The non-periodic communication module is used for, if the available remaining time can complete the non-periodic communication once, the master station sends an non-periodic request message to the slave station, and receives the non-periodic response message fed back by the slave station.
9. An electronic device, comprising: processor; a memory for storing instructions executable by the processor; The processor is used to execute the method according to any one of claims 1 to 7. 10 . A computer-readable storage medium having computer program instructions stored thereon, wherein when the computer program instructions are executed by a processor, the processor is enabled to perform the method according to claim 1 .