Communication method, electronic equipment and storage medium

By setting index information and parsing device description files for EtherCAT bus slaves and establishing mapping relationships, the problem that the EtherCAT bus cannot mix IO slaves and servo slaves is solved, and mixing and stable control of multiple types of slaves is realized.

CN120498918APending Publication Date: 2025-08-15BEIJING A&E TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510669268.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing EtherCAT bus communication solution cannot support mixing between IO slaves and servo slaves, resulting in the inability to achieve mixing of multiple types of slaves.

Method used

Set index information for slaves, obtain and parse the device description file of slaves, obtain PDO information of IO slaves and servo slaves, and establish corresponding mapping relationships to determine the storage location of PDO data in the main station memory and the location of data frames, thereby realizing control of different types of slaves.

Benefits of technology

The mixing between IO slaves and servo slaves is realized, and the convenience of the master station to control the slaves and the stability of communication is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120498918A_ABST
    Figure CN120498918A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method, electronic equipment and a storage medium. The communication method comprises the following steps: setting index information for the slave station; acquiring and analyzing an equipment description file of the slave station so as to respectively acquire PDO information of the IO slave station and PDO information of the servo slave station; based on the PDO information of the IO slave station and the PDO information of the servo slave station, respectively establishing a first mapping relation between the PDO data of the IO slave station and a master station data structure and a second mapping relation between the PDO data of the servo slave station and the master station data structure; wherein the first mapping relation is used for indicating the storage position of the PDO data in the master station memory; according to the first mapping relation, the second mapping relation, the PDO information and the index information, IO data corresponding to the IO slave station and control data corresponding to the servo slave station are read and written, and therefore the effect of mixed connection of various types of slave stations is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automatic control technology, and in particular to a communication method, electronic equipment, and storage medium. Background Art

[0002] Currently, servo motor control and I / O modules are two key components of industrial control. The EtherCAT fieldbus protocol meets the high-performance real-time requirements of the industrial control industry, enabling stable and reliable data transmission at the microsecond level. The industry is beginning to adopt EtherCAT as the communication protocol for servo motors and I / O modules, using ESC slave control chips to enable EtherCAT master control of servo systems and I / O modules.

[0003] However, the existing ECIO communication solution based on the EtherCAT bus does not support the mixed connection of multiple types of slaves. For example, it is impossible to achieve the mixed connection of IO slaves and servo slaves. Summary of the Invention

[0004] The present application at least provides a communication method, an electronic device, and a storage medium to achieve mixed connection of multiple types of slave stations.

[0005] In a first aspect, the present application provides a communication method, which is applied to a master station, wherein the master station communicates with multiple slave stations based on an EtherCAT bus, and the slave stations include IO slave stations and servo slave stations; the communication method includes: setting index information for the slave station; obtaining and parsing the device description file of the slave station to obtain the PDO information of the IO slave station and the PDO information of the servo slave station respectively; based on the PDO information of the IO slave station and the PDO information of the servo slave station, establishing a first mapping relationship between the PDO data of the IO slave station and the master station data structure, and a second mapping relationship between the PDO data of the servo slave station and the master station data structure respectively; wherein the first mapping relationship is used to indicate the storage location of the PDO data in the master station memory; according to the first mapping relationship, the second mapping relationship, the PDO information and the index information, the IO data corresponding to the IO slave station and the control data corresponding to the servo slave station are read and written.

[0006] The above scheme sets index information for each slave station, obtains and parses the device description file of the slave station to respectively obtain the PDO information of the IO slave station and the PDO information of the servo slave station, and based on the PDO information of the IO slave station and the PDO information of the servo slave station, respectively establishes a first mapping relationship between the PDO data of the IO slave station and the data structure of the master station, and a second mapping relationship between the PDO data of the servo slave station and the data structure of the master station, and then according to the first mapping relationship and the second mapping relationship, the storage location of the PDO data of the IO slave station and the PDO data of the servo slave station in the memory of the master station can be obtained respectively, so that the master station can respectively map the IO slave station and the PDO data of the servo slave station. The PDO data of the servo slave station is read and written; on the basis of the first mapping relationship and the second mapping relationship, combined with the index information and PDO information, the position of the read and write commands of each slave station on the data frame can be determined according to the index information, and the position of the PDO in the data frame can be obtained according to the PDO information. Therefore, after reading and writing the PDOs of the IO slave station and the servo slave station respectively according to the first mapping relationship and the second mapping relationship, the PDO of each slave station can be loaded into the corresponding position of the data frame according to the PDO information. After the slave station receives these data frames, it can control different types of slave stations, thereby realizing the mixed connection of multiple types of slave stations.

