Inter-core communication method based on PLC multi-core system

By dividing the PLC multi-core system into control cores and computing cores, and combining OpenAMP and shared memory mechanisms with adaptive routing algorithms and linked list management mechanisms, the problem of low communication efficiency in PLC multi-core systems is solved, and stability and real-time performance are improved.

CN122086830APending Publication Date: 2026-05-26NANJING ZHILIHUI INFORMATION TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING ZHILIHUI INFORMATION TECHNOLOGY CO LTD
Filing Date
2026-02-12
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In existing multi-core PLC systems, the OpenAMP mechanism lacks real-time performance, while the shared memory mechanism suffers from frequent inter-core interrupts, affecting system stability and resulting in low communication efficiency.

Method used

A hybrid communication mechanism is adopted to divide the PLC multi-core system into a control core and a computing core, which respectively use the OpenAMP architecture and a shared memory mechanism. The optimal communication mode and priority management message transmission are dynamically selected through an adaptive routing algorithm and a doubly linked list optimization management mechanism.

Benefits of technology

It improves the communication stability and real-time performance of PLC multi-core systems, ensures fast and accurate data transmission, reduces system resource consumption and interruption interference, and enhances overall performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086830A_ABST
    Figure CN122086830A_ABST
Patent Text Reader

Abstract

The invention discloses an inter-core communication method based on a PLC multi-core system, and relates to the technical field of inter-core communication, the PLC multi-core system is divided into a control core and a calculation core, and initialization configuration is carried out for different types of cores; a hybrid communication mechanism is set, the hybrid communication mechanism comprises an openAMP architecture and a shared memory mechanism, and environment establishment is carried out for the two communication modes; establishing a message type identification mechanism, and automatically classifying according to message features; constructing a self-adaptive routing algorithm to select an optimal communication mode; constructing a double linked list optimization management mechanism, calculating message priorities, and setting message sending time in a double linked list; when the PLC multi-core system sends a message, a sending core selects a core type according to the optimal communication mode, and openAMP architecture communication and shared memory mechanism communication are executed respectively according to the core type; and checking a communication result, executing an automatic retransmission strategy when the communication fails, and calculating retransmission times and retransmission intervals.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of inter-core communication technology, specifically to an inter-core communication method based on a PLC multi-core system. Background Technology

[0002] Technological advancements and the demands of industrial automation are driving PLC performance upgrades. Single-core processors are limited in handling complex tasks, making multi-core processors crucial for improving PLC performance. Among these technologies, inter-core communication, a core technology of multi-core processors, plays a vital role in enhancing processor performance and system stability. Efficient inter-core communication mechanisms ensure fast and accurate data transmission between multiple cores, reducing latency, fully leveraging parallel computing capabilities, and ultimately improving overall performance.

[0003] Currently, there are two main methods for inter-core communication: the OpenAMP communication component and shared memory mechanisms. The OpenAMP mechanism achieves efficient multi-core parallel processing by optimizing the operating system and runtime environment, exhibiting high flexibility and reliability. It is widely applicable to different hardware and software environments and provides communication and synchronization mechanisms to ensure the correct execution of multi-core tasks. Shared memory mechanisms are an efficient inter-core communication method that allows multiple processes or threads to directly access the same memory region, thus significantly improving the efficiency of data transmission and processing. However, the OpenAMP mechanism has some real-time limitations. Furthermore, frequent inter-core interruptions in shared memory mechanisms may interfere with other applications in the operating system, affecting system stability and performance. Summary of the Invention

[0004] The purpose of this invention is to provide an inter-core communication method based on a PLC multi-core system to solve the problems raised in the prior art.

[0005] To achieve the above objectives, the present invention provides the following technical solution:

[0006] A method for inter-core communication in a PLC multi-core system, the method comprising the following steps:

[0007] S100: Divide the PLC multi-core system into a control core and a computing core, and perform initialization configuration for different types of cores;

[0008] Furthermore, the specific steps for initializing configurations for different types of cores are as follows:

[0009] S101. The PLC multi-core system is divided into a control core and a computing core. The control core is used to handle the input and output operations of the PLC multi-core system and communication with external devices, and sends control signals as messages. The computing core is used for data calculation and processing, and sends specific data as messages.

[0010] S102. Professionals set up a mapping structure for the control core and the computing core. The mapping structure includes a unique core identifier, core type, current load rate and communication capability indicators. A monitoring module is set up to monitor the CPU utilization, memory usage and communication queue status of the core in real time.

[0011] S200. Set up a hybrid communication mechanism, which includes the OpenAMP architecture and a shared memory mechanism, and build an environment for the two communication modes.

