Communication method, networking system and Ethernet equipment
By configuring the target register of the EtherCAT slave to allow data back instantly, the problem of data transmission delay in the EtherCAT system is solved, and the data real-time and response speed are improved. It is suitable for application scenarios with complex topology and high real-time requirements.
Patent Information
- Application Number
- CN202411481230.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2024-12-24
AI Technical Summary
In the EtherCAT system, in the case of acquisition scenarios with a large number of slaves, complex topology structure and strict real-time requirements, data transmission delay leads to a reduction in real-time data, especially the data collected by the EtherCAT slaves located at the front end of the communication link. You need to wait for all other slaves to complete data collection before returning to the master station.
By configuring the target flag bit in the target register of the EtherCAT slave, the slave allows the collected data to be returned instantly, avoiding waiting for the last slave to complete the data acquisition and returning directly to the EtherCAT master station.
It improves the real-time acquisition speed of EtherCAT slave device data by the EtherCAT master station, improves the response speed and efficiency of the networking system, and is suitable for application scenarios that require rapid response.
Smart Images

Figure CN119182623A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communications, and in particular to a communication method, a networking system and an Ethernet device. Background Art
[0002] In the existing EtherCAT system, the PDO communication method of EtherCAT is to use the EtherCAT master station to send out PDO communication messages. When passing through each EtherCAT slave station in turn, according to the FMMU mapping rules, the logical read instruction is used to complete the data collection of the slave station device, and after reaching the last slave station node, it returns along the original path. That is, when the EtherCAT master station sends a PDO communication message to a series of EtherCAT slave stations, each EtherCAT slave station will process the PDO communication message in sequence, and then the PDO communication message will return to the EtherCAT master station along the same path.
[0003] However, in the case of a large number of slaves, a complex topology and strict real-time requirements, the data collected by the first EtherCAT slave needs to wait until the last EtherCAT slave completes the collection and returns to the EtherCAT master to be valid; furthermore, the existing communication process causes the data collected by the EtherCAT slave at the front end of the communication link to wait for all other EtherCAT slaves to complete the same data collection process before it can be returned to the EtherCAT master, which causes a delay in data transmission, thereby reducing the real-time performance of the data. Summary of the invention
[0004] In a first aspect, the present application provides a communication method, which is applied to an EtherCAT master station in a networking system, wherein the networking system includes an EtherCAT master station and a plurality of EtherCAT slave stations, and the method includes:
[0005] Configuring the value of the target flag bit in the target register of each EtherCAT slave station; the value of the target flag bit is used to indicate whether to perform a message return operation;
[0006] Sending a first communication message, wherein the first communication message passes through each of the EtherCAT slave stations in sequence;
[0007] A second communication message is received in return; the second communication message is a message that is immediately returned by the EtherCAT slave station for performing a message return operation after processing the first communication message.
[0008] In an optional embodiment, it also includes:
[0009] Parsing the returned second communication message to obtain a first working count value in the second communication message;
[0010] According to the first working count value, an abnormality check is performed on the second communication message.
[0011] In an optional implementation manner, performing anomaly checking on the second communication message includes:
[0012] Based on the second communication message, determining a first target slave station that performs a message return operation on the second communication message and a first position order of the first target slave station in the networking system;
[0013] Determine, according to the first position order, a first target count value corresponding to the first target slave station after performing the message return operation;
[0014] Determining whether the first working count value is equal to the first target count value;
[0015] If yes, determining that the second communication message transmitted back is a normal message;
[0016] If not, it is determined that the second communication message transmitted back is an abnormal message.
[0017] In an optional embodiment, it also includes:
[0018] Receive a third communication message; the third communication message includes device data acquired by all the EtherCAT slaves after executing the data read command in the first communication message;
[0019] Parsing the third communication message to obtain a second working count value in the third communication message;
[0020] performing an abnormality check on the third communication message according to the second working count value;
[0021] The performing abnormality check on the third communication message includes:
[0022] Based on the third communication message, determining the total number of all the EtherCAT slave stations;
[0023] According to the total number, determining a second target count value corresponding to when the last EtherCAT slave station returns the third communication message;
[0024] Determining whether the second working count value is equal to the second target count value;
[0025] If yes, determining that the third communication message is a normal message;
[0026] If not, it is determined that the third communication message is an abnormal message.
[0027] In an optional implementation manner, after receiving the third communication message, the method further includes:
[0028] Filtering out valid data from the device data carried by the third communication message specifically includes:
[0029] Determine each second target slave station that performs a message return operation and a second position order of each second target slave station in the networking system;
[0030] The device data arranged in positions corresponding to the second position order are removed from the data field of the third communication message, and the remaining device data in the third communication message is used as valid data.
[0031] In a second aspect, the present application provides a communication method, which is applied to an EtherCAT slave station in a networking system, wherein the networking system includes an EtherCAT master station and a plurality of EtherCAT slave stations, and the method includes:
[0032] Receiving a first communication message sent from the EtherCAT master station or the previous EtherCAT slave station;
[0033] Execute a data read command carried by the first communication message to obtain corresponding device data, and add the device data to the first communication message to obtain a second communication message;
[0034] Read the value of the target flag bit in the target register, and determine whether to perform a message return operation based on the value of the target flag bit;
[0035] If it is determined that the message return operation is currently being executed, the second communication message is immediately returned to the EtherCAT master station, and the second communication message is synchronously forwarded to the next EtherCAT slave station.
[0036] In an optional implementation, the determining whether to currently perform a message return operation based on the value of the target flag bit includes:
[0037] Determine whether the value of the target flag bit is a target value;
[0038] If yes, determine that the message return operation is currently being executed;
[0039] If not, it is determined that the message return operation is not currently executed.
[0040] In an optional embodiment, the method further comprises:
[0041] The third communication message to be transmitted back is forwarded to the previous EtherCAT slave station or the EtherCAT master station; the third communication message includes all the device data acquired by the EtherCAT slave stations after executing the data read command in the first communication message.
[0042] In a third aspect, the present application provides a networking system, including:
[0043] An EtherCAT master station, used to execute the aforementioned communication method;
[0044] Several EtherCAT slaves are respectively used to execute the aforementioned communication methods.
[0045] In a fourth aspect, the present application provides an Ethernet device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the aforementioned communication method.
[0046] The embodiments of the present application have the following beneficial effects:
[0047] An embodiment of the present application provides a communication method, which, when applied to an EtherCAT master station in a networking system, includes: configuring the value of a target flag bit in a target register of each EtherCAT slave station; the value of the target flag bit is used to indicate whether to perform a message return operation; sending a first communication message, the first communication message passing through each EtherCAT slave station in sequence; receiving a returned second communication message; the second communication message is a message that the EtherCAT slave station used to perform the message return operation immediately returns after executing the first communication message. The embodiment of the present application configures the value of the target flag bit in the target register of the corresponding EtherCAT slave station so that it has a message return function, so that the corresponding EtherCAT slave station can directly return the collected device data to the EtherCAT master station, without waiting for the last EtherCAT slave station to complete data collection before returning the corresponding device data to the EtherCAT master station, so that the EtherCAT master station can obtain the device data of the target EtherCAT slave station in real time more quickly, thereby improving the response speed and efficiency of the networking system, and also improving the real-time nature of the data, so that it can be effectively applied to certain application scenarios that require fast response, expanding the scope of application scenarios, and having good practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present application and should not be regarded as limiting the scope of protection of the present application. In each of the drawings, similar components are numbered similarly.
[0049] Figure 1 A schematic diagram of a network topology structure of a networking system is shown;
[0050] Figure 2 A schematic diagram of the internal structure of an EtherCAT slave is shown;
[0051] Figure 3 A schematic diagram of parameter configuration of the FMMU configuration register in the slave station control chip in an embodiment of the present application is shown;
[0052] Figure 4 A schematic diagram of parameter configuration of the Type attribute of the FMMU configuration register in the slave control chip in an embodiment of the present application is shown;
[0053] Figure 5 A schematic diagram of a first implementation method of an EtherCAT master station executing a communication method in an embodiment of the present application is shown;
[0054] Figure 6 A schematic diagram showing an implementation of the communication method performed by an EtherCAT slave in an embodiment of the present application is shown;
[0055] Figure 7 A schematic diagram of a second implementation of the communication method executed by the EtherCAT master station in an embodiment of the present application is shown;
[0056] Figure 8 A schematic diagram showing a third implementation of the communication method executed by the EtherCAT master station in the embodiment of the present application is shown. DETAILED DESCRIPTION
[0057] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0058] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0059] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present application, are intended only to indicate specific features, numbers, steps, operations, elements, components, or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations of the foregoing items.
[0060] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0061] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0062] PDO (Process Data Object) is a data transmission format used for real-time Ethernet (Ethernet / IP) communication. It is used to transmit real-time data and provide a direct access channel to device application objects. It achieves efficient data transmission and interaction between devices by encapsulating process data in a standardized message structure.
[0063] The Fieldbus Memory Management Unit (FMMU) is an important component in the EtherCAT slave controller. It is responsible for mapping logical addresses to physical memory, allowing data segments across multiple EtherCAT slaves to use logical addresses.
[0064] The EtherCat slave control chip (ESC) is a dedicated chip that implements the EtherCat data link layer protocol. It is used to process EtherCat data frames and provide a data interface for the slave control system.
[0065] In the communication mechanism using Ethernet protocol, Figure 1Taking the network topology diagram shown as an example, the Ethernet topology includes an EtherCAT master station and several EtherCAT slave stations, and the EtherCAT master station and the EtherCAT slave stations transmit signals or data through the Ethernet bus. Among them, the EtherCAT master station sends a PDO communication message to the EtherCAT slave station, and the PDO communication message will pass through each EtherCAT slave station in turn.
[0066] Furthermore, the EtherCAT master station can send a PDO communication message to the first EtherCAT slave station through the EtherCAT bus, and then the PDO communication message passes through each EtherCAT slave station in turn. After receiving the PDO communication message, each EtherCAT slave station responds to the instruction carried by the PDO communication message to complete the EtherCAT master station's data collection or writing operations on the EtherCAT slave station.
[0067] Among them, the equipment performance of each EtherCAT slave station in the network topology is the same, the distance between each EtherCAT slave station is the same, the EtherCAT master station and each EtherCAT slave station are connected by a 100M network cable with an MII interface, and each EtherCAT slave station collects an equal amount of data when responding to the read command issued by the EtherCAT master station.
[0068] For example, Figure 2 As shown, the EtherCAT master sends a PDO communication message to the EtherCAT slave. When the message passes through each EtherCAT slave in turn, the PDO communication message enters from the Port0 port (i.e., the input port) of each EtherCAT slave, and first passes through the frame processing unit for protocol data processing; then it is forwarded to other EtherCAT slaves through the Port2 port (i.e., the output port), wherein the message forwarding process does not pass through the frame processing unit but is directly forwarded through the Port2 port.
[0069] Among them, if the time for each EtherCAT slave station to process the PDO communication message through the frame processing unit after receiving it is set to t1, the transmission time between the ports of any two adjacent EtherCAT slave stations is t2, wherein the hardware delay is negligible; then, the EtherCAT master station sends out a PDO communication message, and when it passes through each EtherCAT slave station in turn, each EtherCAT slave station responds to the read instruction carried in the message to collect the internal slave device data, and after the PDO communication message arrives at the last EtherCAT slave station, the PDO communication message is returned along the original sending path, and each EtherCAT slave station does not process the returned PDO communication message.
[0070] Among them, taking the first EtherCAT slave station (i.e., slave station 1) as an example, at t1+t2, slave station 1 stores the data collected when responding to the read instruction into the corresponding position of the PDO communication message, and the PDO communication message after writing the data then passes through the remaining EtherCAT slave stations in turn (if the number of remaining slave stations required to pass is 8), and finally returns to the EtherCAT master station, then the time corresponding to the return of the PDO communication message to the master station is 9t1+18t2, which means that the data collected by slave station 1 at t1+t2 needs to be processed by the EtherCAT master station at 9t1+18t2, and then, as the number of slave stations in the Ethernet topology increases, the more complex its topology is, the time for the data collected by each slave station to be sent to the master station will increase by a multiple of (t1+2t2), that is, in this topology, the slave station with a higher ranking will be more affected in terms of the real-time performance of the collected data, which will cause the master station to be unable to respond quickly based on the real-time effectiveness of the collected data, affecting the overall processing efficiency.
[0071] It is understandable that when there are multiple EtherCAT slaves in the system, the real-time performance of the data will be affected. Because the data message needs to pass through each EtherCAT slave in turn before returning to the EtherCAT master, in this process, the data of the EtherCAT slave that sends the data first may be reduced in real time because it is waiting for other EtherCAT slaves to process the message. In other words, the data collected by the EtherCAT slave at the front end of the communication link needs to wait for all other EtherCAT slaves to complete the message processing before it can be returned to the EtherCAT master, which leads to delays in data transmission, especially when there are many EtherCAT slaves.
[0072] Based on this, an embodiment of the present application provides a networking system, which can be applied to fields such as industrial automation; illustratively, the networking system includes an EtherCAT master station and several EtherCAT slave stations. Signals or data are transmitted between the EtherCAT master station and the EtherCAT slave station via an Ethernet bus. Optionally, the number of EtherCAT master stations and EtherCAT slave stations in the networking system is not limited here. Among them, the EtherCAT master station can be a device such as a controller, and the EtherCAT slave station can be a device such as a sensor or an actuator.
[0073] In one example, before implementing communication between an EtherCAT master and an EtherCAT slave in a networking system, the EtherCAT master may send configuration information to the EtherCAT slave so that the EtherCAT slave automatically configures the slave's own achievable functions and other properties according to the configuration information.
[0074] The configuration process of the EtherCAT slave station may be completed during the initialization phase of the EtherCAT slave station to ensure that the EtherCAT slave station can correctly participate in the network communication within the networking system.
[0075] Furthermore, since the configuration information of the slave control chip in each EtherCAT slave can define the properties such as the functions that the slave itself can implement, and the Type attribute of the FMMU configuration register in the slave control chip is used to specify the configuration type of the FMMU in the EtherCAT slave control chip, which includes but is not limited to read, write or read / write operations.
[0076] Therefore, in order to improve the real-time and efficiency of data transmission in the system, this embodiment sets the Type attribute of the FMMU configuration register so that the corresponding EtherCAT slave station, based on the Type attribute value, obtains the corresponding device data (such as sensor readings, status information, etc.) through the data read command after receiving the PDO communication message containing the data read command sent by the EtherCAT master station or the previous EtherCAT slave station in the same networking system, and immediately returns the device data to the EtherCAT master station. At the same time, it also passes the same message to the next EtherCAT slave station according to the conventional message forwarding process, and then returns the device data obtained by itself to the EtherCAT master station without waiting for other EtherCAT slave stations to execute the data read command.
[0077] It can be seen that this embodiment can improve the real-time performance of data acquisition of EtherCAT slaves accordingly, can transmit data between networking systems with extremely low latency, and can be effectively applied to application scenarios that require precise synchronization and real-time control. In addition, this embodiment also increases the flexibility of the networking system, and can flexibly select which EtherCAT slaves need to transmit data faster (i.e., immediately transmit the collected device data back to the EtherCAT master) by configuring the Type data of the FMMU configuration register of each EtherCAT slave, without affecting the normal operation of other EtherCAT slaves, that is, the real-time performance of the data return of each EtherCAT slave is flexibly set, and the EtherCAT master can obtain real-time device data faster by modifying the configuration information of the EtherCAT slave without affecting the overall communication link, thereby improving the response speed and efficiency of the system.
[0078] Exemplarily, before realizing the communication between the EtherCAT master station and the EtherCAT slave station, the networking system pre-configures each EtherCAT slave station; specifically, the slave control chip of each EtherCAT slave station is parameterized to set the Type attribute of the FMMU configuration register in the slave control chip; wherein, the value of the target flag bit in the Type attribute is set to a specific value, so as to indicate through the value of the target flag bit in the Type attribute that after receiving a PDO communication message containing a data read command sent by the EtherCAT master station or the previous EtherCAT slave station in the same networking system, after obtaining the corresponding device data (such as sensor readings, status information, etc.) through the data read command, the EtherCAT slave station determines whether to immediately transmit the device data back to the EtherCAT master station.
[0079] Furthermore, if Figure 3 As shown in FIG. 1 , the FMMU configuration register in the slave control chip of the EtherCAT slave needs to be configured with various information items such as the logical start address (i.e. Logical Start Address), length (i.e. Length), logical start bit (i.e. Logical Start bit), logical stop bit (i.e. Logical Stop bit), physical start address (i.e. Physical Start Address), physical start bit (i.e. Physical Start bit), type (i.e. Type), activation field (Activate), reserved field (i.e. Reserved), etc. Among them, Figure 4 As shown in the figure, the read and write properties of the PDO communication message are controlled by the Type attribute after the mapping rules are configured in the FMMU configuration register.
[0080] Furthermore, during the configuration process of the EtherCAT slave station, the value of the target flag bit corresponding to the Type attribute of the FMMU configuration register of the slave control chip in each (or target) EtherCAT slave station is changed to a target value, wherein the meaning corresponding to the assignment of any flag bit of the Type attribute can be adaptively set according to actual needs, and this embodiment does not limit this.
[0081] In one embodiment, if Figure 4 As shown, bit 2 in the Type attribute is used as the target flag bit. When the target value is configured for the target flag bit, the value can be 0 or 1. Among them, the different flag bit values corresponding to the ECAT interface and the PDI interface in the Type attribute are used to indicate the read and write attributes of the interface, wherein the value of the flag bit (bit 0) is used to indicate whether it has a read attribute, and the value of the flag bit (bit 1) is used to indicate whether it has a write attribute. For example, when the value of the corresponding flag bit is set to 0, it indicates that the read and write attributes of the interface are unreadable or unwritable; when the value of the corresponding flag bit is set to 1, it indicates that the read and write attributes of the interface are readable or writable; if the value of bit 0 corresponding to the ECAT interface or PDI interface is 0, it indicates that it is unreadable; if the value of bit 1 corresponding to the ECAT interface or PDI interface is 0, it indicates that it is not writable. In addition, the flag bit (7:3) is a reserved field, and its value can be set to 0.
[0082] It should be noted that when configuring the Type attribute, the target flag bit (bit 2) can be set to a value of 0, indicating that the current EtherCAT slave does not need to perform a message return operation; the target flag bit (bit 2) can be set to a value of 1, indicating that the current EtherCAT slave needs to perform a message return operation; but the premise for performing the message return operation is that the value of the flag bit (bit 0) used to indicate the read attribute in the Type attribute is configured to be 1; that is, if the EtherCAT slave needs to be able to perform the message return operation normally, it is necessary to configure the EtherCAT slave to have both the data read attribute and the message return function, that is, the current EtherCAT slave itself needs to have the data read capability before it can normally perform the message return operation; in this embodiment, in order to ensure normal communication and data exchange transmission between the EtherCAT master and the EtherCAT slave, by default, all EtherCAT slaves are configured to have the data read attribute in the initialization phase, and then one or more of the EtherCAT slaves are specially configured to have the message return capability, so that the corresponding EtherCAT slave can normally perform the message return operation during the communication process.
[0083] This embodiment modifies the Type attribute setting of the FMMU configuration register in the EtherCAT slave station so that the corresponding EtherCAT slave station can immediately transmit the device data back to the EtherCAT master station after obtaining the device data, instead of waiting for all EtherCAT slave stations in the entire communication link in the networking system to complete the processing. In this way, the EtherCAT master station can receive real-time data from some EtherCAT slave stations more quickly.
[0084] Among them, when the target flag bit in the Type attribute of the FMMU register of the corresponding EtherCAT slave is set to a specific value, the acquired real-time device data is immediately returned to the EtherCAT master in the form of a PDO communication message (i.e., the message return operation is performed), and at the same time, the PDO communication message with the real-time device data added is passed to the next EtherCAT slave according to the normal process.
[0085] It should be noted that the number of EtherCAT slave stations configured to perform message return operations can be set accordingly according to actual needs, and this embodiment does not limit this; and since the last slave station only needs to perform a message return operation and does not perform a message forwarding operation downward, and when the PDO communication message reaches the last slave station, the PDO communication message already contains the device data corresponding to all slave stations except the last slave station. Therefore, there is no need to configure the message return function for the last slave station.
[0086] like Figure 5 As shown, exemplary, the EtherCAT master station in the networking system may specifically include the following steps in the process of realizing communication:
[0087] S110, configuring the value of the target flag bit in the target register of each EtherCAT slave station.
[0088] The value of the target flag bit is used to indicate whether to perform a message return operation.
[0089] S120: Send a first communication message.
[0090] S130, receiving a returned second communication message.
[0091] The second communication message is a message that the EtherCAT slave station used to perform the message return operation returns immediately after processing the first communication message.
[0092] It can be understood that the EtherCAT master station first configures the parameters of each EtherCAT slave station; wherein, in order to realize the real-time message feedback function of the EtherCAT slave station, the EtherCAT master station can send a configuration command to the corresponding EtherCAT slave station to configure the value of the target flag bit in the target register of the corresponding EtherCAT slave station, and then indicate whether the current EtherCAT slave station executes the message feedback function through the value of the target flag bit.
[0093] After completing the configuration of the EtherCAT slave station, the EtherCAT master station can be used to send PDO communication messages (i.e., first communication messages) to each EtherCAT slave station. During this process, the device data that needs to be mapped for each EtherCAT slave station can be set in the first communication message, and the FMMU mapping information can be configured.
[0094] Furthermore, a configured first communication message is sent to the EtherCAT slave station, wherein the first communication message passes through each EtherCAT slave station in sequence, and each EtherCAT slave station executes a preset message processing logic after receiving the first communication message, and determines whether to perform a message return operation according to the value of the target flag bit in the target register.
[0095] If the current EtherCAT slave station needs to perform a message return operation, it obtains a second communication message to be returned after executing the operation command (such as a data read command and / or a data write command) in the first communication message, and then returns the second communication message to the EtherCAT master station.
[0096] Correspondingly, after receiving the first communication message sent by the EtherCAT master, each EtherCAT slave station in the same networking system needs to perform corresponding processing on the first communication message (i.e., execute the preset message processing logic) to realize the communication interaction between the EtherCAT master station and the EtherCAT slave station.
[0097] like Figure 6 As shown, exemplarily, the process of the EtherCAT slave station realizing communication may include the following steps:
[0098] S210, receiving a first communication message sent from the EtherCAT master station or the previous EtherCAT slave station.
[0099] S220, executing a data read command carried in the first communication message to obtain corresponding device data, and adding the device data to the first communication message to obtain a second communication message.
[0100] S230, reading the value of the target flag bit in the target register, and determining whether to perform a message return operation based on the value of the target flag bit.
[0101] It can be understood that the EtherCAT master station sends the first communication message, and the first communication message passes through each EtherCAT slave station in the networking system in turn. This means that the first communication message first passes through the first slave station connected to the EtherCAT master station, and then is forwarded to the second slave station via the first slave station, and so on, the first communication message passes through each slave station in turn and reaches the last slave station. Furthermore, for the first slave station, the received first communication message is directly sent by the EtherCAT master station; and for any intermediate slave station and the last slave station, the received first communication message is forwarded by the corresponding previous EtherCAT slave station.
[0102] After receiving the first communication message, each EtherCAT slave parses the first communication message to obtain information such as operation commands carried by the first communication message. If the first communication message carries a data read command, the data read command is executed to read the corresponding device data of the current EtherCAT slave, and the device data is added to the target position in the first communication message according to the FMMU information in the first communication message. In this embodiment, for the convenience of distinguishing the description, the first communication message with the device data added is used as the second communication message.
[0103] The data read command instructs each EtherCAT slave to transmit the corresponding device data (such as status information, working parameters, etc.) read by itself back to the EtherCAT master in the form of a message. In addition, since the first communication message carries the FMMU mapping information, when executing the data read command, the corresponding device data can be obtained according to the FMMU mapping information and the device data can be added to the target position in the first communication message to obtain the second communication message.
[0104] In this embodiment, during the initialization process of the EtherCAT slave station, the value of the target flag bit (bit 2) in the Type attribute in the FMMU configuration register is set accordingly, and the value of the target flag bit is used to indicate whether the current EtherCAT slave station will immediately return the read device data to the EtherCAT master station after executing the data read command issued by the EtherCAT master station.
[0105] Furthermore, each EtherCAT slave station can automatically identify the target flag bit in its own target register, and determine whether to execute the message return operation based on the value of the target flag bit. The timing of reading the value of the target flag bit in the target register to determine whether to execute the message return operation can be adaptively set according to actual needs, and this embodiment does not limit this; for example, the process can be performed after executing the data read command, or after receiving the first communication message, or synchronously during the process of executing the data read command, etc.
[0106] After reading the target flag bit in the target register, each EtherCAT slave determines whether the value of the target flag bit is the target value; if the value of the target flag bit is the target value, it is determined that the message return operation is currently executed; if the value of the target flag bit is not the target value, it is determined that the message return operation is not currently executed.
[0107] The target register is the FMMU configuration register, and the target flag bit is the flag bit 2 of the Type attribute in the FMMU configuration register. Optionally, when the value of the flag bit 2 is set to 1, it indicates that the message return operation needs to be performed, and when the value of the flag bit 2 is set to 0, it indicates that the message return operation does not need to be performed.
[0108] S240: If it is determined that the message return operation is currently being performed, the second communication message is immediately returned to the EtherCAT master station, and the second communication message is synchronously forwarded to the next EtherCAT slave station.
[0109] It can be understood that if the current message return operation is determined based on the value of the target flag bit, the current EtherCAT slave station can directly return the second communication message with its own device data added to the EtherCAT master station immediately. During this process, the current EtherCAT slave station also forwards the second communication message to the next EtherCAT slave station.
[0110] That is, if it is determined that the message return operation is currently being performed, the EtherCAT slave station copies the second communication message to obtain two second communication messages, one of which is forwarded to the next EtherCAT slave station, and the other is returned to the EtherCAT master station.
[0111] Furthermore, the process of transmitting the second communication message back to the EtherCAT master station is that the current EtherCAT slave station transmits the second communication message back to the previous EtherCAT slave station, and the previous EtherCAT slave station transmits the second communication message back to the previous EtherCAT slave station, and so on, until it is transmitted back to the EtherCAT master station; that is, the return path of the second communication message passes through multiple EtherCAT slave stations between the current EtherCAT slave station and the EtherCAT master station in sequence, and finally reaches the EtherCAT master station, and in the process of transmitting the message back, each EtherCAT slave station does not process the second communication message in any way, and only performs the message forwarding operation.
[0112] Furthermore, after receiving the second communication message forwarded by the current EtherCAT slave station, the next EtherCAT slave station first parses the second communication message, and then executes the data read instruction in the second communication message, and adds the read device data to the target location of the second communication message; then, it determines whether to perform the message return operation, and performs the forwarding operation of the corresponding message according to the determination result.
[0113] That is, when any EtherCAT slave in the networking system performs a message return operation, the second communication message to be returned is returned upward, passes through one or more EtherCAT slaves in sequence, and finally reaches the EtherCAT master. That is, if the current EtherCAT slave receives the second communication message returned by the next EtherCAT slave, it does not process the second communication message and directly returns the second communication message upward to the previous EtherCAT slave; if the current EtherCAT slave is the first slave, the second communication message is directly returned to the EtherCAT master.
[0114] In one embodiment, Figure 7 As shown, the EtherCAT master can also perform the following steps:
[0115] S250, forwarding the third communication message to be returned to the previous EtherCAT slave station or the EtherCAT master station.
[0116] It should be noted that since each EtherCAT slave station in the networking system needs to execute the data read command issued by the EtherCAT master station, the first slave station, after receiving the first communication message containing the data read command, adds the read device data to the first communication message to obtain the second communication message, and then forwards the second communication message to the second slave station (regardless of whether the current EtherCAT slave station performs a message return operation, the second communication message will be forwarded to the next EtherCAT slave station), and after the second slave station executes the data read command, it also adds the read device data to the second communication message, and forwards the second communication message to the third slave station. At this time, the second communication message received by the third slave station contains the device data corresponding to the first slave station and the second slave station.
[0117] This means that the second communication message with the device data corresponding to each EtherCAT slave station will pass through each EtherCAT slave station in turn, and then, after receiving the second communication message containing the device data corresponding to (N-1) slave stations (where N is the total number of EtherCAT slave stations in the networking system), the last slave station executes the data read command and adds the read device data to the target position of the second communication message. In this way, all EtherCAT slave stations in the networking system have received the communication message containing the data read command issued by the EtherCAT master station and completed the data read command. At this time, the last slave station will return the second communication message with the device data of all slave stations to the EtherCAT master station.
[0118] Among them, for the convenience of distinction and explanation, this embodiment uses the second communication message received by the EtherCAT master station containing the device data of all EtherCAT slaves as the third communication message, that is, the third communication message is a message containing the device data obtained by all EtherCAT slaves after executing the data read command in the first communication message.
[0119] In addition, the third communication message can also be understood as including the message required to be returned during the normal communication process performed by each EtherCAT slave station (each EtherCAT slave station does not perform a message return operation).
[0120] In the process of returning the third communication message, the third communication message passes through each EtherCAT slave station in turn and finally reaches the EtherCAT master station; each EtherCAT slave station does not process the third communication message and only performs the message return operation.
[0121] It is worth noting that since the second communication message and the third communication message respectively contain different numbers of device data obtained by EtherCAT slaves after executing the data read command in the first communication message, the EtherCAT master station can obtain the device data of each EtherCAT slave station that performs the message return operation in real time according to the second communication message and the third communication message after receiving the returned second communication message and the third communication message, and verify the integrity of the entire communication link according to the third communication message containing the device data of all EtherCAT slave stations.
[0122] As an optional implementation, the returned second communication message and the third communication message may be checked for abnormalities respectively, and then the device data inside the message may be obtained when it is determined that the second communication message and the third communication message have no abnormalities, so as to ensure the accuracy of the obtained device data.
[0123] Among them, since each EtherCAT slave executes the operation command carried in the message once, the corresponding work count value in the message will increase according to the number of command executions, and then, the abnormality check of the message can be achieved through the work count value inside the message.
[0124] Furthermore, in one example, Figure 8 As shown, the EtherCAT master station can also perform the following steps during the communication process:
[0125] S140: parse the returned second communication message to obtain a first working count value in the second communication message.
[0126] S150: Perform an abnormality check on the second communication message according to the first working count value.
[0127] Exemplarily, based on the second communication message, determine the first target slave station that performs a message return operation on the second communication message and the first position order of the first target slave station in the networking system; according to the first position order, determine the first target count value corresponding to the first target slave station after performing the message return operation; judge whether the first working count value is equal to the first target count value; if the first working count value is equal to the first target count value, determine that the returned second communication message is a normal message; if the first working count value is not equal to the first target count value, determine that the returned second communication message is an abnormal message.
[0128] It can be understood that the second communication message currently received by the EtherCAT slave station is first parsed to obtain information (such as the target slave station identifier, address, etc.) for determining the position order of the first target slave station that performs the message return operation, and then the position order of the first target slave station in the networking system is determined based on the information; then, the cumulative value (i.e., the first target count value) of the corresponding working count value of each EtherCAT slave station when executing the corresponding operation command between the first slave station and the first target slave station is calculated based on the position order and the category and number of operation commands contained in the second communication message; wherein the cumulative value of the working count value indicates the total number of times each slave station completes the corresponding operation command in the process of the communication message passing through each slave station in turn from the first slave station to the first target slave station and finally arriving at the first target slave station. In addition, the cumulative value of the corresponding working count value when executing different types of operation commands in the same slave station may be different, which is adaptively set according to actual needs, and this embodiment does not limit this.
[0129] For example, if the communication message sent by the EtherCAT master station only contains one data read command, each slave station only performs a data read operation once after receiving the communication message, and the working count value in the communication message is only incremented by one each time; that is, after the first target slave station executes the data read command, the accumulated value of the working count value corresponds to the position order of the first target slave station in the networking system; for example, the first target slave station is the third slave station in the networking system, then the accumulated value of the working count value is 3.
[0130] Then, the first target count value is compared with the actual first working count value in the first communication message. If the first target count value is equal to the actual first working count value, it means that the second communication message is a normal message; otherwise, it means that the second communication message is an abnormal message.
[0131] Furthermore, the EtherCAT slave station also receives a third communication message; wherein the third communication message includes the device data acquired by all EtherCAT slave stations after executing the data read command in the first communication message.
[0132] It can be understood that the third communication message is the message returned by the last EtherCAT slave station; wherein, if the target flag bit of the last EtherCAT slave station is configured as the target value, the third communication message and the second communication message returned by the last EtherCAT slave station are the same message; optionally, the return operation of the message can be set to be executed only once (that is, after the last EtherCAT slave station has the message return function, it is set to only execute the message return operation once); if the target flag bit of the last EtherCAT slave station is not configured as the target value, the third communication message is the message returned by the last EtherCAT slave station based on the first communication message under the normal message forwarding logic.
[0133] In one embodiment, similar to the process of abnormality check of the second communication message, after receiving the third communication message, the third communication message can also be checked for abnormality to ensure the accuracy of the device data in the third communication message, thereby ensuring the reliability of subsequent verification of the integrity of the communication link.
[0134] Exemplarily, the abnormality check process of the third communication message may be: parsing the second communication message to obtain the second working count value in the third communication message; and performing abnormality check on the third communication message according to the second working count value.
[0135] In this process, first, based on the third communication message, the total number of all EtherCAT slave stations is determined; then, based on the total number, the second target count value corresponding to the last EtherCAT slave station returning the third communication message is determined; it is judged whether the second working count value is equal to the second target count value; if the second working count value is equal to the second target count value, the third communication message is determined to be a normal message; if the second working count value is not equal to the second target count value, the third communication message is determined to be an abnormal message.
[0136] It can be understood that the third communication message is first parsed to obtain information for determining the position order of all EtherCAT slave stations (such as the target slave station identifier, address, etc.), and then the total number of all EtherCAT slave stations is determined based on the information; then, the cumulative value of the corresponding working count value of each EtherCAT slave station when executing the corresponding operation command between the first slave station and the last slave station is calculated based on the total number (that is, the second target count value); wherein the cumulative value of the working count value indicates the total number of times each slave station completes the corresponding operation command in the process of the communication message passing through each slave station in sequence from the first slave station to the last slave station and finally arriving at the last slave station.
[0137] Correspondingly, the second target count value is compared with the actual second working count value in the third communication message. If the two are equal, it means that the third communication message is a normal message; otherwise, it is an abnormal message.
[0138] In one implementation, after receiving the returned second communication message and / or the third communication message, the EtherCAT master station can extract valid device data from the two messages, and then perform other operations according to the device data.
[0139] Among them, for the second communication message transmitted back, if it is determined that the second communication message is a normal message, the EtherCAT master station can directly read the device data from the second communication message. Since some device data in the second communication message and the third communication message overlap, if the device data of the overlapping part has been quickly read in the second communication message, there is no need to read it again for the third communication message.
[0140] It can be understood that, in theory, the speed at which the EtherCAT master station receives the second communication message is faster than the speed at which the EtherCAT master station receives the third communication message. Therefore, the EtherCAT master station can first quickly obtain the corresponding device data from the second communication message, which contains all the device data corresponding to the first slave station to the EtherCAT slave station currently performing the message return operation. Furthermore, if the third communication message is subsequently received, only the device data of all EtherCAT slave stations located after the EtherCAT slave station currently performing the message return operation in the second communication message can be obtained. For example, if the second communication message received by the EtherCAT master station includes the device data of each EtherCAT slave station between slave station 1 and slave station X; then when the EtherCAT master station receives the third communication message again, it can directly obtain the device data of each EtherCAT slave station between slave station X+1 and slave station N; wherein N is the total number of EtherCAT slave stations in the networking system, and X is the total number of EtherCAT slave stations in the EtherCAT network ... <N。
[0141] In some examples, exemplarily, after completing the data reading of the second communication message, it is necessary to filter the device data carried in the third communication message to read valid device data (i.e., non-duplicate device data) therefrom; wherein, the process of filtering out valid data from the device data carried by the third communication message may be to determine each second target slave station that performs the message return operation and the second position order of each second target slave station in the networking system; remove all device data between the position corresponding to each second position order and the first position from the data field of the third communication message, and use the remaining device data in the third communication message as valid data.
[0142] That is, all device data between the corresponding position of each EtherCAT slave station used to perform the message return operation and the first position are eliminated from the device data stored in the data domain of the third communication message, and this part of the device data is all the device data in the first communication message; and the remaining device data in the third communication message is used as the valid device data of the third communication message.
[0143] In order to ensure the simplicity of the data processing process, the position order of the last EtherCAT slave station that performs the message return operation can be directly determined, and the storage position of the device data of the slave station in the data field of the third communication message can be determined, so that all device data between the storage position and the first position can be directly eliminated, so that the remaining device data can be used as valid data, thereby achieving a one-time rapid elimination of invalid data and improving the efficiency of data processing. Among them, the process of the EtherCAT master station determining each EtherCAT slave station that performs the message return operation can be implemented based on the configuration record corresponding to the EtherCAT master station when initializing the configuration of each EtherCAT slave station, or based on the data reading situation of the second communication message, etc. This embodiment does not limit the implementation method of this determination process, and it can be adaptively set according to actual needs.
[0144] It should be noted that the above-mentioned abnormality check on the second communication message or the third communication message, and the operation of removing the corresponding device data from the third communication message can be determined whether to be performed according to actual needs, and this embodiment does not limit this.
[0145] Furthermore, this embodiment, without affecting the overall communication link, modifies the configuration of certain EtherCAT slaves to enable them to have a message return function, so that the EtherCAT master can more quickly obtain the real-time device data of the EtherCAT slaves configured with the message return function, thereby improving the response speed and efficiency of the system, and improving the real-time performance of data of certain specific EtherCAT slaves, so that it can be effectively applied to certain application scenarios that require a quick response. In addition, this embodiment also increases the flexibility of the networking system accordingly, and can flexibly select which EtherCAT slaves' device data needs to be transmitted faster without affecting the normal operation of other EtherCAT slaves, thereby improving the real-time performance and flexibility of the data transmission process.
[0146] The embodiment of the present application also provides an Ethernet device, which may be, but is not limited to, a sensor, an actuator, a controller, a driver, a switch, a router, a repeater, etc. Exemplarily, the Ethernet device includes a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to enable the Ethernet device to execute the communication method of the present application.
[0147] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. At least one of the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0148] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.
[0149] In addition, the present application also provides a computer storage medium for storing the computer program used in the above-mentioned Ethernet device, wherein the computer program, when executed on a processor, implements the communication method of the above-mentioned embodiment.
[0150] The computer storage medium may be a non-volatile storage medium or a volatile storage medium. For example, the computer storage medium may include, but is not limited to, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0151] In several embodiments provided in the present application, it should be understood that the disclosed system and method can also be implemented in other ways. The system embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0152] In addition, each step in each embodiment of the present application can be implemented by a functional module or unit, and the functional modules or units can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0153] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an Ethernet device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
[0154] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.
Claims
1. A communication method, characterized in that: Applied to an EtherCAT master station in a networking system, the networking system includes an EtherCAT master station and a plurality of EtherCAT slave stations, the method includes: Configuring the value of the target flag bit in the target register of each EtherCAT slave station; the value of the target flag bit is used to indicate whether to perform a message return operation; Sending a first communication message, wherein the first communication message passes through each of the EtherCAT slave stations in sequence; A second communication message is received in return; the second communication message is a message that is immediately returned by the EtherCAT slave station for performing a message return operation after processing the first communication message.
2. The communication method according to claim 1, characterized in that: Also includes: Parsing the returned second communication message to obtain a first working count value in the second communication message; According to the first working count value, an abnormality check is performed on the second communication message.
3. The communication method according to claim 2, characterized in that: The performing abnormality check on the second communication message includes: Based on the second communication message, determining a first target slave station that performs a message return operation on the second communication message and a first position order of the first target slave station in the networking system; Determine, according to the first position order, a first target count value corresponding to the first target slave station after performing the message return operation; Determining whether the first working count value is equal to the first target count value; If yes, determining that the second communication message transmitted back is a normal message; If not, it is determined that the second communication message transmitted back is an abnormal message.
4. The communication method according to claim 1, characterized in that: Also includes: Receive a third communication message; the third communication message includes device data acquired by all the EtherCAT slaves after executing the data read command in the first communication message; Parsing the third communication message to obtain a second working count value in the third communication message; performing an abnormality check on the third communication message according to the second working count value; The performing abnormality check on the third communication message includes: Based on the third communication message, determining the total number of all the EtherCAT slave stations; According to the total number, determining a second target count value corresponding to when the last EtherCAT slave station returns the third communication message; Determining whether the second working count value is equal to the second target count value; If yes, determining that the third communication message is a normal message; If not, it is determined that the third communication message is an abnormal message.
5. The communication method according to claim 4, characterized in that: After receiving the third communication message, the method further includes: Filtering out valid data from the device data carried by the third communication message specifically includes: Determine each second target slave station that performs a message return operation and a second position order of each second target slave station in the networking system; The device data arranged in positions corresponding to the second position order are removed from the data field of the third communication message, and the remaining device data in the third communication message is used as valid data.
6. A communication method, characterized in that: Applied to an EtherCAT slave station in a networking system, the networking system includes an EtherCAT master station and a plurality of EtherCAT slave stations, the method includes: Receiving a first communication message sent from the EtherCAT master station or the previous EtherCAT slave station; Execute a data read command carried by the first communication message to obtain corresponding device data, and add the device data to the first communication message to obtain a second communication message; Read the value of the target flag bit in the target register, and determine whether to perform a message return operation based on the value of the target flag bit; If it is determined that the message return operation is currently being executed, the second communication message is immediately returned to the EtherCAT master station, and the second communication message is synchronously forwarded to the next EtherCAT slave station.
7. The communication method according to claim 6, characterized in that: The determining whether to currently perform a message return operation based on the value of the target flag bit includes: Determine whether the value of the target flag bit is a target value; If yes, determine that the message return operation is currently being executed; If not, it is determined that the message return operation is not currently executed.
8. The communication method according to claim 6 or 7, characterized in that: The method further comprises: The third communication message to be transmitted back is forwarded to the previous EtherCAT slave station or the EtherCAT master station; the third communication message includes the device data acquired by all the EtherCAT slave stations after executing the data read command in the first communication message.
9. A networking system, characterized in that: include: An EtherCAT master station, configured to execute the communication method according to any one of claims 1 to 5; A plurality of EtherCAT slave stations are respectively used to execute the communication method described in any one of claims 6 to 8.
10. An Ethernet device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the communication method according to any one of claims 1 to 8.