[0007] A second aspect of the present application provides an electronic device, comprising a memory and a processor coupled to each other, wherein the processor is configured to execute program instructions stored in the memory to implement the communication method in the first aspect.

[0008] A third aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, implement the communication method in the first aspect.

[0009] The above scheme sets index information for each slave station, obtains and parses the device description file of the slave station to obtain the PDO information of the IO slave station and the PDO information of the servo slave station respectively, and establishes a first mapping relationship between the PDO of the IO slave station and the master station data structure, and a second mapping relationship between the PDO of the servo slave station and the master station data structure respectively based on the PDO information of the IO slave station and the PDO information of the servo slave station. Then, according to the first mapping relationship and the second mapping relationship, the storage locations of the PDO of the IO slave station and the PDO of the servo slave station on the master station memory can be obtained respectively, so that the master station can respectively map the IO slave station and the servo slave station. The PDO of the station is read and written; on the basis of the first mapping relationship and the second mapping relationship, combined with the index information and PDO information, the position of the read and write commands of each slave station on the data frame can be determined according to the index information, and the position of the PDO in the data frame can be obtained according to the PDO information. Therefore, after reading and writing the PDOs of the IO slave station and the servo slave station respectively according to the first mapping relationship and the second mapping relationship, the PDO of each slave station can be loaded into the corresponding position of the data frame according to the PDO information. After the slave station receives these data frames, it can control different types of slave stations, thereby realizing the mixed connection of multiple types of slave stations.

[0010] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and, together with the specification, are used to illustrate the technical solutions of the present application.

[0012] Figure 1 is a flow chart of a communication method in one embodiment of the present application;

[0013] Figure 2 This is a schematic diagram of the connection between the master station and the slave station in one embodiment of the present application;

[0014] Figure 3 This is a schematic diagram of the framework of an embodiment of the electronic device of the present application;

[0015] Figure 4 This is a schematic diagram of a framework of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0016] The following describes the embodiments of the present application in detail with reference to the accompanying drawings.

[0017] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0018] The term "and / or" in this article is simply a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0019] In the industrial control field, a master station is typically connected to multiple slave stations. Each slave station may be equipped with a slave processor (MCU) and a slave controller (ESC). Depending on the type of slave station, the slave station may also be equipped with a servo system or an I / O module. For example, an I / O slave station may be equipped with an I / O module, while a servo slave station may be equipped with a servo system.

[0020] During a communication cycle between the master and slaves, the EtherCAT master packages data into EtherCAT data frames (data messages) and sends them to the EtherCAT bus. As the data frame travels downstream, it passes through the EtherCAT slaves on the bus, such as the X-axis EtherCAT servo slave, the Y-axis EtherCAT servo slave, and the EtherCAT IO slaves. Each slave extracts input data from the data frame and inserts output data into the frame. For example, a servo slave extracts input data such as the command position and inserts the feedback position as output data into the EtherCAT data frame. An IO slave extracts input data such as the measurement control word and inserts data such as the measured height as output data into the data frame. After passing through the last slave, the data frame becomes an uplink message and is returned to the master. Therefore, during a single communication cycle, the EtherCAT master can access the process data synchronously latched by all EtherCAT slaves.

[0021] See also Figure 1 , Figure 1 : is a flow chart of a communication method in one embodiment of the present application. The communication method is applied to a master station, which communicates with multiple slave stations based on the EtherCAT bus. The slave stations include IO slave stations and servo slave stations. Specifically, the communication method includes:

[0022] Step S10: Setting index information for the slave station.

[0023] Step S20: Acquire and parse the device description file of the slave station to respectively acquire the PDO information of the IO slave station and the PDO information of the servo slave station.

[0024] The slave's device description file includes information related to the slave, such as the manufacturer, product code, and PDO information. PDO information indicates the bit length, meaning, and storage location of the corresponding PDO data (e.g., control data, I / O data). Those skilled in the art understand that PDO information is also known as Process Data Object (PDO) information.