[0012] Furthermore, the specific steps for setting up the environment for the two communication modes are as follows:

[0013] S201. Set up a hybrid communication mechanism: the compute core uses the OpenAMP architecture, and the control core uses a shared memory mechanism. The specific environment setup for the OpenAMP architecture is as follows: download the BSP package and configure the Petalinux environment variables; create a new project; configure u-boot in detail, adding kernel options and modifying the device tree; then configure rootfs, selecting options to include the OpenAMP application, RPMsg module, and default test firmware; after completing the configuration, start the compilation process, generate the BOOT.BIN file, and output it to the specified directory; finally, start u-boot, manually load the system, execute test commands, and verify whether the OpenAMP configuration is successful. It is worth noting that the control core also needs to complete the relevant OpenAMP configuration. Although the compute core acts as the sender when using the OpenAMP mechanism for communication, there are situations where the compute core sends data to the control core, and both communicating parties need to be configured with the OpenAMP architecture.

[0014] S202. The specific environment setup for the shared memory mechanism is as follows: First, a memory address space is allocated as shared memory using System V. Different cores can access the shared memory. The shmat function is used to attach the process address space to the physical space. After the shared memory is allocated, communication is then completed using inter-core interrupts and synchronization mutual exclusion mechanisms.

[0015] By combining the openAMP architecture and shared memory mechanism, it adapts to the communication needs of different cores and solves the shortcomings of a single mechanism; it also builds a targeted environment to ensure the stable operation of both communication modes, laying the foundation for efficient communication.

[0016] S300: Establish a message type identification mechanism to automatically classify messages based on their characteristics; construct an adaptive routing algorithm to select the optimal communication mode.

[0017] Furthermore, the specific steps for constructing an adaptive routing algorithm to select the optimal communication mode are as follows:

[0018] S301. Extract the real-time performance, data volume, and periodicity of all messages in the PLC multi-core system. Real-time performance refers to the message processing time in the system, and periodicity indicates that messages repeat at fixed intervals within the system. After arranging all extracted message processing times from smallest to largest, calculate the difference between adjacent message processing times. Use the two largest differences as dividing nodes to divide the message processing time sequence into three segments. Define the first segment as high real-time, the second segment as medium real-time, and the third segment as low real-time, based on the message processing time from smallest to largest. Similarly, sort all message data volumes from smallest to largest, calculate adjacent differences, and extract the largest difference as a dividing node to divide the message data volume sequence into two segments. Define the first segment as small data volume and the second segment as large data volume, based on the message data volume from smallest to largest. A message is considered periodic if it repeats at fixed intervals within the system; otherwise, it is not periodic.

[0019] Data with high real-time requirements, small data volume, and no periodicity is classified as control signals; data with medium real-time requirements, large data volume, and no periodicity is classified as computational data; and messages with low real-time requirements and periodicity are classified as state synchronization.

[0020] S302. When a multi-core PLC system needs to process messages, extract the real-time nature, data volume, and current system load rate of the real-time message. Standardize these three data types and remove their dimensions to obtain a real-time factor, a data volume factor, and a current load rate factor. The adaptive routing algorithm is constructed as follows:

[0021] ;

[0022] In the formula, Route Score This represents the routing score, where α, β, and γ represent the weights of real-time performance, data volume, and current load rate, respectively. RealTime represents the real-time factor, DateSize represents the data volume factor, and Load represents the current load rate factor.

[0023] A preset scoring threshold is set. When the routing score is greater than or equal to the scoring threshold, the OpenAMP architecture communication mode is selected as the optimal communication mode; when the routing score is less than the scoring threshold, the shared memory mechanism communication mode is selected as the optimal communication mode.

[0024] Messages are automatically categorized based on real-time performance, data volume, and periodicity, allowing different message types to be matched with appropriate processing logic to improve categorization accuracy. The adaptive routing algorithm selects the optimal communication mode through multi-factor scoring, dynamically adapting to system load and message characteristics to ensure real-time and reliable communication.

[0025] S400: Construct a doubly linked list to optimize the management mechanism, calculate message priority, and set the message sending time in the doubly linked list;

[0026] Furthermore, the specific steps for setting the message sending time in a doubly linked list are as follows:

[0027] S401. In the shared memory communication mode, a doubly linked list optimization management mechanism is constructed. The linked list items in the doubly linked list can be flexibly ordered according to priority, and are arranged from front to back in the linked list items according to priority from high to low. For each message in the doubly linked list, the time urgency is extracted, which represents the reciprocal of the message's deadline. An expert scoring algorithm is used to score the security level of each message, and the current control core load rate is extracted. The priority is calculated after standardizing the time urgency, security level score, and load rate, using the following formula:

