Industrial control data synchronization method and device and dual-port random access memory
By adding dual-port RAM between the EtherCAT module and the PLC module, the problem of large delay in data synchronization between EtherCAT and PLC in industrial control and high resource occupancy is solved, and efficient data synchronization and low resource occupancy are achieved.
Patent Information
- Application Number
- CN202411957151.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-29
- Publication Date
- 2025-04-25
AI Technical Summary
In the prior art, the data synchronization between EtherCAT and PLC is delayed and the resource occupancy rate is high.
By adding dual-port RAM between the EtherCAT module and the PLC module, the EtherCAT module determines the periodic data packet at the beginning of the bus cycle and writes it to the dual-port RAM. Then, an interrupt message is generated and sent to the PLC module. The PLC module reads the periodic data packet from the dual-port RAM and generates output data, writes it to the dual-port RAM, and the EtherCAT module obtains output data from the dual-port RAM.
It realizes the use of the bus cycle of the EtherCAT module to transmit data between the EtherCAT module and the PLC module, without performing additional data synchronization operations, high data synchronization efficiency and low resource occupancy.
Smart Images

Figure CN119882582A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of industrial control technology, and in particular to an industrial control data synchronization method, device and dual-port random access memory. Background Art
[0002] With the rapid development of science and technology, smart manufacturing and industrial control are facing new development trends and challenges. Industrial control systems will achieve a higher degree of automation and intelligence, pushing smart manufacturing to a higher level. Therefore, faster and more accurate industrial control has also emerged. PLC (Programmable Logic Controller) and EtherCAT (Ethernet Control Automation Technology) each play an important role in the field of industrial automation. The high integration of the two can achieve precise control of industrial processes and improve production efficiency, product quality and safety.
[0003] In the related art, data synchronization between PLC and EtherCAT is usually achieved by data query or rising edge query, which has high resource occupancy and large latency. Summary of the invention
[0004] In view of this, the embodiments of the present application provide an industrial control data synchronization method, device and dual-port random access memory to solve the problems of large data synchronization delay and high resource utilization between EtherCAT and PLC in industrial control in the prior art.
[0005] In a first aspect of an embodiment of the present application, there is provided an industrial control data synchronization method, which is used to realize data synchronization between an Ethernet control automation EtherCAT module and a programmable logic controller PLC module, comprising:
[0006] Step S101, in response to receiving a bus cycle start signal, the EtherCAT module determines a periodic data packet;
[0007] Step S102, the EtherCAT module writes the periodic data packet into the dual-port random access memory RAM;
[0008] Step S103: The EtherCAT module generates a data update interrupt message, and sends the data update interrupt message to the PLC module;
[0009] Step S104, in response to receiving the data update interrupt message, the PLC module reads the periodic data packet from the dual-port RAM, generates output data based on the periodic data packet, and writes the output data into the dual-port RAM;
[0010] Step S105: The EtherCAT module obtains output data from the dual-port RAM.
[0011] In some embodiments, the EtherCAT module determines a periodic data packet, including:
[0012] Step S1011, the EtherCAT module obtains the output data of the previous bus cycle from the dual-port RAM;
[0013] Step S1012: The EtherCAT module determines a periodic data packet of the current bus cycle based at least on the output data of the previous bus cycle.
[0014] In some embodiments, step S102 includes:
[0015] Step S1021, the EtherCAT module obtains input data authority from the dual-port RAM;
[0016] Step S1022, in response to determining that the EtherCAT module writes the periodic data packet into the dual-port RAM, the dual-port RAM sets the input data update flag bit;
[0017] Step S1023: The EtherCAT module releases the input data permission of the dual-port RAM.
[0018] In some embodiments, step S104 includes:
[0019] Step S1041, in response to receiving the data update interrupt message, the PLC module obtains input data authority from the dual-port RAM;
[0020] Step S1042, in response to determining that the input data update flag of the dual-port RAM is set, the PLC module obtains a periodic data packet from the dual-port RAM, resets the input data update flag and releases the input data permission of the dual-port RAM;
[0021] Step S1043: The PLC module generates output data based on the periodic data packet and releases the input data permission of the dual-port RAM;
[0022] Step S1044, the PLC module obtains the output data authority from the dual-port RAM, and writes the output data into the dual-port RAM;
[0023] Step S1045, in response to determining that the PLC module writes the output data packet into the dual-port RAM, the dual-port RAM sets the output data update flag bit;
[0024] Step S1046: The PLC module releases the output data permission of the dual-port RAM.
[0025] In some embodiments, step 105 includes:
[0026] Step S1051, after sending the data update interrupt message, the EtherCAT module periodically queries the output data update flag of the dual-port RAM;
[0027] Step S1052: in response to determining that the output data update flag of the dual-port RAM is set, the EtherCAT module obtains output data authority from the dual-port RAM;
[0028] Step S1053: The EtherCAT module resets the output data update flag and releases the output data permission of the dual-port RAM.
[0029] A second aspect of an embodiment of the present application provides an industrial control data synchronization method, which is used to achieve data synchronization between an Ethernet control automation EtherCAT module and a programmable logic controller PLC module, including:
[0030] Step S201, in response to receiving an instruction to send non-periodic data, the PLC module writes target non-periodic data into a non-periodic data storage space;
[0031] Step S202, the EtherCAT module obtains target non-periodic data from the non-periodic data storage space;
[0032] Step S203, the EtherCAT module writes the reply data of the target non-periodic data into the non-periodic data storage space;
[0033] Step S204: The PLC module obtains reply data of the target non-periodic data from the non-periodic data storage space.
[0034] In some embodiments, step S201 includes:
[0035] In response to receiving the instruction to send non-periodic data, the PLC module obtains the read and write permissions of the non-periodic data storage space from the dual-port random access memory RAM;
[0036] The PLC module writes the target non-periodic data into the non-periodic data storage space;
[0037] The PLC module sets the status flag of the non-periodic data storage space and releases the read and write permissions of the non-periodic data storage space;
[0038] Step S202 includes:
[0039] In response to the query determining that the status flag of the non-periodic data storage space in the dual-port RAM is set, the EtherCAT module obtains read and write permissions for the non-periodic data storage space from the dual-port RAM;
[0040] The EtherCAT module reads the target acyclic data, writes the reply data of the target acyclic data into the acyclic data storage space, and releases the read and write permissions of the acyclic data storage space;
[0041] Step S204 includes:
[0042] The PLC module obtains the read and write permissions of the non-periodic data storage space from the dual-port RAM, and obtains the reply data of the target non-periodic data;
[0043] The PLC module resets the status flag of the non-periodic data storage space and releases the read and write permissions of the non-periodic data storage space.
[0044] According to a third aspect of an embodiment of the present application, there is provided an industrial control data synchronization device, including:
[0045] The determination module is configured to determine the periodic data packet by the Ethernet control automation EtherCAT module under the condition of receiving the bus cycle start signal;
[0046] A writing module is configured to write the periodic data packet into the dual-port random access memory RAM by the EtherCAT module;
[0047] An interrupt module is configured to generate a data update interrupt message from the EtherCAT module and send the data update interrupt message to a programmable logic controller (PLC) module;
[0048] a reading module configured to, in response to receiving a data update interrupt message, read a periodic data packet from the dual-port RAM by the PLC module, generate output data based on the periodic data packet, and write the output data into the dual-port RAM;
[0049] The acquisition module is configured to acquire output data from the dual-port RAM by the EtherCAT module.
[0050] According to a fourth aspect of the embodiments of the present application, an industrial control data synchronization device is provided, including:
[0051] A writing module is configured to write the target non-periodic data into the non-periodic data storage space by the PLC module in response to receiving the non-periodic data sending indication;
[0052] The acquisition module is configured to acquire target non-periodic data from the non-periodic data storage space by the Ethernet control automation EtherCAT module;
[0053] The writing module is also configured to write reply data of the target acyclic data in the acyclic data storage space by the EtherCAT module;
[0054] The acquisition module is further configured to acquire, by the PLC module, reply data of the target non-periodic data from the non-periodic data storage space.
[0055] In a fifth aspect of the embodiments of the present application, a dual-port random access memory RAM is provided, the dual-port RAM is used to implement the method as described in any one of the first to second aspects above, characterized in that the dual-port RAM includes at least a handshake channel, the handshake channel includes at least a handshake register, and the handshake register is used to manage the state information when the Ethernet control automation EtherCAT module and the programmable logic controller PLC module interact with the dual-port RAM;
[0056] The status information includes at least one of the following:
[0057] Data read and write permission information, and data storage space status information.
[0058] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application add a dual-port RAM between the EtherCAT module and the PLC module, the EtherCAT module determines a periodic data packet at the beginning of a bus cycle, and sends the periodic data packet to the dual-port RAM, then the EtherCAT module generates and sends an interrupt message to the PLC module, after receiving the interrupt message, the PLC module obtains the periodic data packet from the dual-port RAM, generates output data based on the periodic data packet, and writes the output data to the dual-port RAM, the EtherCAT module obtains the output data written by the PLC module from the dual-port RAM, thereby realizing the use of the bus cycle of the EtherCAT module to transmit data between the EtherCAT module and the PLC module, without performing additional data synchronization operations, and the data synchronization efficiency is high and the resource occupancy rate is small. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0060] Figure 1 It is a flowchart of an industrial control data synchronization method provided in an embodiment of the present application.
[0061] Figure 2 It is a flowchart of a method for determining a periodic data packet by an EtherCAT module provided in an embodiment of the present application.
[0062] Figure 3It is a flowchart of a method for an EtherCAT module to write a periodic data packet into a dual-port RAM provided in an embodiment of the present application.
[0063] Figure 4 It is a flow chart of a method for a PLC module to read periodic data packets and generate output data provided in an embodiment of the present application.
[0064] Figure 5 It is a flowchart of a method for an EtherCAT module to obtain output data from a dual-port RAM provided in an embodiment of the present application.
[0065] Figure 6 It is a system architecture diagram for implementing the industrial control data synchronization method provided in the embodiment of the present application.
[0066] Figure 7 This is another industrial control data synchronization method provided in an embodiment of the present application.
[0067] Figure 8 This is another industrial control data synchronization method provided in an embodiment of the present application.
[0068] Fig. 9 This is another industrial control data synchronization method provided in an embodiment of the present application.
[0069] Fig.10 A dual-port random access memory RAM is provided in an embodiment of the present application.
[0070] Fig.11 It is a schematic diagram of an industrial control data synchronization device provided in an embodiment of the present application.
[0071] Fig.12 It is a schematic diagram of another industrial control data synchronization device provided in an embodiment of the present application.
[0072] Fig.13 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0073] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0074] An industrial control data synchronization method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0075] As mentioned above, in the related art, data synchronization between PLC and EtherCAT is usually achieved by means of data query or rising edge query.
[0076] Data query means that the PLC can query the input data in the data storage unit in real time and compare it with the data stored in itself. If there is a difference in the data comparison, it is determined that the data has been updated. At this time, the PLC can run the algorithm task and update the calculation result data to EtherCAT after the operation is completed. This method requires the PLC to query the input data in the data storage unit in real time and quickly. When the bus cycle of EtherCAT is small, the amount of input data written to the data storage unit is large. The PLC needs to query at a high frequency, and its resource utilization rate will increase significantly.
[0077] On the other hand, rising edge query means that the PLC can query the input data update flag in the data storage unit in real time. If the update flag is a rising edge, the data has been updated. At this time, the PLC can run the algorithm task and update the calculation result data to EtherCAT after the operation is completed. This method requires the PLC controller to quickly query the input data update flag in the data storage unit in real time. Although it will not increase the resource occupancy rate of the PLC as the amount of input data increases, the software query mode has a delay in principle, so the data synchronization effect may not be good.
[0078] In view of this, a dual-port RAM is added between the EtherCAT module and the PLC module. The EtherCAT module determines the periodic data packet at the beginning of the bus cycle and sends the periodic data packet to the dual-port RAM. Then the EtherCAT module generates and sends an interrupt message to the PLC module. After receiving the interrupt message, the PLC module obtains the periodic data packet from the dual-port RAM, generates output data based on the periodic data packet, and writes the output data into the dual-port RAM. The EtherCAT module obtains the output data written by the PLC module from the dual-port RAM, thereby realizing the transmission of data between the EtherCAT module and the PLC module by utilizing the bus cycle of the EtherCAT module, without performing additional data synchronization operations, and having high data synchronization efficiency and low resource occupancy.
[0079] Figure 1 Schematic diagram of a process flow of an industrial control data synchronization method provided by an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0080] In step S101 , in response to receiving a bus cycle start signal, the EtherCAT module determines a periodic data packet.
[0081] In step S102, the EtherCAT module writes the periodic data packet into the dual-port random access memory RAM.
[0082] In step S103, the EtherCAT module generates a data update interrupt message, and sends the data update interrupt message to the PLC module.
[0083] In step S104 , in response to receiving the data update interrupt message, the PLC module reads the periodic data packet from the dual-port RAM, generates output data based on the periodic data packet, and writes the output data into the dual-port RAM.
[0084] In step S105 , the EtherCAT module obtains output data from the dual-port RAM.
[0085] In certain embodiments of the present application, the method can be used to achieve data synchronization between an EtherCAT module and a PLC module.
[0086] In some embodiments, the EtherCAT module may determine a periodic data packet upon receiving a bus cycle start signal, wherein the periodic data packet is obtained by the EtherCAT module according to the data packet that needs to be sent to the PLC in this bus cycle.
[0087] After determining the periodic data packet, the EtherCAT module may write the periodic data packet into the dual-port RAM, wherein the dual-port RAM may include an input data space and an output data space, and the EtherCAT module may write the periodic data packet into the input data space of the dual-port RAM.
[0088] After writing the periodic data packet into the dual-port RAM, the EtherCAT module can generate a data update interrupt message and send the data update interrupt message to the PLC module. In one example, the EtherCAT module can send an interrupt message to the PLC module through the GPIO (General Purpose Input Output) module in the dual-port RAM, thereby realizing a hardware interrupt and avoiding the delay caused by software query.
[0089] After receiving the data update interrupt message, the PLC module can read the periodic data packet from the input data space of the dual-port RAM, and use the periodic data packet to perform calculation tasks and generate output data. The PLC module can also write the generated output data into the output data space of the dual-port RAM.
[0090] After the PLC writes the output data into the dual-port RAM, the EtherCAT module can obtain the output data from the output data space of the dual-port RAM.
[0091] According to the technical solution provided in the embodiment of the present application, a dual-port RAM is added between the EtherCAT module and the PLC module, the EtherCAT module determines the periodic data packet at the beginning of the bus cycle, and sends the periodic data packet to the dual-port RAM, then the EtherCAT module generates and sends an interrupt message to the PLC module, after receiving the interrupt message, the PLC module obtains the periodic data packet from the dual-port RAM, generates output data based on the periodic data packet, and writes the output data to the dual-port RAM, the EtherCAT module obtains the output data written by the PLC module from the dual-port RAM, thereby realizing the use of the bus cycle of the EtherCAT module to transmit data between the EtherCAT module and the PLC module, without performing additional data synchronization operations, the data synchronization efficiency is high and the resource occupancy rate is small.
[0092] Figure 2 1 is a flow chart of a method for determining a periodic data packet by an EtherCAT module provided in an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0093] In step S1011 , the EtherCAT module obtains output data of the previous bus cycle from the dual-port RAM.
[0094] In step S1012, the EtherCAT module determines a periodic data packet of the current bus cycle based at least on the output data of the previous bus cycle.
[0095] In some embodiments of the present application, when the EtherCAT module receives the bus cycle start signal, it can first obtain the output data of the previous bus cycle from the dual-port RAM, and then determine the cycle data packet of the current bus cycle based on the output data of the previous bus cycle. In this way, when the EtherCAT module assembles the bus cycle data packet, it can realize data synchronization with the PLC module by reading the output data space of the previous cycle from the output data space of the dual-port RAM, without the need to perform additional data query synchronization operations, thereby improving data synchronization efficiency and reducing resource utilization.
[0096] Figure 3 1 is a flow chart of a method for writing a periodic data packet into a dual-port RAM by an EtherCAT module provided in an embodiment of the present application. Figure 3 As shown, the method comprises the following steps:
[0097] In step S1021, the EtherCAT module obtains input data authority from the dual-port RAM.
[0098] In step S1022 , in response to determining that the EtherCAT module writes the periodic data packet into the dual-port RAM, the dual-port RAM sets the input data update flag bit.
[0099] In step S1023, the EtherCAT module releases the input data permission of the dual-port RAM.
[0100] In some embodiments, when the EtherCAT module writes a periodic data packet into the dual-port RAM, it may first obtain the input data permission from the dual-port RAM, then write the periodic data packet into the dual-port RAM, and set the input data update flag of the dual-port RAM, for example, to 1. After executing the data writing operation and the input data update flag setting operation, the EtherCAT module may release the input data permission of the dual-port RAM.
[0101] In one example, the dual-port RAM may include a handshake channel, which may include a handshake register, which may store the input data permission, output data permission, input data update flag, and output data update flag of the dual-port RAM. The EtherCAT module may query the information in the handshake register, and modify the information by sending corresponding messages, such as modifying the input data permission to be occupied by the EtherCAT module, or modifying the input data permission to be released (i.e., not currently occupied), or setting the input data update flag to 1 or resetting it to 0, etc.
[0102] Figure 4 1 is a flow chart of a method for generating output data by a PLC module reading a periodic data packet provided in an embodiment of the present application. Figure 4 As shown, the method comprises the following steps:
[0103] In step S1041 , in response to receiving the data update interrupt message, the PLC module obtains input data authority from the dual-port RAM.
[0104] In step S1042, in response to determining that the input data update flag of the dual-port RAM is set, the PLC module obtains a periodic data packet from the dual-port RAM, resets the input data update flag and releases the input data permission of the dual-port RAM.
[0105] In step S1043, the PLC module generates output data based on the periodic data packet and releases the input data permission of the dual-port RAM.
[0106] In step S1044, the PLC module obtains the output data authority from the dual-port RAM and writes the output data into the dual-port RAM.
[0107] In step S1045, in response to determining that the PLC module writes the output data packet into the dual-port RAM, the dual-port RAM sets the output data update flag bit.
[0108] In step S1046, the PLC module releases the output data permission of the dual-port RAM.
[0109] In some embodiments of the present application, the PLC module reads the periodic data packet to generate output data, which may be that after receiving the data update interrupt message, the PLC module obtains the input data permission from the dual-port RAM and queries the input data update flag in the dual-port RAM. If the input data update flag is set, the periodic data packet is obtained and the input data update flag is reset.
[0110] The PLC module can use the acquired periodic data packets to perform calculation tasks and obtain output data. On the other hand, the PLC module can also release the input data permission of the dual-port RAM and obtain the output data permission of the dual-port RAM. After obtaining the output data permission, the PLC module can write the output data into the dual-port RAM and set the output data update flag of the dual-port RAM. After the setting is completed, the PLC module releases the output data permission of the dual-port RAM.
[0111] Figure 5 1 is a flow chart of a method for obtaining output data from a dual-port RAM by an EtherCAT module provided in an embodiment of the present application. Figure 5 As shown, the method comprises the following steps:
[0112] In step S1051, after sending the data update interrupt message, the EtherCAT module periodically queries the output data update flag of the dual-port RAM.
[0113] In step S1052 , in response to determining that the output data update flag of the dual-port RAM is set, the EtherCAT module obtains output data authority from the dual-port RAM.
[0114] In step S1053, the EtherCAT module obtains the output data from the dual-port RAM, resets the output data update flag and releases the output data authority of the dual-port RAM.
[0115] In some embodiments of the present application, after sending the data update interrupt message, the EtherCAT module can periodically query the output data update flag of the dual-port RAM. If the query determines that the output data update flag of the dual-port RAM is set, the EtherCAT module obtains the output data permission from the dual-port RAM.
[0116] After obtaining the output data permission, the EtherCAT module can obtain the output data written by the PLC from the output data space of the dual-port RAM. After that, the EtherCAT module can reset the output data update flag and release the output data permission of the dual-port RAM.
[0117] Figure 6 1 is a system architecture diagram for implementing the industrial control data synchronization method provided in the embodiment of the present application. Figure 6 As shown, the communication board may include the EtherCAT protocol, and the PLC controller may include motion control tasks.
[0118] When the cycle synchronization signal arrives, EtherCAT can obtain the update completion signal output in the previous cycle, that is, the output data of the previous cycle, and perform packetization and link transmission and reception of the data of this cycle, for example, sending the cycle data packet to the dual-port RAM. After sending the data packet of this cycle, EtherCAT can generate an input update completion interrupt to achieve blocking, and send the input update completion interrupt to the PLC.
[0119] After the PLC obtains the input update completion interrupt, if the query determines that the data in the I (input) area of the dual-port RAM has been updated, such as the RTS flag is set, the task processing algorithm can be called to perform input and output processing to obtain output data. The PLC can write the output data to the Q (output) area of the dual-port RAM for data output. After writing, the output data flag of the dual-port RAM can be updated, such as RTS is set, to release the output update completion signal.
[0120] After sending the input update completion interrupt, EtherCAT periodically queries the output update completion signal. When the output update completion signal is received, that is, after querying and confirming that the RTS flag bit in the Q area of the dual-port RAM is set, the output data is obtained to complete the data synchronization. After that, the above process can be repeated in each communication cycle of EtherCAT, thereby realizing data synchronization between EtherCAT and PLC.
[0121] In other words, the PLC controller and the EtherCAT communication board use input data update interrupts for synchronization. After the EtherCAT communication board completes a bus cycle of communication, an input data update interrupt is generated. After the PLC controller captures this interrupt, the motion control task that has completed the motion planning algorithm calculation is awakened to update the algorithm input and output data. After the algorithm output data is updated, the output data update completion flag in the dual-port RAM is set. The motion control task uses the latest input data to calculate the motion control algorithm. After the calculation is completed, the task enters a blocked sleep state and waits for the next EtherCAT communication board bus cycle to complete the input data update and wake up.
[0122] At the beginning of the next bus cycle, the EtherCAT communication board first obtains the output data update completion flag in the dual-port RAM. After updating the output data, it performs periodic data packetization and transmits the newly obtained output data to each output module. At the same time, it obtains the latest input data from each input module. After the bus cycle is completed, an input data update completion interrupt is generated to wake up the motion control task in the PLC controller. After the motion control task obtains the input data, it updates the calculated output data to the dual-port RAM and sets the update completion flag, and runs back and forth.
[0123] Figure 7 This is another industrial control data synchronization method provided by the embodiment of the present application. Figure 7 As shown in the figure, at the end of the EtherCAT communication board bus cycle, the PLC controller motion controller has read out the input data in the previous cycle, that is, the input data authority in the dual-port RAM has been returned to the EtherCAT communication board. After obtaining the authority, the EtherCAT communication board updates the input data, and after the update is completed, the input data authority is released to the PLC controller, and an input data update completion interrupt is generated. Then the EhterCAT communication board waits for the output data update flag in the dual-port RAM.
[0124] After the PLC controller captures the input data update interrupt and obtains the dual-port RAM input data update authority, it reads the input data in the dual-port RAM into the motion control task. At this time, the motion control task releases the dual-port RAM input data authority. After the motion controller task updates the input data, it obtains the dual-port RAM output data update authority to update the output data. After the update is completed, the dual-port RAM output data update mark and authority are released. The EtherCAT communication board that obtains the output data update mark and authority in the dual-port RAM immediately ends the wait and reads the output data in the dual-port RAM. After the reading is completed, the dual-port RAM output data update mark and authority are returned to the PLC controller. At this point, the output and input data of one cycle are updated and wait for the data update of the next cycle.
[0125] Figure 8 This is another industrial control data synchronization method provided by the embodiment of the present application. Figure 8 As shown, the method comprises the following steps:
[0126] In step S201 , in response to receiving an instruction to send non-periodic data, the PLC module writes target non-periodic data into a non-periodic data storage space.
[0127] In step S202 , the EtherCAT module obtains target non-periodic data from the non-periodic data storage space.
[0128] In step S203 , the EtherCAT module writes the reply data of the target aperiodic data into the aperiodic data storage space.
[0129] In step S204 , the PLC module obtains reply data of the target non-periodic data from the non-periodic data storage space.
[0130] In some embodiments of the present application, the method can be used to achieve data synchronization between an EtherCAT module and a PLC module.
[0131] In some embodiments, the EtherCAT module and the PLC module can also use the dual-port RAM to transmit non-periodic data. In this case, non-periodic data storage space can be set in the dual-port RAM. When performing non-periodic data transmission, it can be implemented through a master-slave mechanism, in which the PLC module is the master and can send non-periodic data, and the EtherCAT data is the slave and can only reply to the received non-periodic data.
[0132] When the PLC module receives the instruction to send aperiodic data, it can write the target aperiodic data into the aperiodic data storage space. The EtherCAT module obtains the target aperiodic data from the aperiodic data storage space and replies to the target aperiodic data. The EtherCAT module can write the reply data of the target aperiodic data into the aperiodic data storage space. The PLC module obtains the reply data of the target aperiodic data from the aperiodic data storage space, thereby realizing the aperiodic data synchronization between the EtherCAT module and the PLC module.
[0133] In some embodiments, the EtherCAT module obtains the target non-periodic data from the non-periodic data storage space. In response to receiving an indication to send non-periodic data, the PLC module obtains read and write permissions for the non-periodic data storage space from a dual-port random access memory RAM; the PLC module writes the target non-periodic data into the non-periodic data storage space; the PLC module sets a status flag of the non-periodic data storage space and releases the read and write permissions for the non-periodic data storage space.
[0134] In other embodiments, the EtherCAT module obtains the target non-periodic data from the non-periodic data storage space. In response to a query to determine that the status flag of the non-periodic data storage space in the dual-port RAM is set, the EtherCAT module obtains the read and write permissions of the non-periodic data storage space from the dual-port RAM; the EtherCAT module reads the target non-periodic data, writes reply data of the target non-periodic data in the non-periodic data storage space, and releases the read and write permissions of the non-periodic data storage space.
[0135] In some other embodiments, the PLC module obtains the reply data of the target non-periodic data from the non-periodic data storage space. The PLC module may obtain the read and write permissions of the non-periodic data storage space from the dual-port RAM, and obtain the reply data of the target non-periodic data; the PLC module resets the status flag of the non-periodic data storage space, and releases the read and write permissions of the non-periodic data storage space.
[0136] Fig. 9 This is another industrial control data synchronization method provided by the embodiment of the present application. Fig. 9 As shown in the figure, the non-periodic data interaction between the EtherCAT communication board and the PLC controller can be realized by using the mailbox master-slave mechanism on the dual-port RAM. The mailbox can be the non-periodic data storage space in the dual-port RAM. The non-periodic data synchronization can be used to realize the interaction of configuration data, IO data, diagnostic data, etc.
[0137] When using the mailbox master-slave mechanism to implement non-periodic data interaction, the PLC controller can be the Master and the EtherCAT communication board can be the Slave. Only the Master has the authority to write data to the mailbox, and the Slave can only passively reply to the mailbox data according to the Master's command. The dual-port RAM provides read and write permission bits to ensure data consistency. Both the Master and the Slave can only read and write the mailbox data if they obtain the mailbox read and write permission, so both parties must identify the authority before using the mailbox.
[0138] In one example, before the PLC controller sends a mailbox command to the EtherCAT communication board, it first obtains an idle mailbox and sets the read and write permissions. After the mailbox data is written, the mailbox is set to full and the read and write permissions are released. When the EtherCAT communication board queries the mailbox full status and sets the read and write permissions, it reads the data in the mailbox and writes the reply data. After completion, it sets the mailbox full status and releases the read and write permissions. At this time, the PLC controller obtains the mailbox full status and sets the read and write permissions, reads the mailbox reply data, sets the mailbox idle and releases the read and write permissions. At this point, a non-periodic data interaction is completed.
[0139] Fig.10 A dual-port random access memory RAM is provided in an embodiment of the present application. The dual-port RAM can be used to implement Figures 1 to 9 The method provided by any of the embodiments shown. The dual-port RAM includes at least a handshake channel, and the handshake channel includes at least a handshake register, and the handshake register is used to manage the state information when the Ethernet control automation EtherCAT module and the programmable logic controller PLC module interact with the dual-port RAM.
[0140] The status information may include at least one of the following: data read and write permission information, and data storage space status information. The data read and write permission information may include the read and write permission information of the input data area of the dual-port RAM, the read and write permission information of the output data area of the dual-port RAM, and the read and write permission information of the non-periodic data storage space of the dual-port RAM; the data storage space status information may include: the status information of the input data area of the dual-port RAM, the status information of the output data area of the dual-port RAM, and the status information of the non-periodic data storage space of the dual-port RAM.
[0141] Furthermore, the dual-port RAM also includes a system channel and a communication channel. Fig.10 As shown in the figure, the input data space, output data space and non-periodic data storage space can be managed by the communication channel, which also manages other communication-related storage spaces. The handshake channel manages the storage space related to the handshake authority and data status. The system channel manages the storage space related to system operation.
[0142] The spatial allocation of each channel is shown in Table 1.
[0143] Table 1 Space allocation of each channel in dual-port RAM
[0144]
[0145]
[0146] By adopting the technical solution of the embodiment of the present application, an interrupt signal is provided through the hardware GPIO in the dual-port RAM, and an interrupt is generated in the GPIO before the EtherCAT board communication starts. After the PLC obtains the interrupt, the latest input data is obtained through the dual-port RAM and the motion controller algorithm calculation is performed. After the calculation is completed, the latest calculated output data is written to the EtherCAT board through the dual-port RAM. The EtherCAT board transmits the latest motion control data to each motion control unit, which can control the motion algorithm task in the PLC during the EtherCAT communication cycle, so that the data of the PLC and the EhterCAT link can be efficiently synchronized, making the motion control speed faster and the position more accurate.
[0147] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0148] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0149] Fig.11 Schematic diagram of an industrial control data synchronization device provided by an embodiment of the present application. Fig.11 As shown, the device comprises:
[0150] The determination module 1101 is configured to determine the periodic data packet by the Ethernet control automation EtherCAT module under the condition of receiving the bus cycle start signal.
[0151] The writing module 1102 is configured to write the periodic data packet into the dual-port random access memory RAM by the EtherCAT module.
[0152] The interrupt module 1103 is configured to generate a data update interrupt message from the EtherCAT module and send the data update interrupt message to the programmable logic controller PLC module.
[0153] The reading module 1104 is configured to respond to receiving a data update interrupt message, read a periodic data packet from the dual-port RAM by the PLC module, generate output data based on the periodic data packet, and write the output data into the dual-port RAM.
[0154] The acquisition module 1105 is configured to acquire output data from the dual-port RAM through the EtherCAT module.
[0155] According to the technical solution provided in the embodiment of the present application, a dual-port RAM is added between the EtherCAT module and the PLC module, the EtherCAT module determines the periodic data packet at the beginning of the bus cycle, and sends the periodic data packet to the dual-port RAM, then the EtherCAT module generates and sends an interrupt message to the PLC module, after receiving the interrupt message, the PLC module obtains the periodic data packet from the dual-port RAM, generates output data based on the periodic data packet, and writes the output data to the dual-port RAM, the EtherCAT module obtains the output data written by the PLC module from the dual-port RAM, thereby realizing the use of the bus cycle of the EtherCAT module to transmit data between the EtherCAT module and the PLC module, without performing additional data synchronization operations, the data synchronization efficiency is high and the resource occupancy rate is small.
[0156] Fig.12 Schematic diagram of another industrial control data synchronization device provided by an embodiment of the present application. Fig.12 As shown, the device comprises:
[0157] The writing module 1201 is configured to write the target non-periodic data into the non-periodic data storage space in response to receiving the instruction to send non-periodic data.
[0158] The acquisition module 1202 is configured to acquire target non-periodic data from the non-periodic data storage space through the Ethernet control automation EtherCAT module.
[0159] The writing module 1201 is further configured to cause the EtherCAT module to write reply data of the target acyclic data in the acyclic data storage space.
[0160] The acquisition module 1202 is further configured to acquire, by the PLC module, reply data of the target non-periodic data from the non-periodic data storage space.
[0161] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0162] Fig.13 Schematic diagram of an electronic device provided in an embodiment of the present application. Fig.13 As shown, the electronic device 13 of this embodiment includes: a processor 1301, a memory 1302, and a computer program 1303 stored in the memory 1302 and executable on the processor 1301. When the processor 1301 executes the computer program 1303, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1301 executes the computer program 1303, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0163] The electronic device 13 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 13 may include, but is not limited to, a processor 1301 and a memory 1302. Those skilled in the art will appreciate that Fig.13 The electronic device 13 is merely an example and does not limit the electronic device 13 , and may include more or fewer components than those shown in the figure, or different components.
[0164] The processor 1301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0165] The memory 1302 may be an internal storage unit of the electronic device 13, for example, a hard disk or memory of the electronic device 13. The memory 1302 may also be an external storage device of the electronic device 13, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 13. The memory 1302 may also include both an internal storage unit of the electronic device 13 and an external storage device. The memory 1302 is used to store computer programs and other programs and data required by the electronic device.
[0166] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0167] If the integrated module / 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 present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0168] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An industrial control data synchronization method, characterized in that: The method is used to realize data synchronization between an Ethernet control automation EtherCAT module and a programmable logic controller PLC module, and the method comprises: Step S101, in response to receiving a bus cycle start signal, the EtherCAT module determines a periodic data packet; Step S102, the EtherCAT module writes the periodic data packet into a dual-port random access memory RAM; Step S103: the EtherCAT module generates a data update interrupt message, and sends the data update interrupt message to the PLC module; Step S104, in response to receiving the data update interrupt message, the PLC module reads the periodic data packet from the dual-port RAM, generates output data based on the periodic data packet, and writes the output data into the dual-port RAM; Step S105: The EtherCAT module obtains the output data from the dual-port RAM.
2. The method according to claim 1, characterized in that The EtherCAT module determines a periodic data packet, including: Step S1011, the EtherCAT module obtains output data of the previous bus cycle from the dual-port RAM; Step S1012: The EtherCAT module determines a periodic data packet of the current bus cycle based at least on the output data of the previous bus cycle.
3. The method according to claim 1, characterized in that The step S102 includes: Step S1021, the EtherCAT module obtains input data permission from the dual-port RAM; Step S1022, in response to determining that the EtherCAT module writes the periodic data packet into the dual-port RAM, the dual-port RAM sets an input data update flag bit; Step S1023: The EtherCAT module releases the input data permission of the dual-port RAM.
4. The method according to claim 1, characterized in that: The step S104 includes: Step S1041, in response to receiving the data update interrupt message, the PLC module obtains input data permission from the dual-port RAM; Step S1042, in response to determining that the input data update flag of the dual-port RAM is set, the PLC module obtains the periodic data packet from the dual-port RAM, resets the input data update flag and releases the input data permission of the dual-port RAM; Step S1043, the PLC module generates output data based on the periodic data packet, and releases the input data permission of the dual-port RAM; Step S1044, the PLC module obtains the output data authority from the dual-port RAM, and writes the output data into the dual-port RAM; Step S1045: in response to determining that the PLC module writes the output data packet into the dual-port RAM, the dual-port RAM sets an output data update flag bit; Step S1046: The PLC module releases the output data permission of the dual-port RAM.
5. The method according to claim 1, characterized in that The step 105 comprises: Step S1051, after sending the data update interrupt message, the EtherCAT module periodically queries the output data update flag of the dual-port RAM; Step S1052: in response to determining that the output data update flag of the dual-port RAM is set, the EtherCAT module obtains output data authority from the dual-port RAM; Step S1053: the EtherCAT module obtains the output data from the dual-port RAM, resets the output data update flag and releases the output data authority of the dual-port RAM.
6. An industrial control data synchronization method, characterized in that: The method is used to realize data synchronization between an Ethernet control automation EtherCAT module and a programmable logic controller PLC module, and the method comprises: Step S201, in response to receiving an instruction to send non-periodic data, the PLC module writes target non-periodic data into the non-periodic data storage space; Step S202, the EtherCAT module obtains the target non-periodic data from the non-periodic data storage space; Step S203, the EtherCAT module writes the reply data of the target non-periodic data into the non-periodic data storage space; Step S204: The PLC module obtains reply data of the target non-periodic data from the non-periodic data storage space.
7. The method according to claim 6, characterized in that The step S201 includes: In response to receiving the instruction to send non-periodic data, the PLC module obtains read and write permissions for the non-periodic data storage space from the dual-port random access memory RAM; The PLC module writes the target non-periodic data into the non-periodic data storage space; The PLC module sets the status flag of the non-periodic data storage space to a position and releases the read and write permissions of the non-periodic data storage space; The step S202 includes: In response to the query determining that the status flag of the non-periodic data storage space in the dual-port RAM is set, the EtherCAT module obtains the read and write permissions of the non-periodic data storage space from the dual-port RAM; The EtherCAT module reads the target non-periodic data, writes reply data of the target non-periodic data into the non-periodic data storage space, and releases the read and write permissions of the non-periodic data storage space; The step S204 includes: The PLC module obtains the read and write permissions of the non-periodic data storage space from the dual-port RAM, and obtains the reply data of the target non-periodic data; The PLC module resets the status flag of the non-periodic data storage space and releases the read and write permissions of the non-periodic data storage space.
8. An industrial control data synchronization device, characterized in that: include: The determination module is configured to determine the periodic data packet by the Ethernet control automation EtherCAT module under the condition of receiving the bus cycle start signal; A writing module is configured to write the periodic data packet into a dual-port random access memory RAM by the EtherCAT module; An interrupt module is configured to generate a data update interrupt message from the EtherCAT module and send the data update interrupt message to a programmable logic controller (PLC) module; a reading module configured to, in response to receiving the data update interrupt message, read the periodic data packet from the dual-port RAM by the PLC module, generate output data based on the periodic data packet, and write the output data into the dual-port RAM; The acquisition module is configured to acquire the output data from the dual-port RAM via the EtherCAT module.
9. An industrial control data synchronization device, characterized in that: include: A writing module is configured to write the target non-periodic data into the non-periodic data storage space by the PLC module in response to receiving the non-periodic data sending indication; An acquisition module is configured to acquire the target non-periodic data from the non-periodic data storage space by an Ethernet control automation EtherCAT module; The writing module is further configured to write reply data of the target non-periodic data in the non-periodic data storage space by the EtherCAT module; The acquisition module is further configured to acquire, by the PLC module, reply data of the target non-periodic data from the non-periodic data storage space.
10. A dual-port random access memory RAM, the dual-port RAM being used to implement the method according to any one of claims 1 to 7, characterized in that: The dual-port RAM at least includes a handshake channel, the handshake channel at least includes a handshake register, and the handshake register is used to manage the state information when the Ethernet control automation EtherCAT module and the programmable logic controller PLC module interact with the dual-port RAM; The status information includes at least one of the following: Data read and write permission information, and data storage space status information.