[0025] Step S30: Based on the PDO information of the IO slave station and the PDO information of the servo slave station, a first mapping relationship between the PDO data of the IO slave station and the master station data structure and a second mapping relationship between the PDO data of the servo slave station and the master station data structure are established respectively.

[0026] The first mapping relationship indicates the storage location of the PDO data in the master's memory. The master's data structure is the master's memory. Therefore, establishing the first mapping relationship between the IO slave's PDO data and the master's data structure, and the second mapping relationship between the servo slave's PDO data and the master's data structure, is equivalent to determining the storage address of the PDO data in the master's memory. When the master wishes to read or write the PDO data of a particular slave, it can directly access the corresponding address in the master's local memory to read or write the slave's PDO data. After the local read or write is complete, the slave's PDO data is loaded into the data frame. Therefore, through the first and second mapping relationships, the master can directly read and write its own memory to update the slave's port data in real time, improving the master's convenient control of the slave.

[0027] Step S40: reading and writing the IO data corresponding to the IO slave station and the control data corresponding to the servo slave station according to the first mapping relationship, the second mapping relationship, the PDO information and the index information.

[0028] The above scheme sets index information for each slave station, obtains and parses the device description file of the slave station to obtain the PDO information of the IO slave station and the PDO information of the servo slave station respectively, and establishes a first mapping relationship between the PDO of the IO slave station and the master station data structure, and a second mapping relationship between the PDO of the servo slave station and the master station data structure respectively based on the PDO information of the IO slave station and the PDO information of the servo slave station. Then, according to the first mapping relationship and the second mapping relationship, the storage locations of the PDO of the IO slave station and the PDO of the servo slave station on the master station memory can be obtained respectively, so that the master station can respectively map the IO slave station and the servo slave station. The PDO of the station is read and written; on the basis of the first mapping relationship and the second mapping relationship, combined with the index information and PDO information, the position of the read and write commands of each slave station on the data frame can be determined according to the index information, and the position of the PDO in the data frame can be obtained according to the PDO information. Therefore, after reading and writing the PDOs of the IO slave station and the servo slave station respectively according to the first mapping relationship and the second mapping relationship, the PDO of each slave station can be loaded into the corresponding position of the data frame according to the PDO information. After the slave station receives these data frames, it can control different types of slave stations, thereby realizing the mixed connection of multiple types of slave stations.

[0029] The multiple slaves that communicate with the master over the EtherCAT bus can include different types of slaves, such as I / O slaves and servo slaves. I / O slaves are used for data reading and writing, while servo slaves are typically used for motion control, such as controlling the motion of each axis of a six-axis robot.

[0030] In some embodiments, setting index information for the slave station includes:

[0031] Step S110: Establish a third mapping relationship between the natural serial number of the slave station and the physical location of the slave station.

[0032] Please refer to Figure 2 , Figure 2 This is a schematic diagram of the connection between the master station and the slave station in one embodiment of the present application. Figure 2As shown, a master station and multiple slave stations can be connected via the EtherCAT bus to form a multi-device control system. The master station automatically assigns a natural sequence number to each slave station, but the natural sequence number of a slave station may not correspond to its physical location. In a multi-device control system, different slave stations are connected to the master station in a specific physical connection sequence. This physical connection sequence can be understood as the order in which each slave station is connected to the master station on the bus. Physical positions are then assigned to each slave station based on this physical connection sequence. For example, slave station 1 has physical position 1, slave station 2 has physical position 2, and so on. Each slave station has a unique physical position. The master station can identify a slave station by its physical position. After establishing a third mapping relationship between natural sequence numbers and slave station physical positions, the master station can use this third mapping relationship to determine the physical position of each slave station based on its natural sequence number, and thus determine the position of read and write commands to each slave station in the data frame.

[0033] In some embodiments, the communication method further includes: searching for the physical location of the slave station according to the natural serial number of the slave station and the third mapping relationship; writing the slave station read and write instructions to the corresponding position of the EtherCAT data frame based on the physical location of the slave station; wherein the slave station read and write instructions include read and write instructions for the IO slave station and read and write instructions for the servo slave station.

