PLC data consistency diagnosis method, ethercat master station protocol stack and electronic equipment
Patent Information
- Application Number
- CN202610804627.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-05
- Publication Date
- 2026-10-27
AI Technical Summary
[0004]本发明提供一种PLC数据一致性诊断方法、EtherCAT主站协议栈及电子设备,以解决相关技术的方法由于EtherCAT主站协议栈接收到的数据与数据源头生成数据不一致,可能导致PLC系统的运行受到影响的技术问题
[0017]上述一种PLC数据一致性诊断方法、EtherCAT主站协议栈及电子设备所实现的方案中,该方法通过获取EtherCAT主站协议栈接收的待诊断数据,待诊断数据包括当前数据序列标识、当前传输数据和当前循环冗余校验数据,根据当前数据序列标识和历史数据序列标识确定序列诊断结果,根据待诊断数据确定验证循环冗余校验数据,验证循环冗余校验数据的确定规则与当前循环冗余校验数据的确定规则相同,根据验证循环冗余校验数据和当前循环冗余校验数据确定校验诊断结果,基于序列诊断结果和校验诊断结果确定待诊断数据的数据一致性诊断结果,能够及时确定EtherCAT主站协议栈接收到的数据与数据源头生成数据的数据一致性情况,为后续PLC系统的运行可以提供参考信息,有利于PLC系统及时发现问题并调整PLC系统的运行行为。
Smart Images