[0028] ;

[0029] In the formula, P represents message priority, w1, w2, and w3 represent the weights of time urgency, security level score, and load rate, respectively, and T... urgency S indicates the urgency of the situation. critical Indicates the security level rating, L core Indicates load rate;

[0030] S402. Each control core owns and maintains a doubly linked list to store information about messages that the control core has not sent. The data items in the linked list include CoreID[], *Msg, MsgSize, priority, next, and pre, which represent the receiving core ID array, the starting address of the transmitted information, the length of the transmitted information, the message priority, the pointer to the next message, and the pointer to the previous message, respectively.

[0031] The receiver core ID array stores multiple or a single receiver core ID. When a single control core sends the same information to multiple cores at the same time, multiple receiver core IDs are stored. The same information sent to different cores is merged into a linked list item. The sending core copies the content to the shared memory once, and the receiving cores respond to receive the information in turn.

[0032] S403. When a new message needs to be sent, first add the new message to the doubly linked list. First, check if the *Msg and MsgSize of any existing linked list node are consistent with the new message. If they are consistent, add the receiving core ID of the new message receiving node to the CoreID[] array. Otherwise, generate a linked list item corresponding to the new message, and insert the linked list item into the corresponding position in the doubly linked list according to the priority value of the new message in the linked list item, and modify the pointers of its predecessor and successor nodes. The doubly linked list supports adjusting the message order according to priority, prioritizing urgent and high-security messages, improving communication orderliness; merging multiple receiving core IDs for the same message reduces repeated access to shared memory, lowers resource consumption, and improves message sending efficiency.

[0033] S500: When sending messages in a multi-core PLC system, the sending core selects the core type according to the optimal communication mode, and executes OpenAMP architecture communication and shared memory mechanism communication respectively according to the core type.

[0034] Furthermore, the specific steps for performing communication in the OpenAMP architecture are as follows:

[0035] S501. When sending messages in a PLC multi-core system, the sending core selects its core type based on the optimal communication mode. When the optimal communication mode is OpenAMP architecture communication, the sending core is determined to be a computing core. The OpenAMP architecture communication steps are as follows:

[0036] A1. Send the kernel to initialize the remoteproc subsystem;

[0037] A2. The sending core loads the firmware on the remote processor via the remoteproc interface;

[0038] A3. Both the sending core and the receiving core initialize RPMsg support and create an RPMsg channel;

[0039] A4. After the channel is established, both the sending core and the receiving core call the API to communicate between the cores.

[0040] The specific steps for performing shared memory communication are as follows:

[0041] S502. When the optimal communication mode is shared memory mechanism communication, determine that the sending core is the control core; the steps of shared memory mechanism communication are as follows:

[0042] D1. Determine whether it is a new message according to the method in S403. If it is a new message, add a new message list item to the doubly linked list.

[0043] D2. Wait until there are no other linked list items before the new message linked list item, that is, it is the turn of the new message to be sent;

[0044] D3. Copy the data in the new message that needs to be transmitted to the shared memory, and generate inter-core interrupt notification receiving cores in the order of the CoreID[] array;

[0045] D4. The receiving core responds to the interrupts in sequence and reads data from the shared memory;

[0046] D5. Once all receiving cores in the CoreID[] array have successfully received the data, the sender deletes the first linked list item node in the doubly linked list to complete the communication.

[0047] When accessing shared memory in steps D3 and D4, a good synchronization and mutual exclusion mechanism needs to be set up. It is preferable to use read-write locks and semaphore mechanisms. The shared memory can be divided into N small blocks, and each small block can be accessed independently to ensure the security and stability of its access.

[0048] The above method enables efficient management of communication between multiple cores, ensuring accurate and rapid data transmission to each receiver. Simultaneously, the linked list structure allows the operating system to easily manage the order in which information is sent, reducing the number of shared memory accesses and ensuring orderly communication.

[0049] S600: Verify the communication result. If communication fails, execute the automatic retransmission strategy and calculate the number of retransmissions and the retransmission interval.

[0050] Furthermore, the specific steps for calculating the number of retransmissions and the retransmission interval are as follows:

[0051] S601. Construct a retransmission strategy, which includes the number of retransmissions and the retransmission interval; calculate the number of retransmissions using the following formula:

[0052] N retry =max(3,min(10,system) index ×5));

[0053] In the formula, N retry Indicates the number of retransmissions, system index The system stability index is determined by expert scoring; the retransmission interval is calculated using the formula: T interval =Base interval ×(1+Error×2), where T interval Indicates the retransmission interval, Base interval This indicates the preset basic retransmission interval, and Error indicates the system communication failure rate, which is obtained by dividing the number of communication failures by the total number of communications.