[0034] As before, when the user controls the slave station or reads the slave station data through the master station, it is usually achieved by writing corresponding instructions at the position corresponding to the slave station at each physical position in the data frame, such as inputting "read ambient temperature data", "first axis upward movement", etc. After determining the third mapping relationship between the natural serial number and the physical position of the slave station, the read and write instructions for each slave station can be written to the corresponding position of the data frame according to the third mapping relationship. When the slave station receives the data frame, it reads the instruction at the corresponding position on the data frame and responds to the instruction, thereby realizing the control of the slave station by the master station.

[0035] In some embodiments, establishing a third mapping relationship between the natural sequence number of the slave station and the physical location of the slave station includes:

[0036] Step S111: Obtain the physical position of the slave station on the EtherCAT bus, and set the physical position of the slave station in the master station data structure.

[0037] Step S112: Based on the physical location of the slave station, a third mapping relationship between the natural serial number of the slave station and the physical location of the slave station is established.

[0038] The physical location of the slave station can be obtained from the bus, and the physical location of the slave station is stored in the master station memory, and a third mapping relationship between the natural serial number of the slave station and the physical location of the slave station is established.

[0039] In some embodiments, the communication method further comprises:

[0040] Step S50: establishing a fourth mapping relationship between the physical location of the slave station and the PDO information of the slave station.

[0041] When a master is connected to multiple slaves, each slave has its own PDO information, making it impossible for the master to determine the correspondence between each slave and the PDO information from the numerous PDOs. In this embodiment, by establishing a fourth mapping relationship between the physical location of a slave and its PDO information, the master can determine the ownership of each PDO information based on the physical location of the slave and subsequently read and write PDO data based on the PDO information and the corresponding physical location of the slave.

[0042] In some embodiments, establishing a fourth mapping relationship between the physical location of the slave station and the PDO information of the slave station includes:

[0043] Step S510: Acquire a device description file of a slave station and a physical location of the slave station corresponding to the device description file.

[0044] Step S520: Parse the device description file to obtain PDO information of the slave station corresponding to the device description file.

[0045] Step S530: establishing a fourth mapping relationship between the physical location of the slave station and the PDO information of the slave station.

[0046] The device description file of the slave station may include relevant information such as the slave station's manufacturer, product code, PDO information, etc. In some embodiments, after the physical location of the slave station is set in the master station data structure, the physical location of the slave station corresponding to the device description file can be obtained from the master station data structure.

[0047] In this embodiment, by establishing a fourth mapping relationship between the physical location of the slave station and the PDO information of the slave station, the master station can determine the ownership of each PDO information according to the physical location of the slave station, and subsequently read and write the PDO data based on the PDO information and the corresponding physical location of the slave station.

[0048] In some embodiments, the communication method further comprises:

[0049] Step S610: Scan the device description file of the slave station to obtain the device description information of the slave station.

[0050] Step S620: In response to the device description information of the slave being incomplete, determining whether the master has imported the device description file of the slave.

[0051] Step S630: In response to the master station importing the device description file of the slave station, the slave station device description file imported into the master station is parsed to obtain device description information of the slave station.

[0052] In other embodiments, the device description file of the slave station imported locally by the master station can also be parsed to obtain the device description information of the slave station. When the device description information obtained based on the device description file of the slave station imported locally by the master station is incomplete, the slave station is scanned again to obtain the device description file of the slave station.

[0053] The master station can scan the slave station to obtain the device description file. After scanning and obtaining the device description file, the device description information of the slave station (such as the manufacturer of the slave station device, etc.) can be obtained. After obtaining the device description information, it can be determined whether the device description information of each slave station is complete. For example, some slave stations only have the device manufacturer but no PDO information, and the device description information of the slave station is incomplete. If it is determined that the device description information of a certain slave station is incomplete, check whether the master station has locally imported the device description file of the slave station, such as the slave station XML configuration information. If the master station has locally imported the device description file of the slave station, the slave station device description file imported into the master station is parsed to obtain the device description information of the slave station. Therefore, in the above embodiment, the device description file obtained by scanning the slave station and the device description file imported locally by the master station can be redundant with each other. When the device description file scanning of the slave station fails, the device description file of the slave station can also be obtained locally, which improves the strategy of the master station to obtain the slave station configuration, thereby improving the stability of communication between the master station and the slave station.

[0054] In some embodiments, based on the PDO information of the IO slave station and the PDO information of the servo slave station, establishing a first mapping relationship between the PDO data of the IO slave station and the master station data structure and a second mapping relationship between the PDO data of the servo slave station and the master station data structure respectively includes:

[0055] Step S310: parse each PDO element in the PDO information of the IO slave station and the servo slave station respectively.

[0056] Step S320: Based on the parsing result of the PDO element, respectively obtain the PDO memory information of the IO slave station and the PDO memory information of the servo slave station; the PDO memory information is used to indicate the storage address of the PDO data in the master station memory.

[0057] Step S330: Based on the PDO memory information of the IO slave station, a first mapping relationship between the PDO data of the IO slave station and the master station data structure is established, and based on the PDO memory information of the servo slave station, a second mapping relationship between the PDO data of the servo slave station and the master station data structure is established.

[0058] Therefore, establishing a first mapping relationship between the PDO data of the IO slave and the master's data structure, and a second mapping relationship between the PDO data of the servo slave and the master's data structure, is equivalent to determining the storage address of the PDO data in the master's memory. When the master wishes to read or write the PDO data of a slave, it can directly access the corresponding address in the master's local memory to achieve the reading and writing of the slave's PDO data. After the local reading and writing is completed, the slave's PDO data is loaded into the data frame. Therefore, through the first and second mapping relationships, the master can directly read and write its own memory to update the slave's port data in real time, improving the convenience of the master's control over the slave.

[0059] In some embodiments, based on the parsing result of the PDO element, respectively obtaining the PDO memory information of the IO slave station and the PDO memory information of the servo slave station includes:

[0060] Step S321: Obtain the bit length and meaning corresponding to the control data from each PDO element of the servo slave station, and obtain the offset of each PDO element of the servo slave station in the PDO memory area to obtain the PDO memory information of the servo slave station.

[0061] Step S322: Obtain the bit length and meaning corresponding to the IO data from each PDO element of the IO slave station, and obtain the memory area length of the sending PDO and the receiving PDO, and the memory address of the first PDO element to obtain the PDO memory information of the IO slave station.

[0062] In some embodiments, the communication method further comprises:

[0063] Step S71: Determine the memory area of the PDO data of the IO slave in the master station according to the memory address of the first PDO element and the length of the memory area of the sending PDO and the receiving PDO.

[0064] Step S72: Map the PDO data of the IO slave station in the memory area of the master station to the user memory area.

[0065] In some embodiments, establishing a first mapping relationship between the PDO data of the IO slave station and the master station data structure based on the PDO memory information of the IO slave station, and establishing a second mapping relationship between the PDO data of the servo slave station and the master station data structure based on the PDO memory information of the servo slave station includes:

[0066] Step S331: Encapsulate the PDO memory information of the IO slave station into a structure to form a structure linked list of the IO slave station, so as to establish a first mapping relationship between the PDO data of the IO slave station and the master station data structure;

[0067] Step S332: Encapsulate the PDO memory information of the servo slave station into a structure to form a structure linked list of the servo slave station, so as to establish a second mapping relationship between the PDO data of the servo slave station and the master station data structure.

[0068] For example, after obtaining the PDO information of the slave station at each physical location, each PDO element is parsed. For servo slave stations, the bit length and meaning of the corresponding control data are obtained from each PDO element, and the offset of each element in the PDO memory area is obtained. This information is then encapsulated into a structure, and then a structure list is formed to facilitate search. For IO slave stations, the bit length and meaning of the corresponding IO data are obtained from each PDO element, and the memory area length of the entire transmit PDO (TxPDO) and receive PDO (RxPDO) and the memory address of the first PDO element are obtained. This information is then encapsulated into a structure to form a structure list for easy search.

[0069] The following is a brief description of the communication process between the master station and the slave station in this application:

[0070] For reading and writing servo slaves, the servo slaves that the user needs to read and write, as well as the specific control information of the servo slaves that need to be read and written, are first obtained. The master station finds the physical position of the corresponding servo slave based on the natural serial number of the servo slave that needs to be read and written, and the third mapping relationship between the natural serial number and the physical position of the slave, and then determines the read and write position of the specific control information in the data frame according to the physical position of the corresponding servo slave; further, the fourth mapping relationship between the physical position of the servo slave and the PDO information of the slave is used to determine the PDO information corresponding to the slave; after determining the PDO information of the servo slave, the storage position of the PDO data of the slave in the master memory is determined based on the second mapping relationship between the PDO information of the servo slave and the master data structure, and then the PDO data corresponding to the servo slave can be read and written in the master memory according to the second mapping relationship; in addition, the PDO information corresponding to the servo slave is parsed to obtain the read and write position of the PDO data corresponding to the servo slave in the Ethercat data frame. Therefore, after reading and writing the PDO data in the master station memory according to the second mapping relationship, the PDO data can be loaded into the corresponding position of the Ethercat data frame according to the PDO information; and the Ethercat data frame is sent to the servo slave station to realize the control of the servo slave station.