Figure CN122993881A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a PLC data consistency diagnosis method, an EtherCAT master station protocol stack, and electronic equipment. Background Technology
[0002] In related technologies, the process of reading and writing data from a multi-node EtherCAT slave network via a PLC system involves the PLC real-time data processing system writing data sent to a specific node in the EtherCAT slave network into the output data area defined on the CPU module. This output data is then read by the EtherCAT master protocol stack and sent to the corresponding EtherCAT slave node via periodic output process data messages sent by the EtherCAT master. Similarly, the EtherCAT master protocol stack also writes the input data from the EtherCAT slave network nodes returned with periodic input process data frames into the input data area defined on the CPU module for the PLC real-time data processing system to read.
[0003] However, if a fault occurs in the PLC real-time data processing system or the data generation source of the EtherCAT slave network node, causing the data to stop updating in real time, or if the generated data is copied or transmitted incorrectly at different stages, the bilateral data transmission system will still transmit historical data or data that has already experienced abnormalities to the EtherCAT master protocol stack. This results in the EtherCAT master protocol stack receiving non-real-time or unexpected data, which in turn leads to inconsistencies between the data received by the EtherCAT master protocol stack and the data generated by the data source, potentially affecting the operation of the PLC system. Summary of the Invention
[0004] This invention provides a PLC data consistency diagnosis method, an EtherCAT master station protocol stack, and electronic equipment to solve the technical problem that the operation of the PLC system may be affected due to inconsistencies between the data received by the EtherCAT master station protocol stack and the data generated by the data source.
[0005] This application provides a PLC data consistency diagnosis method applied to an EtherCAT master protocol stack. The method includes: acquiring diagnostic data received by the EtherCAT master protocol stack, the diagnostic data including a current data sequence identifier, current transmitted data, and current cyclic redundancy check (CRUD) data; determining a sequence diagnosis result based on the current data sequence identifier and historical data sequence identifiers; determining verification CRUD data based on the diagnostic data, wherein the determination rule for the verification CRUD data is the same as the determination rule for the current CRUD data; determining a verification diagnosis result based on the verification CRUD data and the current CRUD data; and determining a data consistency diagnosis result for the diagnostic data based on the sequence diagnosis result and the verification diagnosis result.
[0006] In one embodiment of the present invention, if the data to be diagnosed comes from an EtherCAT slave network node, the method further includes: obtaining the current data frame of the current period and the number of nodes of the EtherCAT slave network node corresponding to the current data frame, wherein the current data frame includes node frame data of the EtherCAT slave network node of the specified number of nodes; if the node frame data has not yet obtained a data consistency diagnosis result, using the node frame data of the EtherCAT slave network node as the data to be diagnosed, and determining the data consistency diagnosis result of the data to be diagnosed, until all node frame data has obtained a data consistency diagnosis result; and determining the data consistency diagnosis result of the current data frame based on the data consistency diagnosis results of all EtherCAT slave network nodes.
[0007] In one embodiment of the present invention, the method further includes at least one of the following: storing the diagnostic time in association with the data consistency diagnostic result of the current data frame, wherein the data consistency diagnostic result of the current data frame includes the data consistency diagnostic result of the node frame data of each EtherCAT slave network node; if the data consistency diagnostic result of the current data frame is inconsistent, designating the EtherCAT slave network nodes with inconsistent data consistency diagnostic results as abnormal nodes; and the PLC system reads the data consistency diagnostic result of the current data frame, and if the data consistency diagnostic result of the current data frame is inconsistent, triggering the PLC system to adjust its operating behavior.
[0008] In one embodiment of the present invention, the generation method of the current data frame includes: acquiring input process data of an EtherCAT slave network node to obtain the current transmission data; determining the generation sequence of the input process data to obtain a current data sequence identifier; determining the current cyclic redundancy check data based on the current transmission data and the current data sequence identifier; generating node frame data of the EtherCAT slave network node based on the current data sequence identifier, the current transmission data, and the current cyclic redundancy check data; and inserting the node frame data of each EtherCAT slave network node into the corresponding data position of the initial data frame to obtain the current data frame.
[0009] In one embodiment of the present invention, if the data to be diagnosed comes from a PLC system, the method further includes: obtaining a preset number of entry data in the output data area and a current number of entry data in the currently stored entry data, wherein the entry data includes output process data sent by the PLC system; generating a periodic output data message based on the currently stored entry data; if the preset number of entry data is equal to the current number of entry data, taking each entry data as the data to be diagnosed and determining the data consistency diagnosis result of the diagnostic data; and determining the data consistency diagnosis result of the periodic output data message based on the data consistency diagnosis results of all entry data.
[0010] In one embodiment of the present invention, generating a periodic output data message based on currently stored entry data includes: obtaining a periodic message identifier and output process data sent by the PLC system to obtain the current transmission data; determining the generation sequence of the output process data to obtain a current data sequence identifier; determining the current cyclic redundancy check data according to the periodic message identifier, the current transmission data, and the current data sequence identifier; generating the entry data based on the periodic message identifier, the current data sequence identifier, the current transmission data, and the current cyclic redundancy check data, and writing the entry data into the output data area; and generating the periodic output data message based on the entry data in the output data area.
[0011] In one embodiment of the present invention, the method further includes: if the preset number of entry data is not equal to the current number of entry data, determining that the consistency diagnosis result of the number of entries in the periodic output data message is inconsistent; if the preset number of entry data is equal to the current number of entry data, determining that the consistency diagnosis result of the number of entries in the periodic output data message is consistent.
[0012] In one embodiment of this application, the method further includes: associating and storing the diagnosis time with the consistency diagnosis result of the number of entries and the data consistency diagnosis result of the periodically output data packets; if the consistency diagnosis result of the number of entries is inconsistent, and / or if the data consistency diagnosis result is inconsistent, using the diagnosis time as the error occurrence time; if the consistency diagnosis result of the number of entries is inconsistent, and / or if the data consistency diagnosis result is inconsistent, determining the error type based on the consistency diagnosis result of the number of entries and the data consistency diagnosis result.
[0013] This application embodiment also provides an EtherCAT master protocol stack, which includes: a data storage area for storing diagnostic data received by the EtherCAT master protocol stack, the diagnostic data including a current data sequence identifier, current transmitted data, and current cyclic redundancy check (CRUD) data; a diagnostic module for determining a sequence diagnostic result based on the current data sequence identifier and historical data sequence identifiers, determining verification CRUD data based on the diagnostic data, wherein the determination rule for the verification CRUD data is the same as the determination rule for the current CRUD data, determining a verification diagnostic result based on the verification CRUD data and the current CRUD data, and determining a data consistency diagnostic result for the diagnostic data based on the sequence diagnostic result and the verification diagnostic result; a diagnostic result storage module for storing the data consistency diagnostic result for the diagnostic data; and a diagnostic result access interface for responding to a diagnostic result access request and transmitting the data consistency diagnostic result corresponding to the diagnostic result access request.
[0014] This application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the method provided in any of the above embodiments.
[0015] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method provided in any of the above embodiments.
[0016] This application also provides a computer program product or computer program, wherein the computer program product includes a computer program stored in a computer storage medium, and when the computer program in the computer storage medium is executed by a processor, it is used to load and execute the steps of the method provided in any of the above embodiments.
[0017] In the aforementioned PLC data consistency diagnosis method, EtherCAT master protocol stack, and electronic device implementation scheme, this method acquires the data to be diagnosed received by the EtherCAT master protocol stack. The data to be diagnosed includes the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check data. The method determines the sequence diagnosis result based on the current data sequence identifier and historical data sequence identifiers. It then determines the verification cyclic redundancy check data based on the data to be diagnosed, using the same rules as the current cyclic redundancy check data. Finally, it determines the verification diagnosis result based on the verification and verification diagnosis results. Based on the sequence diagnosis result and the verification diagnosis result, it determines the data consistency diagnosis result of the data to be diagnosed. This method can promptly determine the data consistency between the data received by the EtherCAT master protocol stack and the data generated by the data source, providing reference information for the subsequent operation of the PLC system. This facilitates the timely detection of problems and adjustment of the PLC system's operating behavior.
[0018] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 A schematic diagram of the PLC system IO data transmission principle provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure block diagram for real-time data diagnosis of the EtherCAT master station protocol stack using the PLC data consistency diagnosis method provided in the embodiments of the present invention. Figure 3 A flowchart illustrating the PLC data consistency diagnosis method provided in this embodiment of the invention; Figure 4 A schematic flowchart of a PLC data consistency diagnosis method provided in an embodiment of the present invention; Figure 5 A schematic diagram of the encapsulation structure for periodic node input data provided in an embodiment of the present invention; Figure 6A schematic diagram illustrating the correspondence between node frame data and periodic process input data in an embodiment of the present invention using EtherCAT related message data. Figure 7 A schematic diagram of the encapsulation structure of the output data area data entry encapsulation structure provided in the embodiments of the present invention; Figure 8 A schematic diagram illustrating the correspondence between the data of the entries and the EtherCAT related message data of the periodic output data provided in the embodiments of the present invention; Figure 9 A schematic flowchart of a PLC data consistency diagnosis method provided in an embodiment of the present invention; Figure 10 This is a schematic diagram of the structure of an EtherCAT master protocol stack provided in an embodiment of the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] Please see Figure 1 As shown, Figure 1 This is a schematic diagram of the PLC system IO data transmission principle block diagram provided in an embodiment of the present invention, as shown below. Figure 1 As shown, the PLC real-time data processing system (PLC system) writes data sent to a node in the EtherCAT slave network into the output data area defined on the CPU module. Then, the EtherCAT master protocol stack reads this output data and sends it to the corresponding EtherCAT slave node via the periodic output process data message sent by the EtherCAT master. Similarly, the EtherCAT master protocol stack also writes the input data from the EtherCAT slave network nodes, which are returned with periodic input process data frames, into the input data area defined on the CPU module for the PLC real-time data processing system to read. The PLC real-time data processing system communicates with the PLC online monitoring software via Ethernet.
[0023] The inventors discovered the following potential causes of inconsistencies between the data received by the EtherCAT master protocol stack and the data generated by the data source: failure of the data generation source leading to a failure to update data in real time; write operation errors when writing data to the output data area; output data area failure; and read operation errors when the EtherCAT master protocol stack reads data. Therefore, the EtherCAT master protocol stack needs to perform data consistency diagnostics on the data sent to it by both sides (PLC system and EtherCAT slave node).
[0024] Please see Figure 2 As shown, Figure 2 This is a schematic diagram of the structure block diagram for real-time data diagnosis of the EtherCAT master station protocol stack using the PLC data consistency diagnosis method provided in this embodiment of the invention, as shown below. Figure 2 As shown, the EtherCAT master protocol stack needs to perform data diagnostics on the output process data sent by the PLC real-time data processing system to the corresponding EtherCAT slave nodes and the input process data returned by the corresponding nodes in the EtherCAT slave network to the EtherCAT master. It also needs to save the diagnostic results and provide an interface for accessing those results. The real-time data diagnostic function of the EtherCAT master protocol stack is a sub-function responsible for performing real-time diagnostics on the data transmitted to the EtherCAT master protocol stack and writing the real-time diagnostic results to the diagnostic result storage space allocated by the protocol stack. This includes real-time data update status, diagnostic results, and a diagnostic history table. Users can read the diagnostic history results at any time through the diagnostic result access interface. The diagnostic results are stored in the form of a table (a linked list generated by a data structure), and this table is called the "Diagnostic History Table."
[0025] Please see Figure 3 As shown, Figure 3 A flowchart illustrating the PLC data consistency diagnosis method provided in this embodiment of the invention includes the following steps: Step S301: Obtain the diagnostic data received by the EtherCAT master protocol stack.
[0026] The data to be diagnosed includes the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check data.
[0027] The data to be diagnosed can be node frame data in the input data area or entry data in the output data area.
[0028] Step S302: Determine the sequence diagnosis result based on the current data sequence identifier and the historical data sequence identifier.
[0029] Historical data sequence identifiers are the same as those used in previous diagnostics of the current data sequence. For example, they can be unique within the same period. If two diagnostics within the same period find duplicate current data sequence identifiers, it indicates a potential anomaly, and the data consistency diagnosis fails, indicating inconsistency. If the current data sequence identifier differs from the historical data sequence identifier, the sequence diagnosis result is successful; conversely, if the current data sequence identifier is the same as a historical data sequence identifier, the sequence diagnosis result is unsuccessful. The sequence diagnosis results can determine whether the inconsistency is due to a failure at the data generation source, resulting in a failure to update data in real time. If a failure at the data generation source leads to a failure to update data in real time, it may result in a failed sequence diagnosis result.
[0030] Step S303: Determine the verification cyclic redundancy check data based on the data to be diagnosed.
[0031] The rules for determining the verification cyclic redundancy check (CRAC) data are the same as those for determining the current CRAC data. This means that the same data rules and data items are used when calculating the verification CRAC data as when calculating the current CRAC data.
[0032] Step S304: Determine the verification diagnosis result based on the verified cyclic redundancy check data and the current cyclic redundancy check data.
[0033] The current cyclic redundancy check (CRUD) data is the data generated at the source (PLC system or EtherCAT slave network node) before the data is written to the output or input data area. The CRUD verification data is determined based on the data to be diagnosed after it has been written to the output or input data area. In this way, if the CRUD verification data is the same as the current CRUD data, the verification result is passed, which can rule out data anomalies caused by factors such as write operation errors when writing data to the output data area.
[0034] As an example, if the entry ID does not change within a certain period, or if no data can be read from the output data area, then the output data area is considered faulty. If no data is read, or the CRC check of the read data fails, then the read operation performed by the EtherCAT master protocol stack is considered to have failed.
[0035] Step S305: Determine the data consistency diagnosis result of the data to be diagnosed based on the sequence diagnosis result and the verification diagnosis result.
[0036] For the data to be diagnosed in the input data area, if both the sequence diagnosis result and the verification diagnosis result are passed, the data consistency diagnosis result is passed; otherwise, if at least one of the sequence diagnosis result and the verification diagnosis result is failed, the data consistency diagnosis result is failed.
[0037] For the data to be diagnosed in the output data area, it is also necessary to determine the number of the periodic output data frames that may be sent (Cyclic Frame Id, which must be consistent with the number of periodic output data frames generated during the configuration phase). This facilitates the diagnostic program's diagnosis of the correspondence between this data entry and the periodic output data frame data (the preset number of entry data in the output data area). The consistency check result is obtained by combining the entry number consistency diagnosis result, sequence diagnosis result, and check diagnosis result through the judgment of the current entry number and the preset entry number (entry sequence diagnosis) and whether the periodic message identifier is repeated (entry ID diagnosis).
[0038] In one embodiment, if the data to be diagnosed comes from an EtherCAT slave network node, the method further includes: obtaining the current data frame of the current period and the number of nodes of the EtherCAT slave network node corresponding to the current data frame, wherein the current data frame includes node frame data of the EtherCAT slave network node with the number of nodes; if the node frame data has not yet obtained a data consistency diagnosis result, the node frame data of the EtherCAT slave network node is used as the data to be diagnosed, and the data consistency diagnosis result of the data to be diagnosed is determined, until all node frame data has obtained a data consistency diagnosis result; and the data consistency diagnosis result of the current data frame is determined based on the data consistency diagnosis results of all EtherCAT slave network nodes.
[0039] Following the above embodiments, the method further includes at least one of the following: The diagnostic time is associated with the data consistency diagnostic result of the current data frame and stored. The data consistency diagnostic result of the current data frame includes the data consistency diagnostic result of the node frame data of each EtherCAT slave network node. The diagnostic time can be the current system time. This makes it easier to perform statistical analysis on the historically stored data consistency diagnostic results to determine the time when data inconsistency occurred and other information. If the data consistency diagnosis result of the current data frame is inconsistent, the EtherCAT slave network nodes with inconsistent data consistency diagnosis results will be regarded as abnormal nodes. This will help locate abnormal nodes and facilitate subsequent handling. The PLC system reads the data consistency diagnostic result of the current data frame. If the data consistency diagnostic result of the current data frame is inconsistent, the PLC system is triggered to adjust its operating behavior. If data inconsistency occurs, it can be detected in a timely manner, and the risk of using erroneous data in the next process can be avoided. The operating behavior includes, but is not limited to, stopping data transmission or switching to a redundant system, and various remedial or safety states.
[0040] The EtherCAT master protocol stack performs consistency diagnosis on the node input data of the read process data, which can not only diagnose whether the data is consistent, but also locate the abnormal node in combination with the node configuration situation.
[0041] For an exemplary consistency diagnosis process of node input process data by the EtherCAT master protocol stack, please refer to Figure 4 as shown in Figure 4 which is a specific schematic flowchart of the PLC data consistency diagnosis method provided by the embodiment of the present invention, as shown in Figure 4 the following: acquiring the current periodic input process data frame (current data frame), acquiring the current system time as the occurrence time t (diagnosis time) of this diagnosis, acquiring the number (m) of nodes whose input data is included in the current data frame (the number of nodes) in combination with the node configuration situation, initializing the number of currently diagnosed nodes: i=0, if i<m, acquiring the node number n of the i-th node according to the configuration situation (for example, the constraint situation on entries, such as how many entries are configured), performing node frame sequence diagnosis to obtain a sequence diagnosis result, and performing data CRC diagnosis to obtain a check diagnosis result, and saving the diagnosis results. If m is 1, the data consistency diagnosis result of the data to be diagnosed can be determined according to the sequence diagnosis result and the check diagnosis result at this time, and the diagnosis result is saved. If m is greater than 1, the sequence diagnosis and check diagnosis are performed on the next node, the data consistency diagnosis result of the current data frame is determined according to the data consistency diagnosis results of all EtherCAT slave network nodes, the diagnosis result is saved, and the process ends.
[0042] The EtherCAT master protocol stack will immediately trigger and start the node input data consistency diagnosis function when receiving the periodic input process data frame, and perform diagnosis on the node input data in combination with the configuration situation of the periodic node input data, and the diagnosis result will be saved in time. Users can quickly locate the cause of the fault by analyzing the historical diagnosis results of the read node input data. The PLC system can also read the diagnosis result in real time, adjust the operation behavior of the PLC system, avoid catastrophic consequences caused by abnormal data or failure of real-time data update, and provide guarantee for the reliable operation of the PLC system.
[0043] In some embodiments, the current data frame is generated by: acquiring input process data of an EtherCAT slave network node to obtain current transmission data; determining the generation sequence of the input process data to obtain a current data sequence identifier; determining current cyclic redundancy check (CRC) data based on the current transmission data and the current data sequence identifier; generating node frame data of the EtherCAT slave network node based on the current data sequence identifier, the current transmission data, and the current CRC data; and inserting the node frame data of each EtherCAT slave network node into the corresponding data position of the initial data frame to obtain the current data frame.
[0044] It is understood that steps S301 to S305 can be used as diagnostic steps for node frame data. The current data frame includes node frame data corresponding to multiple EtherCAT slave network nodes.
[0045] Please see Figure 5 As shown, Figure 5 A schematic diagram of the encapsulation structure for periodic node input data provided in an embodiment of the present invention is shown below. Figure 5 As shown, when configuring periodic input process data messages, each node with input process data must be configured. The data configuration encapsulation of each node must be uniform. The current method is to add header and trailer fields to the node data to obtain a node frame data. The current data frame (periodic node input data) is then obtained based on multiple node frame data. st Node Frame, 2 nd Node Frame … n th Node Frame. Take 1 st Taking NodeFrame as an example, the meaning of each field is as follows: Node Frame Sequence (Current Data Sequence Identifier): This field is the header field of the input process data for EtherCAT slave network nodes. It is used to indicate the generation sequence of node data. The node controller needs to periodically or when it receives an event to increment this data. As an example, it can be 4 bytes. Node Data (currently transmitted data, input process data of EtherCAT slave network nodes): Node data that the EtherCAT slave needs to send to the EtherCAT master. For example, it can be 0~1480 bytes. 3) Cyclic Redundancy Check (CRC, current CRC data): The result of performing cyclic redundancy check on the node frame sequence and node data. As an example, it can be 2 bytes.
[0046] Please see Figure 6 As shown, Figure 6 A schematic diagram illustrating the correspondence between node frame data and EtherCAT-related message data of periodic process input data provided in this embodiment of the invention, as shown below. Figure 6 As shown, the correspondence between node frame data and EtherCAT related message data of periodic process input data can be as follows: one periodic process input data (current data frame) includes multiple node frame data 1 st Node Frame, 2 nd Node Frame … n th Node Frame.
[0047] The above data encapsulation method takes into account the different transmission methods and data mapping methods of bilateral data. According to the characteristics of the data, the encapsulation method is adopted for bilateral data so that the real-time data diagnostic function of the EtherCAT master station protocol stack can diagnose the data consistency results in a timely and efficient manner.
[0048] In some embodiments, if the data to be diagnosed comes from a PLC system, the method further includes: obtaining a preset number of entry data in the output data area and a current number of entry data in the currently stored entry data, wherein the entry data includes output process data sent by the PLC system; generating a periodic output data message based on the currently stored entry data; if the preset number of entry data is equal to the current number of entry data, taking each entry data as the data to be diagnosed and determining the data consistency diagnosis result of the diagnostic data; and determining the data consistency diagnosis result of the periodic output data message based on the data consistency diagnosis results of all entry data.
[0049] Following the above embodiments, generating periodic output data messages based on currently stored entry data includes: obtaining a periodic message identifier and output process data sent by the PLC system to obtain current transmission data; determining the generation sequence of the output process data to obtain a current data sequence identifier; determining current cyclic redundancy check data based on the periodic message identifier, current transmission data, and current data sequence identifier; generating entry data based on the periodic message identifier, current data sequence identifier, current transmission data, and current cyclic redundancy check data, and writing the entry data into the output data area; and generating periodic output data messages based on the entry data in the output data area.
[0050] Please see Figure 7 As shown, Figure 7 A schematic diagram of the encapsulation structure of the output data area data entry encapsulation structure provided in the embodiments of the present invention is shown below. Figure 7 As shown, the PLC real-time data processing system outputs periodic messages (1) to each possible EtherCAT slave network. st Entry, 2nd Entry…n th Based on the data from the Entry, the periodic output data frames that may be sent are numbered (Cyclic Frame ID, which must match the number of periodic output data frames generated during the configuration phase, serving as a periodic message identifier). This facilitates the diagnostic program's diagnosis of the correspondence between this data entry and the periodic output data frame data. Before writing to the output data area, the data portion is packaged and encapsulated to generate a data entry containing periodic output data. The encapsulation structure of the entry is as follows: The meaning of each field is as follows: Entry ID (Periodic Message Id): Indicates which periodic output data packet this packet belongs to. As an example, it can be used as an entry ID, which is 4 bytes. Entry Sequence (Current Data Sequence Identifier): Each time the PLC real-time data processing system writes this periodic data to the output data area, it must increment this data segment. As an example, it can be used as an entry sequence, 4 bytes. Periodic message data (Data, output process data sent by the PLC system, currently transmitted data): The data to be updated to the EtherCAT periodic output message Data segment. As an example, it can be periodic output message data, 0~1486 bytes; 4) Cyclic Redundancy Check (CRC, Current Cyclic Redundancy Check Data): The result of performing cyclic redundancy check on all data in the periodic message ID, message sequence, and periodic message data fields. As an example, it can be 2 bytes.
[0051] Please see Figure 8 As shown, Figure 8 A schematic diagram illustrating the correspondence between the data of the entries and the EtherCAT related message data of the periodic output data provided in this embodiment of the invention, as shown below. Figure 8 As shown, a periodic output data message includes Entry Id (periodic message identifier), Entry Sequence (current data sequence identifier), Data (current transmitted data), and CRC (current cyclic redundancy check data). The Data in the EtherCAT related message of the periodic output data comes from the entry data. The above method ensures consistency in data encapsulation and decapsulation during data consistency diagnostics by the EtherCAT master protocol stack. Considering the differences in transmission methods and data mapping between the two sides, different encapsulation methods are adopted for the two sides based on their characteristics. This allows the EtherCAT master protocol stack's real-time data diagnostic function to promptly and efficiently diagnose data consistency.
[0052] Following the above embodiments, the method further includes: if the preset number of entry data is not equal to the current number of entry data, determining that the consistency diagnosis result of the number of entries in the periodically output data message is inconsistent; if the preset number of entry data is equal to the current number of entry data, determining that the consistency diagnosis result of the number of entries in the periodically output data message is consistent.
[0053] Following the above embodiments, the method further includes: associating and storing the diagnosis time with the consistency diagnosis results of the number of entries and the data consistency diagnosis results of the periodically output data packets; if the consistency diagnosis result of the number of entries is inconsistent, and / or if the data consistency diagnosis result is inconsistent, using the diagnosis time as the error occurrence time; if the consistency diagnosis result of the number of entries is inconsistent, and / or if the data consistency diagnosis result is inconsistent, determining the error type based on the consistency diagnosis results of the number of entries and the data consistency diagnosis results.
[0054] As an example, error types include, but are not limited to, one or more of the following: entry ID error, entry sequence error, entry data CRC error, etc.
[0055] Diagnostic results need to be stored as an entry sequence, meaning all entries are numbered sequentially, and the diagnostic results are saved under each entry sequence. For example, if a diagnosis is triggered by a periodic event, recording the number of diagnoses reveals the number of successful write accesses, allowing the upper layer to determine the number of write accesses and the number of successful write accesses. Comparison with historical diagnoses allows for statistical analysis of diagnostic results for the same error type, such as the time of occurrence and duration of the error. The start time for each error is the system time read when the error was first diagnosed; recording this is for analyzing when the error began, allowing users to analyze the causes of the error by combining this time with internal and external events.
[0056] The EtherCAT master protocol stack performs consistency diagnosis on the output data sent by the PLC real-time data processing system. When the data sent by the PLC real-time data processing system is inconsistent with the data read by the EtherCAT master protocol stack, the EtherCAT master protocol stack can record the data inconsistency in a timely manner, providing reliable data support for users to analyze faults, or reminding users of the current data anomaly, hoping that users can take appropriate next steps based on the anomaly.
[0057] For an example of a consistency diagnostic process for output data sent by a PLC real-time data processing system to an EtherCAT master protocol stack, please refer to [link / reference]. Figure 9 As shown, Figure 9A specific flowchart illustrating the PLC data consistency diagnosis method provided in this embodiment of the invention is shown below. Figure 9 As shown, the number of data entries configured in the output data area (preset number of data entries) is obtained. For example, one method is to obtain n = Diag_GetConfigEnteiesNum(). The number of entries in the current output data area (current number of data entries) is obtained. For example, one method is to obtain m = Diag_GetCurrentEnteiesNum(). It is determined whether m is equal to n. If not (m and n are not equal), the diagnostic result (consistency diagnostic result of the number of entries) is saved. If m is equal to n, the current system time is obtained as the occurrence time t (diagnostic time) of this diagnosis. The number of data entries diagnosed is initialized to i = 0. If i is less than n, the entry ID diagnosis is performed to obtain the consistency diagnostic result of the number of entries. The entry sequence diagnosis is performed to obtain the sequence diagnostic result. The entry data CRC diagnosis is performed to obtain the verification diagnostic result. The diagnostic result of each data entry is saved until i equals n, and the process ends.
[0058] The EtherCAT master protocol stack can obtain the number of output data entries configured by the user and the number of entries currently existing in the output data area through relevant interfaces. By comparing the two, it can be determined whether the number of entries configured and the actual number of entries are consistent. If they are inconsistent, the consistency diagnosis result of the number of entries needs to be recorded; if they are consistent, the entry content diagnosis continues and the diagnosis result is saved.
[0059] For each item's diagnosis, the diagnosis result, the number of diagnoses, and the time when the error occurred should be recorded. The results should also be compared with historical diagnoses. Error items should be classified according to error type, and the start time of each type of error should be calculated.
[0060] In the aforementioned PLC data consistency diagnosis method, the EtherCAT master station performs consistency diagnosis on the output data sent by the PLC real-time data processing system and the input data replied by the EtherCAT nodes. This is achieved by acquiring the data to be diagnosed received by the EtherCAT master station protocol stack. This data includes the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check (CRUD) data. The sequence diagnosis result is determined based on the current data sequence identifier and historical data sequence identifiers. The CRUD verification data is then determined based on the data to be diagnosed, following the same rules as the current CRUD data. Finally, the verification diagnosis result is determined based on the verification and verification results. Based on the sequence diagnosis result and the verification diagnosis result, the data consistency diagnosis result of the data to be diagnosed is determined. This method can promptly determine the data consistency between the data received by the EtherCAT master station protocol stack and the data generated by the data source, providing reference information for the subsequent operation of the PLC system. This facilitates timely problem detection and adjustment of the PLC system's operational behavior.
[0061] In one embodiment, an EtherCAT master protocol stack is provided, which corresponds one-to-one with the methods in the above embodiments. Please refer to [link to relevant documentation]. Figure 10 , Figure 10 This is a schematic diagram of the structure of an EtherCAT master protocol stack provided in an embodiment of the present invention, as shown below. Figure 10 As shown, the EtherCAT master protocol stack 1000 includes a data storage area 1001 for storing diagnostic data received by the EtherCAT master protocol stack. The diagnostic data includes the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check (CRUD) data. A diagnostic module 1002 is used to determine the sequence diagnostic result based on the current data sequence identifier and historical data sequence identifiers, determine the verification CRUD data based on the diagnostic data (the determination rule for the verification CRUD data is the same as the determination rule for the current CRUD data), determine the verification diagnostic result based on the verification CRUD data and the current CRUD data, and determine the data consistency diagnostic result of the diagnostic data based on the sequence diagnostic result and the verification diagnostic result. A diagnostic result storage module 1003 is used to store the data consistency diagnostic result of the diagnostic data. A diagnostic result access interface 1004 is used to respond to a diagnostic result access request and transmit the data consistency diagnostic result corresponding to the diagnostic result access request.
[0062] The specific limitations of the EtherCAT master protocol stack described above can be found in the method limitations section above, and will not be repeated here. Each module in the EtherCAT master protocol stack can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0063] In one embodiment, a computer program product or computer program is provided, the computer program product including a computer program stored in a computer storage medium, and the computer program in the computer storage medium being executed by a processor to load and execute the method mentioned in any of the above embodiments.
[0064] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method mentioned in any of the above embodiments.
[0065] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method mentioned in any of the above embodiments.
[0066] It should be noted that, in the embodiments of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0067] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0068] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0069] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims. All of these forms are within the protection scope of this application.
Claims
1. A method for diagnosing PLC data consistency, characterized in that, Applied to the EtherCAT master protocol stack, the method includes: Obtain the diagnostic data received by the EtherCAT master protocol stack, wherein the diagnostic data includes the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check data; The sequence diagnostic result is determined based on the current data sequence identifier and the historical data sequence identifier; Based on the data to be diagnosed, verification cyclic redundancy check data is determined, and the rule for determining the verification cyclic redundancy check data is the same as the rule for determining the current cyclic redundancy check data. The verification diagnostic result is determined based on the verified cyclic redundancy check data and the current cyclic redundancy check data. The data consistency diagnostic result of the data to be diagnosed is determined based on the sequence diagnostic result and the verification diagnostic result.
2. The PLC data consistency diagnosis method as described in claim 1, characterized in that, If the data to be diagnosed comes from an EtherCAT slave network node, the method further includes: Obtain the current data frame of the current period, and the number of nodes of the EtherCAT slave network corresponding to the current data frame. The current data frame includes the node frame data of the EtherCAT slave network nodes of the current number of nodes. If the node frame data has not yet obtained a data consistency diagnosis result, the node frame data of the EtherCAT slave network node is used as the data to be diagnosed, and the data consistency diagnosis result of the data to be diagnosed is determined, until all node frame data has obtained a data consistency diagnosis result. The data consistency diagnostic result of the current data frame is determined based on the data consistency diagnostic results of all EtherCAT slave network nodes.
3. The PLC data consistency diagnosis method as described in claim 2, characterized in that, The method further includes at least one of the following: The diagnostic time is associated with the data consistency diagnostic result of the current data frame and stored. The data consistency diagnostic result of the current data frame includes the data consistency diagnostic result of the node frame data of each EtherCAT slave network node. If the data consistency diagnosis result of the current data frame is inconsistent, the EtherCAT slave network node whose data consistency diagnosis result is inconsistent will be regarded as an abnormal node. The PLC system reads the data consistency diagnosis result of the current data frame. If the data consistency diagnosis result of the current data frame is inconsistent, the PLC system is triggered to adjust its operating behavior.
4. The PLC data consistency diagnosis method as described in claim 2, characterized in that, The current data frame is generated in the following ways: Obtain the input process data of the EtherCAT slave network node to obtain the current transmission data; Determine the generation sequence of the input process data to obtain the current data sequence identifier; The current cyclic redundancy check data is determined based on the current transmitted data and the current data sequence identifier; The node frame data of the EtherCAT slave network node is generated based on the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check data. Insert the node frame data of each EtherCAT slave network node into the corresponding data position of the initial data frame to obtain the current data frame.
5. The PLC data consistency diagnosis method according to any one of claims 1-4, characterized in that, If the data to be diagnosed comes from a PLC system, the method further includes: The preset number of entry data in the output data area and the current number of currently stored entry data are obtained, wherein the entry data includes the output process data sent by the PLC system; Generate periodic output data messages based on the currently stored entry data; If the number of preset entry data is equal to the number of current entry data, each entry data is used as the data to be diagnosed, and the data consistency diagnosis result of the diagnostic data is determined. The data consistency diagnostic results of the periodic output data packets are determined based on the data consistency diagnostic results of all entry data.
6. The PLC data consistency diagnosis method as described in claim 5, characterized in that, Generate periodic output data messages based on the currently stored entry data, including: Obtain the periodic message identifier and the output process data sent by the PLC system to obtain the current transmission data; Determine the generation sequence of the output process data to obtain the current data sequence identifier; The current cyclic redundancy check data is determined based on the periodic message identifier, the current transmitted data, and the current data sequence identifier; The entry data is generated based on the periodic message identifier, the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check data, and the entry data is written into the output data area. The periodic output data message is generated based on the entry data in the output data area.
7. The PLC data consistency diagnosis method as described in claim 5, characterized in that, The method further includes: If the number of preset entry data is not equal to the number of current entry data, the consistency diagnosis result of the number of entries in the periodic output data message is determined to be inconsistent. If the preset number of entry data is equal to the current number of entry data, the consistency diagnosis result of the number of entries in the periodic output data message is determined to be consistent.
8. The PLC data consistency diagnosis method as described in claim 7, characterized in that, The method further includes: The diagnostic time is associated with the consistency diagnostic results of the number of entries in the periodic output data packets and the data consistency diagnostic results, and stored accordingly. If the consistency diagnosis result for the number of items is inconsistent, and / or if the consistency diagnosis result for the data is inconsistent, the diagnosis time shall be taken as the time when the error occurred. If the consistency diagnosis result of the number of entries is inconsistent, and / or if the consistency diagnosis result of the data is inconsistent, the error type shall be determined based on the consistency diagnosis result of the number of entries and the consistency diagnosis result of the data.
9. An EtherCAT master protocol stack, characterized in that, The EtherCAT master protocol stack includes: The data storage area is used to store the diagnostic data received by the EtherCAT master protocol stack. The diagnostic data includes the current data sequence identifier, the current transmitted data, and the current cyclic redundancy check data. The diagnostic module is used to determine the sequence diagnostic result based on the current data sequence identifier and the historical data sequence identifier, determine the verification cyclic redundancy check data based on the data to be diagnosed, wherein the determination rule for the verification cyclic redundancy check data is the same as the determination rule for the current cyclic redundancy check data, determine the verification diagnostic result based on the verification cyclic redundancy check data and the current cyclic redundancy check data, and determine the data consistency diagnostic result for the data to be diagnosed based on the sequence diagnostic result and the verification diagnostic result. A diagnostic result storage module is used to store the data consistency diagnostic results of the data to be diagnosed. The diagnostic result access interface is used to respond to a diagnostic result access request and transmit the data consistency diagnostic result corresponding to the diagnostic result access request.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 8.