[0054] S602. The monitoring module monitors the message communication status. When the receiving core reports that no message has been received, it determines that the communication has failed and executes a retransmission strategy. The monitoring module verifies the communication results in real time, promptly detects communication failures, and dynamically calculates the number of retransmissions and the retransmission interval to avoid blind retransmissions, thereby improving the communication success rate while reducing system overhead.

[0055] Compared with the prior art, the beneficial effects of the present invention are:

[0056] 1. This invention combines the OpenAMP mechanism and the shared memory mechanism, and stipulates that the OpenAMP mechanism is used when the control core is the sender and the shared memory mechanism is used when the computing core is the sender. This solves the problems of excessive interrupts when using only the shared memory mechanism and low real-time performance when using only the OpenAMP mechanism in traditional inter-core communication, thereby improving the stability and real-time performance of the system.

[0057] 2. This invention designs a doubly linked list in the shared memory mechanism to store the sequence to be sent. Compared with the traditional queue method, the doubly linked list is more flexible, and the addition of priority makes it easier to manage the order. Attached Figure Description

[0058] Figure 1 This is a diagram illustrating the overall architecture of inter-core communication in a PLC multi-core system based on the present invention.

[0059] Figure 2 This is a doubly linked list structure diagram of an inter-core communication method based on a PLC multi-core system according to the present invention;

[0060] Figure 3 This is a flowchart of the insertion of a new node in a PLC multi-core system inter-core communication method according to the present invention. Detailed Implementation

[0061] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0062] Example: Figures 1-3 As shown, the present invention provides a technical solution.

[0063] A method for inter-core communication in a PLC multi-core system, the method comprising the following steps:

[0064] S100: Divide the PLC multi-core system into a control core and a computing core, and perform initialization configuration for different types of cores;

[0065] The specific steps for initializing and configuring different types of cores are as follows:

[0066] S101. The PLC multi-core system is divided into a control core and a computing core. The control core is used to handle the input and output operations of the PLC multi-core system and communication with external devices, and sends control signals as messages. The computing core is used for data calculation and processing, and sends specific data as messages.

[0067] S102. Professionals set up a mapping structure for the control core and the computing core. The mapping structure includes a unique core identifier, core type, current load rate and communication capability indicators. A monitoring module is set up to monitor the CPU utilization, memory usage and communication queue status of the core in real time.

[0068] S200. Set up a hybrid communication mechanism, which includes the OpenAMP architecture and a shared memory mechanism, and build an environment for the two communication modes.

[0069] The specific steps for setting up the environment for the two communication modes are as follows:

[0070] S201. Set up a hybrid communication mechanism: the compute core uses the OpenAMP architecture, and the control core uses a shared memory mechanism. The specific environment setup for the OpenAMP architecture is as follows: download the BSP package and configure the Petalinux environment variables; create a new project; configure u-boot in detail, adding kernel options and modifying the device tree; then configure rootfs, selecting options to include the OpenAMP application, RPMsg module, and default test firmware; after completing the configuration, start the compilation process, generate the BOOT.BIN file, and output it to the specified directory; finally, start u-boot, manually load the system, execute test commands, and verify whether the OpenAMP configuration is successful. It is worth noting that the control core also needs to complete the relevant OpenAMP configuration. Although the compute core acts as the sender when using the OpenAMP mechanism for communication, there are situations where the compute core sends data to the control core, and both communicating parties need to be configured with the OpenAMP architecture.

[0071] S202. The specific environment setup for the shared memory mechanism is as follows: First, a memory address space is allocated as shared memory using System V. Different cores can access the shared memory. The shmat function is used to attach the process address space to the physical space. After the shared memory is allocated, communication is then completed using inter-core interrupts and synchronization mutual exclusion mechanisms.

[0072] By combining the openAMP architecture and shared memory mechanism, it adapts to the communication needs of different cores and solves the shortcomings of a single mechanism; it also builds a targeted environment to ensure the stable operation of both communication modes, laying the foundation for efficient communication.

[0073] S300: Establish a message type identification mechanism to automatically classify messages based on their characteristics; construct an adaptive routing algorithm to select the optimal communication mode.

[0074] The specific steps for constructing an adaptive routing algorithm to select the optimal communication mode are as follows:

[0075] S301. Extract the real-time performance, data volume, and periodicity of all messages in the PLC multi-core system. Real-time performance refers to the message processing time in the system, and periodicity indicates that messages repeat at fixed intervals within the system. After arranging all extracted message processing times from smallest to largest, calculate the difference between adjacent message processing times. Use the two largest differences as dividing nodes to divide the message processing time sequence into three segments. Define the first segment as high real-time, the second segment as medium real-time, and the third segment as low real-time, based on the message processing time from smallest to largest. Similarly, sort all message data volumes from smallest to largest, calculate adjacent differences, and extract the largest difference as a dividing node to divide the message data volume sequence into two segments. Define the first segment as small data volume and the second segment as large data volume, based on the message data volume from smallest to largest. A message is considered periodic if it repeats at fixed intervals within the system; otherwise, it is not periodic.

[0076] Data with high real-time requirements, small data volume, and no periodicity is classified as control signals; data with medium real-time requirements, large data volume, and no periodicity is classified as computational data; and messages with low real-time requirements and periodicity are classified as state synchronization.

[0077] S302. When a multi-core PLC system needs to process messages, extract the real-time nature, data volume, and current system load rate of the real-time message. Standardize these three data types and remove their dimensions to obtain a real-time factor, a data volume factor, and a current load rate factor. The adaptive routing algorithm is constructed as follows:

[0078] ;

[0079] In the formula, Route Score This represents the routing score, where α, β, and γ represent the weights of real-time performance, data volume, and current load rate, respectively. RealTime represents the real-time factor, DateSize represents the data volume factor, and Load represents the current load rate factor.

[0080] A preset scoring threshold is set. When the routing score is greater than or equal to the scoring threshold, the OpenAMP architecture communication mode is selected as the optimal communication mode; when the routing score is less than the scoring threshold, the shared memory mechanism communication mode is selected as the optimal communication mode.

[0081] Messages are automatically categorized based on real-time performance, data volume, and periodicity, allowing different message types to be matched with appropriate processing logic to improve categorization accuracy. The adaptive routing algorithm selects the optimal communication mode through multi-factor scoring, dynamically adapting to system load and message characteristics to ensure real-time and reliable communication.

[0082] S400: Construct a doubly linked list to optimize the management mechanism, calculate message priority, and set the message sending time in the doubly linked list;

[0083] The specific steps for setting the message sending time in a doubly linked list are as follows:

[0084] S401. In the shared memory communication mode, a doubly linked list optimization management mechanism is constructed. The linked list items in the doubly linked list can be flexibly ordered according to priority, and are arranged from front to back in the linked list items according to priority from high to low. For each message in the doubly linked list, the time urgency is extracted, which represents the reciprocal of the message's deadline. An expert scoring algorithm is used to score the security level of each message, and the current control core load rate is extracted. The priority is calculated after standardizing the time urgency, security level score, and load rate, using the following formula:

[0085] ;

[0086] In the formula, P represents message priority, w1, w2, and w3 represent the weights of time urgency, security level score, and load rate, respectively, and T... urgency S indicates the urgency of the situation. critical Indicates the security level rating, L core Indicates load rate;

[0087] S402. Each control core owns and maintains a doubly linked list to store information about messages that the control core has not sent. The data items in the linked list include CoreID[], *Msg, MsgSize, priority, next, and pre, which represent the receiving core ID array, the starting address of the transmitted information, the length of the transmitted information, the message priority, the pointer to the next message, and the pointer to the previous message, respectively.

[0088] The receiver core ID array stores multiple or a single receiver core ID. When a single control core sends the same information to multiple cores at the same time, multiple receiver core IDs are stored. The same information sent to different cores is merged into a linked list item. The sending core copies the content to the shared memory once, and the receiving cores respond to receive the information in turn.

[0089] S403. When a new message needs to be sent, first add the new message to the doubly linked list. First, check if the *Msg and MsgSize of any existing linked list node are consistent with the new message. If they are consistent, add the receiving core ID of the new message receiving node to the CoreID[] array. Otherwise, generate a linked list item corresponding to the new message, and insert the linked list item into the corresponding position in the doubly linked list according to the priority value of the new message in the linked list item, and modify the pointers of its predecessor and successor nodes. The doubly linked list supports adjusting the message order according to priority, prioritizing urgent and high-security messages, improving communication orderliness; merging multiple receiving core IDs for the same message reduces repeated access to shared memory, lowers resource consumption, and improves message sending efficiency.

[0090] S500: When sending messages in a multi-core PLC system, the sending core selects the core type according to the optimal communication mode, and executes OpenAMP architecture communication and shared memory mechanism communication respectively according to the core type.

[0091] The specific steps for performing communication in the OpenAMP architecture are as follows:

[0092] S501. When sending messages in a PLC multi-core system, the sending core selects its core type based on the optimal communication mode. When the optimal communication mode is OpenAMP architecture communication, the sending core is determined to be a computing core. The OpenAMP architecture communication steps are as follows:

[0093] A1. Send the kernel to initialize the remoteproc subsystem;

[0094] A2. The sending core loads the firmware on the remote processor via the remoteproc interface;

[0095] A3. Both the sending core and the receiving core initialize RPMsg support and create an RPMsg channel;

[0096] A4. After the channel is established, both the sending core and the receiving core call the API to communicate between the cores.

[0097] The specific steps for performing shared memory communication are as follows:

[0098] S502. When the optimal communication mode is shared memory mechanism communication, determine that the sending core is the control core; the steps of shared memory mechanism communication are as follows:

[0099] D1. Determine whether it is a new message according to the method in S403. If it is a new message, add a new message list item to the doubly linked list.

[0100] D2. Wait until there are no other linked list items before the new message linked list item, that is, it is the turn of the new message to be sent;

[0101] D3. Copy the data in the new message that needs to be transmitted to the shared memory, and generate inter-core interrupt notification receiving cores in the order of the CoreID[] array;

[0102] D4. The receiving core responds to the interrupts in sequence and reads data from the shared memory;

[0103] D5. Once all receiving cores in the CoreID[] array have successfully received the data, the sender deletes the first linked list item node in the doubly linked list to complete the communication.

[0104] When accessing shared memory in steps D3 and D4, a good synchronization and mutual exclusion mechanism needs to be set up. It is preferable to use read-write locks and semaphore mechanisms. The shared memory can be divided into N small blocks, and each small block can be accessed independently to ensure the security and stability of its access.

[0105] The above method enables efficient management of communication between multiple cores, ensuring accurate and rapid data transmission to each receiver. Simultaneously, the linked list structure allows the operating system to easily manage the order in which information is sent, reducing the number of shared memory accesses and ensuring orderly communication.

[0106] S600: Verify the communication result. If communication fails, execute the automatic retransmission strategy and calculate the number of retransmissions and the retransmission interval.

[0107] The specific steps for calculating the number of retransmissions and the retransmission interval are as follows:

[0108] S601. Construct a retransmission strategy, which includes the number of retransmissions and the retransmission interval; calculate the number of retransmissions using the following formula:

[0109] N retry =max(3,min(10,system) index ×5));

[0110] In the formula, N retry Indicates the number of retransmissions, system index The system stability index is determined by expert scoring; the retransmission interval is calculated using the formula: T interval =Base interval ×(1+Error×2), where T interval Indicates the retransmission interval, Base interval This indicates the preset basic retransmission interval, and Error indicates the system communication failure rate, which is obtained by dividing the number of communication failures by the total number of communications.

[0111] S602. The monitoring module monitors the message communication status. When the receiving core reports that no message has been received, it determines that the communication has failed and executes a retransmission strategy. The monitoring module verifies the communication results in real time, promptly detects communication failures, and dynamically calculates the number of retransmissions and the retransmission interval to avoid blind retransmissions, thereby improving the communication success rate while reducing system overhead.

[0112] Example:

[0113] Each control core maintains its own doubly linked list, i.e., the doubly linked list in step D1, used to manage messages to be sent. Preferably, page tables or similar mechanisms can be used to retrieve the doubly linked list corresponding to the core. The doubly linked list structure is as follows: Figure 2As shown, the linked list items include data items such as CoreID[], *Msg, MsgSize, priority, *next, and *pre, with an empty head node for easy operation. CoreID[] is an array storing the IDs of multiple receiving cores. Since there may be one-to-many transmissions of the same control information, there may be more than one receiving core ID. *Msg is the starting address of the transmitted data, and MsgSize is the length of the data. *Msg and MsgSize are used to locate the specific data storage location. Next, *next and *pre are the successor pointer and the predecessor pointer, respectively, used to connect the entire linked list and facilitate the insertion, querying, and order adjustment of linked list items. Priority is the priority of the message. The doubly linked list will be sorted according to the priority in order so that messages with higher priority are sent first.

[0114] In the shared memory mechanism, when a new message is generated, i.e., step D1, the process is as follows: Figure 3 As shown, the sending core first checks if there is a situation where the same core is sending the same control information to multiple cores simultaneously. Starting from the head of the linked list, it polls the linked list to check if there is a node whose *Msg and MsgSize are exactly the same as the new message. If a node with *Msg and MsgSize is found during the polling process, only the required receiving core ID needs to be added to codeID1[], reducing the number of shared memory accesses. If no node with *Msg and MsgSize is found after polling to the end of the doubly linked list, a new node is created, designated as node A. The CoreID[], *Msg, MsgSize, priority, *next, and *pre data items of the new node are filled in according to the relevant information. Based on the priority field of node A, the system polls from the head node of the doubly linked list in descending order of priority to find the last node with a priority greater than that of the new node, designated as node B. Finally, add a new node at this position, modify the *next and *pre pointers, and set A->*next=B->*next, B->*next->*pre=A, A->*pre=B, and B->*next=A. Then connect the new node to the doubly linked list.