[0071] For the IO slave station, the IO slave station that the user needs to read and write, as well as the specific control information of the IO slave station that needs to be read and written are first obtained. The master station finds the physical position of the corresponding IO slave station based on the natural serial number of the IO slave station that needs to be read and written, and the third mapping relationship between the natural serial number and the physical position of the slave station, and then determines the read and write position of the specific control information in the data frame according to the physical position of the corresponding IO slave station; further, the fourth mapping relationship between the physical position of the IO slave station and the PDO information of the slave station is used to determine the PDO information corresponding to the slave station; after determining the PDO information of the IO slave station, the storage position of the PDO data of the slave station in the master station memory is determined based on the first mapping relationship between the PDO information of the IO slave station and the master station data structure, and then the PDO data corresponding to the IO slave station can be read and written in the master station memory according to the first mapping relationship; in addition, the PDO information corresponding to the IO slave station is parsed to obtain the read and write position of the PDO data corresponding to the IO slave station in the Ethercat data frame. Therefore, after reading and writing the PDO data in the master memory according to the first mapping relationship, the PDO data can be loaded into the corresponding position of the Ethercat data frame according to the PDO information; the Ethercat data frame is sent to the IO slave station to realize data writing to the IO slave station.

[0072] Specifically, for the IO slave station, first input the IO slave station that the user needs to read and write, as well as the data to be updated of the IO port of the IO slave station, and then find the physical location, PDO information, control information bit length and data to be written corresponding to the IO slave station according to the first mapping relationship and the third mapping relationship. By parsing the PDO information, the bit length and meaning of the control data corresponding to each element in the PDO information, the memory area length of the entire RxPDO and TxPDO, and the memory address of the first element in the PDO information of the IO slave station can be obtained. According to the obtained PDO memory first address and IO memory length, the IO memory of the master station is mapped to the user memory area. The user thread and the master station thread synchronize the reading and writing of the IO memory data through semaphores; specifically, the user thread and the master station thread can set a binary semaphore S and open up an IO memory that can be accessed by both threads. When the master station completes reading and writing the IO data of the slave station, it first locks it, synchronizes the entire IO data to the above-mentioned IO memory, performs a V operation on the semaphore S, and then unlocks it. After the user thread is awakened, it first locks the IO memory, reads and writes it, then unlocks it and performs a P operation on the semaphore S, continuing to sleep. In the next communication cycle, the master thread synchronizes the IO memory data to the slave via the IO bus and performs a V operation to wake up the user thread again.

[0073] Through the above solution, users can perform periodic reading and writing, thereby realizing periodic control of each digital IO port and analog IO port of the IO slave station.

[0074] See also Figure 3 , Figure 3 1 is a schematic diagram of a framework of an embodiment of an electronic device of the present application. The electronic device 30 includes a memory 31 and a processor 32 coupled to each other. The processor 32 is configured to execute program instructions stored in the memory 31 to implement the steps of any of the aforementioned communication method embodiments. In a specific implementation scenario, the electronic device 30 may include, but is not limited to, a microcomputer and a server. Furthermore, the electronic device 30 may also include a mobile device such as a laptop computer or a tablet computer, without limitation herein.

[0075] Specifically, the processor 32 is used to control itself and the memory 31 to implement the steps of the training method embodiment of any of the above-mentioned image detection models, or to implement the steps in the above-mentioned image detection method embodiment. The processor 32 can also be referred to as a CPU (Central Processing Unit). The processor 32 may be an integrated circuit chip with signal processing capabilities. The processor 32 can also be a general-purpose processor, 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. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 32 can be implemented by an integrated circuit chip.

[0076] The above scheme sets index information for each slave station, obtains and parses the device description file of the slave station to respectively obtain the PDO information of the IO slave station and the PDO information of the servo slave station, and based on the PDO information of the IO slave station and the PDO information of the servo slave station, respectively establishes a first mapping relationship between the PDO data of the IO slave station and the data structure of the master station, and a second mapping relationship between the PDO data of the servo slave station and the data structure of the master station, and then according to the first mapping relationship and the second mapping relationship, the storage location of the PDO data of the IO slave station and the PDO data of the servo slave station in the memory of the master station can be obtained respectively, so that the master station can respectively map the IO slave station and the PDO data of the servo slave station. The PDO data of the servo slave station is read and written; on the basis of the first mapping relationship and the second mapping relationship, combined with the index information and PDO information, the position of the read and write commands of each slave station on the data frame can be determined according to the index information, and the position of the PDO in the data frame can be obtained according to the PDO information. Therefore, after reading and writing the PDOs of the IO slave station and the servo slave station respectively according to the first mapping relationship and the second mapping relationship, the PDO of each slave station can be loaded into the corresponding position of the data frame according to the PDO information. After the slave station receives these data frames, it can control different types of slave stations, thereby realizing the mixed connection of multiple types of slave stations.

[0077] See also Figure 4 , Figure 4 This is a schematic diagram of a framework of an embodiment of a computer-readable storage medium 40 of the present application. The computer-readable storage medium 40 stores program instructions 401 that can be executed by a processor, and the program instructions 401 are used to implement the steps in any of the above-mentioned communication method embodiments.

[0078] The above scheme sets index information for each slave station, obtains and parses the device description file of the slave station to respectively obtain the PDO information of the IO slave station and the PDO information of the servo slave station, and based on the PDO information of the IO slave station and the PDO information of the servo slave station, respectively establishes a first mapping relationship between the PDO data of the IO slave station and the data structure of the master station, and a second mapping relationship between the PDO data of the servo slave station and the data structure of the master station, and then according to the first mapping relationship and the second mapping relationship, the storage location of the PDO data of the IO slave station and the PDO data of the servo slave station in the memory of the master station can be obtained respectively, so that the master station can respectively map the IO slave station and the PDO data of the servo slave station. The PDO data of the servo slave station is read and written; on the basis of the first mapping relationship and the second mapping relationship, combined with the index information and PDO information, the position of the read and write commands of each slave station on the data frame can be determined according to the index information, and the position of the PDO in the data frame can be obtained according to the PDO information. Therefore, after reading and writing the PDOs of the IO slave station and the servo slave station respectively according to the first mapping relationship and the second mapping relationship, the PDO of each slave station can be loaded into the corresponding position of the data frame according to the PDO information. After the slave station receives these data frames, it can control different types of slave stations, thereby realizing the mixed connection of multiple types of slave stations.

[0079] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.

[0080] The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced with each other and will not be repeated herein for the sake of brevity.

[0081] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation methods described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0082] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0083] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it 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 all or 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 a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: various media that can store program codes, such as 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.

[0084] If the technical solution of this application involves personal information, the product that applies the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing personal information. If the technical solution of this application involves sensitive personal information, the product that applies the technical solution of this application has obtained the individual's separate consent before processing sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, a clear and prominent sign is set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that they agree to the collection of their personal information; or on the personal information processing device, when the personal information processing rules are notified by obvious signs / information, the individual's authorization is obtained through pop-up information or by asking the individual to upload their personal information; among which, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

Claims

1. A communication method, characterized in that: The method is applied to a master station, which communicates with multiple slave stations based on an EtherCAT bus, wherein the slave stations include IO slave stations and servo slave stations. The method includes: Setting index information for the slave station; Obtaining and parsing the device description file of the slave station to respectively obtain the PDO information of the IO slave station and the PDO information of the servo slave station; Based on the PDO information of the IO slave station and the PDO information of the servo slave station, a first mapping relationship between the PDO data of the IO slave station and the master station data structure and a second mapping relationship between the PDO data of the servo slave station and the master station data structure are established respectively; wherein the first mapping relationship is used to indicate the storage location of the PDO data in the master station memory; The IO data corresponding to the IO slave station and the control data corresponding to the servo slave station are read and written according to the first mapping relationship, the second mapping relationship, the PDO information and the index information.