[0115] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A method for inter-core communication based on a PLC multi-core system, characterized in that: The method includes the following steps: S100: Divide the PLC multi-core system into a control core and a computing core, and perform initialization configuration for different types of cores; S200. Set up a hybrid communication mechanism, which includes the OpenAMP architecture and a shared memory mechanism, and build an environment for the two communication modes. S300: Establish a message type identification mechanism to automatically classify messages based on their characteristics; construct an adaptive routing algorithm to select the optimal communication mode. S400: Construct a doubly linked list to optimize the management mechanism, calculate message priority, and set the message sending time in the doubly linked list; S500: When sending messages in a multi-core PLC system, the sending core selects the core type according to the optimal communication mode, and executes OpenAMP architecture communication and shared memory mechanism communication respectively according to the core type. S600: Verify the communication result. If communication fails, execute the automatic retransmission strategy and calculate the number of retransmissions and the retransmission interval.

2. The inter-core communication method based on a PLC multi-core system according to claim 1, characterized in that: The specific steps for initializing and configuring different types of cores in S100 are as follows: S101. The PLC multi-core system is divided into a control core and a computing core. The control core is used to handle the input and output operations of the PLC multi-core system and communication with external devices, and sends control signals as messages. The computing core is used for data calculation and processing, and sends specific data as messages. S102. Professionals set up a mapping structure for the control core and the computing core. The mapping structure includes a unique core identifier, core type, current load rate and communication capability indicators. A monitoring module is set up to monitor the CPU utilization, memory usage and communication queue status of the core in real time.

3. The inter-core communication method based on a PLC multi-core system according to claim 2, characterized in that: The specific steps for setting up the environment for the two communication modes in S200 are as follows: S201. Set up a hybrid communication mechanism, with the computing core using the OpenAMP architecture and the control core using a shared memory mechanism; the specific environment setup for the OpenAMP architecture is as follows: download the BSP package, configure the Petalinux environment variables, create a new project, configure u-boot in depth, add kernel options, and modify the device tree; Next, configure rootfs, selecting options that include the OpenAMP application, RPMsg module, and default test firmware; after completing the configuration, start the compilation process, generate the BOOT.BIN file, and output it to the specified directory; finally, start u-boot, manually load the system, execute test commands, and verify whether the OpenAMP configuration is successful. S202. The specific setup for the shared memory mechanism is as follows: First, use SystemV to request a memory address space as shared memory. Different cores can access the shared memory. Use the shmat function to attach the process address space to the physical space.

4. The inter-core communication method based on a PLC multi-core system according to claim 3, characterized in that: The specific steps in step S300 for constructing the adaptive routing algorithm to select the optimal communication mode are as follows: S301. Extract the real-time performance, data volume, and periodicity of all messages in the PLC multi-core system. Real-time performance refers to the message processing time in the system, and periodicity indicates that messages repeat at fixed intervals within the system. After arranging all extracted message processing times from smallest to largest, calculate the difference between adjacent message processing times. Use the two largest differences as dividing nodes to divide the message processing time sequence into three segments. Define the first segment as high real-time, the second segment as medium real-time, and the third segment as low real-time, based on the message processing time from smallest to largest. Similarly, sort all message data volumes from smallest to largest, calculate adjacent differences, and extract the largest difference as a dividing node to divide the message data volume sequence into two segments. Define the first segment as small data volume and the second segment as large data volume, based on the message data volume from smallest to largest. A message is considered periodic if it repeats at fixed intervals within the system; otherwise, it is not periodic. Data with high real-time requirements, small data volume, and no periodicity is classified as control signals; data with medium real-time requirements, large data volume, and no periodicity is classified as computational data; and messages with low real-time requirements and periodicity are classified as state synchronization. S302. When a multi-core PLC system needs to process messages, extract the real-time nature, data volume, and current system load rate of the real-time message. Standardize these three data types and remove their dimensions to obtain a real-time factor, a data volume factor, and a current load rate factor. The adaptive routing algorithm is constructed as follows: ; In the formula, Route Score This represents the routing score, where α, β, and γ represent the weights of real-time performance, data volume, and current load rate, respectively. RealTime represents the real-time factor, DateSize represents the data volume factor, and Load represents the current load rate factor. A preset scoring threshold is set. When the routing score is greater than or equal to the scoring threshold, the OpenAMP architecture communication mode is selected as the optimal communication mode; when the routing score is less than the scoring threshold, the shared memory mechanism communication mode is selected as the optimal communication mode.