2. The communication method according to claim 1, wherein: The setting of index information for the slave station includes: Establishing a third mapping relationship between the natural serial number of the slave station and the physical location of the slave station; The method further comprises: Finding the physical location of the slave station according to the natural sequence number of the slave station and the third mapping relationship; Based on the physical position of the slave station, the slave station read and write instructions are written to the corresponding position of the EtherCAT data frame; wherein the slave station read and write instructions include read and write instructions for the IO slave station and read and write instructions for the servo slave station.

3. The communication method according to claim 2, wherein: The establishing of a third mapping relationship between the natural sequence number of the slave station and the physical location of the slave station includes: Obtaining the physical location of the slave station on the EtherCAT bus, and setting the physical location of the slave station in the master station data structure; Based on the physical location of the slave station, a third mapping relationship between the natural serial number of the slave station and the physical location of the slave station is established.

4. The communication method according to claim 2, wherein: Also includes: A fourth mapping relationship between the physical location of the slave station and the PDO information of the slave station is established.

5. The communication method according to claim 4, wherein: The establishing of a fourth mapping relationship between the physical location of the slave station and the PDO information of the slave station includes: Obtaining a device description file of the slave station and a physical location of the slave station corresponding to the device description file; Parsing the device description file to obtain PDO information of the slave station corresponding to the device description file; A fourth mapping relationship between the physical location of the slave station and the PDO information of the slave station is established. The communication method according to claim 1 , wherein: Also includes: Scan the device description file of the slave station to obtain the device description information of the slave station; In response to the device description information of the slave being incomplete, determining whether the master has imported the device description file of the slave; In response to the master station importing the device description file of the slave station, the slave station device description file imported into the master station is parsed to obtain device description information of the slave station.

7. The communication method according to claim 1, wherein: The establishing of a first mapping relationship between the PDO data of the IO slave station and the master station data structure and a second mapping relationship between the PDO data of the servo slave station and the master station data structure based on the PDO information of the IO slave station and the PDO information of the servo slave station respectively includes: Parsing each PDO element in the PDO information of the IO slave station and the servo slave station respectively; Based on the parsing result of the PDO element, respectively obtaining the PDO memory information of the IO slave station and the PDO memory information of the servo slave station; the PDO memory information is used to indicate the storage address of the PDO data in the master station memory; Based on the PDO memory information of the IO slave station, a first mapping relationship between the PDO data of the IO slave station and the master station data structure is established, and based on the PDO memory information of the servo slave station, a second mapping relationship between the PDO data of the servo slave station and the master station data structure is established.

8. The communication method according to claim 7, wherein: The acquiring of the PDO memory information of the IO slave station and the PDO memory information of the servo slave station based on the parsing result of the PDO element includes: Obtaining the bit length and meaning corresponding to the control data from each PDO element of the servo slave station, and obtaining the offset of each PDO element of the servo slave station in the PDO memory area to obtain the PDO memory information of the servo slave station; Obtain the bit length and meaning corresponding to the IO data from each PDO element of the IO slave station, and obtain the memory area length of the sending PDO and the receiving PDO, and the memory address of the first PDO element to obtain the PDO memory information of the IO slave station.

9. The communication method according to claim 8, wherein: The method further comprises: Determine the memory area of the PDO data of the IO slave station in the master station according to the memory address of the first PDO element, the length of the memory area of the sending PDO and the receiving PDO; Map the PDO data of the IO slave station in the memory area of the master station to the user memory area.

10. The communication method according to claim 7, wherein: The step of establishing a first mapping relationship between the PDO data of the IO slave station and the master station data structure based on the PDO memory information of the IO slave station, and establishing a second mapping relationship between the PDO data of the servo slave station and the master station data structure based on the PDO memory information of the servo slave station comprises: Encapsulating the PDO memory information of the IO slave station into a structure to form a structure linked list of the IO slave station, so as to establish a first mapping relationship between the PDO data of the IO slave station and the master station data structure; The PDO memory information of the servo slave station is encapsulated into a structure to form a structure linked list of the servo slave station, so as to establish a second mapping relationship between the PDO data of the servo slave station and the master station data structure.

11. An electronic device, characterized in that: The invention comprises a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement the communication method according to any one of claims 1 to 10.

12. A computer-readable storage medium, characterized in that Program instructions are stored thereon, and when the program instructions are executed by a processor, the communication method according to any one of claims 1 to 10 is implemented.