5. The inter-core communication method based on a PLC multi-core system according to claim 4, characterized in that: The specific steps for setting the message sending time in the doubly linked list in S400 are as follows: S401. In the shared memory communication mode, a doubly linked list optimization management mechanism is constructed. The linked list items in the doubly linked list can be flexibly ordered according to priority, and are arranged from front to back in the linked list items according to priority from high to low. For each message in the doubly linked list, the time urgency is extracted, which represents the reciprocal of the message's deadline. An expert scoring algorithm is used to score the security level of each message, and the current control core load rate is extracted. The priority is calculated after standardizing the time urgency, security level score, and load rate, using the following formula: ; In the formula, P represents message priority, w1, w2, and w3 represent the weights of time urgency, security level score, and load rate, respectively, and T... urgency S indicates the urgency of the situation. critical Indicates the security level rating, L core Indicates load rate; S402. Each control core owns and maintains a doubly linked list to store information about messages that the control core has not sent. The data items in the linked list include CoreID[], *Msg, MsgSize, priority, next, and pre, which represent the receiving core ID array, the starting address of the transmitted information, the length of the transmitted information, the message priority, the pointer to the next message, and the pointer to the previous message, respectively. The receiver core ID array stores multiple or a single receiver core ID. When a single control core sends the same information to multiple cores at the same time, multiple receiver core IDs are stored. The same information sent to different cores is merged into a linked list item. The sending core copies the content to the shared memory once, and the receiving cores respond to receive the information in turn. S403. When a new message needs to be sent, first add the new message to the doubly linked list. First, determine whether the *Msg and MsgSize of any existing linked list item node are consistent with the new message. If they are consistent, add the receiving core ID of the new message receiving node to the CoreID[] array. Otherwise, generate the linked list item corresponding to the new message, and insert the linked list item into the corresponding position of the doubly linked list according to the priority value of the new message in the linked list item, and modify the pointers of its predecessor node and successor node.

6. The inter-core communication method based on a PLC multi-core system according to claim 5, characterized in that: The specific steps for performing OpenAMP architecture communication in step S500 are as follows: S501. When sending messages in a PLC multi-core system, the sending core selects its core type based on the optimal communication mode. When the optimal communication mode is OpenAMP architecture communication, the sending core is determined to be a computing core. The OpenAMP architecture communication steps are as follows: A1. Send the kernel to initialize the remoteproc subsystem; A2. The sending core loads the firmware on the remote processor via the remoteproc interface; A3. Both the sending core and the receiving core initialize RPMsg support and create an RPMsg channel; A4. After the channel is established, both the sending core and the receiving core call the API to communicate between the cores.

7. The inter-core communication method based on a PLC multi-core system according to claim 6, characterized in that: The specific steps for performing shared memory mechanism communication in step S500 are as follows: S502. When the optimal communication mode is shared memory mechanism communication, determine that the sending core is the control core; the steps of shared memory mechanism communication are as follows: D1. Determine whether it is a new message according to the method in S403. If it is a new message, add a new message list item to the doubly linked list. D2. Wait until there are no other linked list items before the new message linked list item, that is, it is the turn of the new message to be sent; D3. Copy the data in the new message that needs to be transmitted to the shared memory, and generate inter-core interrupt notification receiving cores in the order of the CoreID[] array; D4. The receiving core responds to the interrupts in sequence and reads data from the shared memory; D5. Once all receiving cores in the CoreID[] array have successfully received the data, the sender deletes the first linked list item node in the doubly linked list to complete the communication.

8. The inter-core communication method based on a PLC multi-core system according to claim 7, characterized in that: The specific steps for calculating the number of retransmissions and the retransmission interval in step S600 are as follows: S601. Construct a retransmission strategy, which includes the number of retransmissions and the retransmission interval; calculate the number of retransmissions using the following formula: N retry =max(3,min(10,system index ×5)); In the formula, N retry Indicates the number of retransmissions, system index The system stability index is determined by expert scoring; the retransmission interval is calculated using the formula: T interval =Base interval ×(1+Error×2), where T interval Indicates the retransmission interval, Base interval This indicates the preset basic retransmission interval, and Error indicates the system communication failure rate, which is obtained by dividing the number of communication failures by the total number of communications. S602. The monitoring module monitors the message communication status. When the receiving kernel reports that no message has been received, it determines that the communication has failed and executes the retransmission strategy.