Multi-master synchronization method and apparatus, and storage medium

By setting high-priority time synchronization tasks and atomic access mechanisms in a multi-master system, the synchronization accuracy and stability issues of traditional multi-master synchronization technology in complex network environments are solved. This achieves time synchronization accuracy and data consistency under high load conditions, making it suitable for collaborative execution of complex tasks in fields such as industrial automation and aerospace.

CN120281421BActive Publication Date: 2026-04-28ANHUI GUOXUN CORE MICROTECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510772211.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2026-04-28
Estimated Expiration
2045-06-11

AI Technical Summary

Technical Problem

Traditional multi-master synchronization technology suffers from poor synchronization accuracy and stability in complex network environments, especially under high load tasks, and cannot meet the requirements of high-precision applications. Furthermore, data synchronization suffers from problems such as untimely updates and data conflicts.

Method used

A hardware interrupt and operating system preemption mechanism is adopted to set high priority for time synchronization tasks, trigger the preemption of low priority tasks through the hardware interrupt controller, and combine it with atomic access mechanism to ensure the accuracy and continuity of data synchronization.

Benefits of technology

In complex system environments, time synchronization tasks always prioritize acquiring system resources to ensure the accuracy and continuity of time synchronization, avoid data conflicts, and improve the overall availability and data consistency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120281421B_ABST
    Figure CN120281421B_ABST
Patent Text Reader

Abstract

The application discloses a kind of multi-master station synchronization method, device and storage medium, and multi-master station synchronization method includes the following steps: setting priority for each master station process;Preset master station generates time synchronization message and sends to network, when receiving master station receives time synchronization message, trigger hardware interrupt, receiving master station executes time synchronization task, receiving master station calculates time deviation according to time synchronization message, and adjusts local clock;Preset master station updates the data of shared data area, and sends data update notification to receiving master station;Receiving master station updates local data based on data update notification.This method is based on the preemption mechanism of hardware interrupt and operating system, gives the ability of stable execution of time synchronization task in complex system environment, in the face of complex situations such as high load, network fluctuation, time synchronization task can always acquire system resources preferentially, ensure the accuracy and continuity of time synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of multi-master station synchronization technology, specifically a multi-master station synchronization method, apparatus, and storage medium. Background Technology

[0002] In today's widespread application of multi-master systems, the quality of the synchronization mechanism directly determines the stability and accuracy of system operation. This is especially true in fields such as industrial automation, robotics, and aerospace, where multiple masters need to collaborate to complete complex and critical tasks. Traditional multi-master synchronization technologies suffer from poor synchronization accuracy and stability when facing complex network environments and high-load tasks. Traditional time synchronization algorithms are susceptible to interference from factors such as network latency and clock drift, resulting in time errors between masters often reaching millisecond levels or even higher, failing to meet the demands of high-precision applications. Regarding data synchronization, methods based on file transfer or simple message passing suffer from problems such as untimely updates and data conflicts, leading to data inconsistencies between masters and impacting overall system performance. Summary of the Invention

[0003] To overcome the shortcomings of the prior art, the present invention provides a multi-master station synchronization method, device and storage medium. The multi-master station synchronization method is based on hardware interrupt and operating system preemption mechanism, which gives the time synchronization task the ability to execute stably in complex system environment. In the face of complex situations such as high load and network fluctuation, the time synchronization task can always obtain system resources first, ensuring the accuracy and continuity of time synchronization.

[0004] To achieve the above objectives, the technical solution adopted by this invention is: a multi-master station synchronization method for performing synchronization tasks for multiple master stations, comprising the following steps:

[0005] Set priorities for each master station process and configure network parameters for time synchronization between master stations;

[0006] The master station is preset to start a time synchronization task at a preset time interval. The time synchronization task includes the master station that starts the time synchronization task generating a time synchronization message and sending it to the receiving master station.

[0007] After receiving the time synchronization message, the receiving master station triggers a hardware interrupt, executes the time synchronization task, calculates the time deviation based on the time synchronization message, and adjusts the local clock according to the time deviation.

[0008] The master station is preset to start a data synchronization task at a preset time interval. The data synchronization task includes the master station that starts the data synchronization task updating the data in the shared data area and sending a data update notification to the receiving master station. The receiving master station accesses the shared data area based on the data update notification to obtain the latest data.

[0009] Through the above technical solution, when the time synchronization task is started, the method triggers a hardware interrupt through the interrupt controller. Relying on the preemption mechanism of the operating system, the time synchronization task preempts the current low-priority task, giving the time synchronization task the ability to execute stably in complex system environments. In the face of complex situations such as high load and network fluctuations, the time synchronization task can always obtain system resources first, ensuring the accuracy and continuity of time synchronization.

[0010] Furthermore, the steps for initiating the data synchronization task on the main site to update the data in the shared data area include:

[0011] The master station that initiates the data synchronization task acquires access permissions to the shared data area through an atomic access mechanism. After acquiring access permissions, the master station that initiated the data synchronization task releases the access permissions only after the data in the shared data area has been updated.

[0012] Through the above technical solution, the atomic access mechanism achieves uninterrupted operation within a single instruction cycle through CPU atomic instructions, ensuring that the operation is either fully executed or not executed at all. This atomic access mechanism effectively avoids the additional overhead caused by process context switching and is suitable for scenarios with short data operation times and high real-time requirements.

[0013] Furthermore, when the master station that initiates the data synchronization task updates the data in the shared data area, the receiving master station is included in the waiting queue for the data update notification. The waiting queue for the data update notification is set with a hard time limit to ensure that the data update notification is delivered to its receiving master station within the deadline.

[0014] Furthermore, the atomic access mechanism includes:

[0015] The system determines whether the shared data area is being used by other master stations. If it is, the master station that initiated the data synchronization task requests access to the shared data area at preset time intervals until it successfully obtains access. While the shared data area is being used by other master stations, the master station that initiated the data synchronization task will not enter a waiting / sleep state, but will instead request access to the shared data area at preset time intervals. Due to the high efficiency of the hardware operating system, the time the master station spends waiting to obtain access to the shared data area is extremely short.

[0016] Further steps include sending data update notifications to the receiving master station, including:

[0017] A data change notification mechanism is used to send data update notifications to the receiving master station. When the master station that initiated the data synchronization task releases access permissions, it immediately notifies the receiving master station to regain access permissions via a semaphore. After the master station that initiated the data synchronization task completes the data update operation on the shared data area, the operating system automatically triggers the data change notification process. Upon receiving the data update notification, the receiving master station immediately accesses the shared data area and reads the latest data from it.

[0018] Furthermore, the steps for receiving data update notifications from the main station and accessing the shared data area include:

[0019] The receiving master station obtains access permissions to the shared data area through an atomic access mechanism. By combining the data change notification mechanism with the atomic access mechanism, data synchronization between multiple master stations can be achieved efficiently, ensuring that each master station can obtain the latest data in a timely and accurate manner when data changes, thus guaranteeing data consistency.

[0020] Furthermore, the master station that initiates the data synchronization task updates the data in the shared data area and sends a data update notification to the receiving master station. The receiving master station accesses the shared data area based on the data update notification to obtain the latest data, including:

[0021] After the main station initiates the data synchronization task, it updates the data in the shared data area and generates a new data version number.

[0022] The data update notification sent to the receiving master station includes the new data version number;

[0023] Receive local data updates from the main station based on the new data version number in the data update notification.

[0024] Furthermore, the master station is an EtherCAT master station.

[0025] Furthermore, the network parameters for time synchronization between master stations include synchronization frequency, time deviation, and timeout. The synchronization frequency refers to the trigger interval of periodic tasks or data synchronization operations, directly affecting the system's response speed to change events. The time deviation refers to the offset between the actual synchronization time and the ideal time reference, which needs to be calibrated through a clock synchronization protocol. The timeout is the maximum allowed duration threshold for synchronization operations; exceeding this threshold results in failure and triggers a recovery process.

[0026] A multi-master station synchronization device, comprising:

[0027] The multi-master configuration module is used to set the priority of each master process and configure the network parameters for time synchronization between master stations.

[0028] The time synchronization task generation module is used to preset the master station to start a time synchronization task at a preset time interval. The time synchronization task includes the master station that starts the time synchronization task generating a time synchronization message and sending it to the receiving master station.

[0029] The time synchronization task response module is used to receive the master station's time synchronization message, trigger a hardware interrupt, receive the master station's execution of the time synchronization task, receive the master station's calculation of the time deviation based on the time synchronization message, and adjust the local clock based on the time deviation.

[0030] The data synchronization task generation module is used to preset the master station to start a data synchronization task at a preset time interval. The data synchronization task includes the master station that starts the data synchronization task updating the data in the shared data area and sending a data update notification to the receiving master station.

[0031] The data synchronization task response module is used to receive data update notifications from the main station, access the shared data area, and obtain the latest data.

[0032] A storage medium, which is a computer-readable storage medium, stores a computer program that, when executed by a multi-core processor, implements the aforementioned multi-master station synchronization method.

[0033] By employing the above technical solutions, the beneficial effects of the present invention are as follows:

[0034] The master station synchronization method disclosed in this application is based on hardware interrupts and the preemption mechanism of the operating system, which gives the time synchronization task the ability to execute stably in complex system environments. In the face of complex situations such as high load and network fluctuations, the time synchronization task can always obtain system resources first, ensuring the accuracy and continuity of time synchronization. It can meet the application scenarios with strict requirements for synchronization accuracy, such as robot collaboration and precision multi-arm collaborative industrial processing, and provides a solid guarantee for the precise collaborative execution of complex tasks.

[0035] The master station synchronization method disclosed in this application uses an atomic access mechanism to effectively avoid the additional overhead caused by process context switching. It is suitable for scenarios with short data operation time and high real-time requirements. Due to the high efficiency of the operating system, the master station waits for a very short time to obtain data access permissions, thereby ensuring the independence of data operations, preventing multiple master stations from operating on the same data at the same time and causing data conflicts, effectively reducing the risk of system failure and improving the overall availability of the system.

[0036] To make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0037] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is a topology diagram of the multi-master station synchronization method in this embodiment of the invention;

[0039] Figure 2 This is a structural block diagram of the multi-master station controller in an embodiment of the present invention;

[0040] Figure 3 This is a flowchart of the multi-master station synchronization process in an embodiment of the present invention;

[0041] Figure 4 This is a diagram of the multi-master station synchronization structure in an embodiment of the present invention.

[0042] The reference numerals in the above figures are as follows: 1. Multi-master controller; 11. Multi-core processor; 12. Multi-port network interface; 13. Storage module; 2. Master station; 3. Slave station; 4. MAC network card. Detailed Implementation

[0043] 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.

[0044] It should be noted that in the description of this invention, the terms "first," "second," etc., are used only for descriptive purposes and to distinguish similar objects; there is no order between them, nor should they be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means two or more.

[0045] Example: This example discloses a multi-master station synchronization method, including the following steps:

[0046] The hard real-time operating system is based on the multi-master controller 1. In kernel mode, it obtains the count of master station 2, registers the number of master stations 2, and configures the cores of the multi-core processor 11 as the corresponding number of EtherCAT master stations 2.

[0047] EtherCAT is a high-performance real-time communication protocol based on Ethernet, designed specifically for the real-time control and data acquisition needs of industrial automation. EtherCAT Master Station 2 uses an intra-frame processing mechanism to allow a single data frame to be processed sequentially by multiple slave stations during transmission, reducing network latency. It is a core component for achieving high-speed real-time control in industrial automation, responsible for coordinating slave devices in the network and ensuring efficient data synchronization.

[0048] like Figure 2 As shown, the multi-master controller 1 includes a multi-core processor 11, multiple network ports 12, and a storage module 13 connected to the multi-core processor 11. The multi-core processor 11 is connected to multiple MAC network cards 4 through the multiple network ports 12. The multi-core processor 11 is simultaneously connected to multiple MAC network cards 4, and the core of the multi-core processor 11 connected to the MAC network card 4 is configured with the corresponding MAC address of the MAC network card 4's network port. The MAC network card 4 is connected to the slave station 3 sequentially through a PHY, a protocol stack, and an RJ45 interface.

[0049] PHY stands for Port Physical Layer. RJ45 is a network interface connector; it typically connects to an Ethernet cable at one end and is used to connect various network devices.

[0050] The hard real-time operating system is applied to the multi-master controller 1, slave station 3, and MAC network card 4. The hard real-time operating system employs preemptive priority scheduling, allowing high-priority tasks to immediately interrupt low-priority tasks; it supports the earliest deadline priority algorithm to dynamically allocate task execution order; and it has a built-in deadline monitoring module that triggers error callbacks or system recovery upon timeout. Therefore, the hard real-time operating system can strictly guarantee that tasks are completed within a defined time window. Compared to soft real-time operating systems, which allow for a certain delay, the hard real-time operating system requires strict time constraints. If a task is not completed before the deadline, the system will determine it as a critical fault, trigger an interrupt to forcibly terminate the faulty task, and initiate a preset recovery process, such as restarting the task or calling an emergency handling program. In this application, the hard real-time operating system is the NECRO Industrial Real-Time Operating System.

[0051] The hard real-time operating system is based on a multi-master controller 1, slave 3 and MAC network card 4, and establishes communication paths between each master station 2 and slave station 3.

[0052] The highest priority is set for each master station 2 process. This highest priority setting ensures that the master station 2 process can obtain the resources of the multi-core processor 11 even when the system is busy, reducing task execution delay. This scheduling strategy ensures that time synchronization messages can be processed in the first time, avoiding time synchronization delay caused by other regular tasks occupying the resources of the multi-core processor 11, thereby improving the timeliness and accuracy of time synchronization of multiple master stations 2.

[0053] Priority refers to a hierarchical parameter used to determine the order of execution in resource allocation or task processing. In this application, the priority range of the NECRO industrial real-time operating system is 0-99, and the priority of the master station 2 process is set to 90.

[0054] Configure network parameters for time synchronization between the two master stations. These parameters include synchronization frequency, time deviation, and timeout. Synchronization frequency refers to the trigger interval for periodic tasks or data synchronization operations, directly affecting the system's response speed to change events. High-frequency synchronization (e.g., Ti≤10ms) can quickly capture data updates, reducing the risk of state lag and is suitable for high real-time scenarios such as industrial control. Time deviation refers to the offset between the actual synchronization time and the ideal time reference, which needs to be calibrated using a clock synchronization protocol (e.g., NTP, PTP). Timeout is the maximum allowed duration threshold for synchronization operations; exceeding this threshold results in failure and triggers a recovery process. Setting a timeout threshold (e.g., TCP retransmission timeout) in network communication balances latency and reliability, preventing infinite waiting.

[0055] In some embodiments, each master station 2 initiates a time synchronization task every 1ms, the time synchronization task including:

[0056] The master station 2, which initiates the time synchronization task, generates a time synchronization message containing a local timestamp. Due to the high priority of the master station 2 process, this time synchronization message can be quickly sent to the receiving master station 2. When the receiving master station 2 receives the time synchronization message, the interrupt controller triggers a hardware interrupt. After receiving the interrupt signal, the multi-core processor 11 pauses its current task, saves its context, and the time synchronization task preempts the current task. The receiving master station 2 calculates the time deviation between its local time and the timestamp in the time synchronization message based on the time synchronization message, and adjusts its local clock according to the time deviation. After the time synchronization task is completed, it restores the context to the multi-core processor 11 and continues to execute the original task.

[0057] The interrupt controller is an independent hardware module in the computer system, existing as a dedicated chip or integrated within the processor. The interrupt controller's register set supports dynamic configuration of interrupt triggering modes, target kernels, and priorities. The hard real-time operating system accesses registers through memory mapping, thus binding the interrupt service routine to the hardware. In this application, the interrupt controller triggers interrupts by configuring peripheral interrupt sources and priorities, while preserving the context environment. After the interrupt is completed, the original environment continues to run.

[0058] If receiving master station 2 is performing a routine data processing task and receives a time synchronization message, the interrupt response mechanism quickly preempts the current task, causing the system to enter the time synchronization task processing flow. This preemptive mechanism enables the processing of time synchronization messages in an extremely short time. Combined with the microsecond-level operating system jitter characteristics of a hard real-time operating system, it greatly reduces errors in the time synchronization process, achieving nanosecond-level time synchronization accuracy between master stations 2.

[0059] In some embodiments, at least one master station among multiple master stations is set as a time synchronization master station, and only the time synchronization master station starts a time synchronization task once every preset time interval.

[0060] In some embodiments, each master station 2 initiates a data synchronization task every 1ms. The data synchronization task includes the master station 2 initiating the task acquiring access permissions to the shared data area through an atomic access mechanism. The atomic access mechanism treats the shared data area as an indivisible whole. When a master station sends a request for access permissions, if the access permissions are idle, they are immediately acquired; otherwise, the master station must wait for the access permissions to be released. The master station 2 initiating the data synchronization task acquiring access permissions to the shared data area through the atomic access mechanism includes determining whether the shared data area is being used by other master stations 2. If the shared data area is being used by other master stations 2, the master station 2 initiating the data synchronization task requests access permissions to the shared data area at preset time intervals until successful acquisition. After acquiring access permissions, the master station 2 initiating the data synchronization task updates the data in the shared data area and generates a new data version number. Once the data update in the shared data area is complete and a new data version number is generated, the master station 2 initiating the data synchronization task releases the access permissions.

[0061] The shared data area is a centralized data storage area jointly accessed by the master station 2 and the child nodes. It supports the master station 2 in efficiently distributing updated content to each child node and ensures data consistency, security, and availability. In this application, the shared data area is used to enable data sharing among several master station 2 processes within the multi-master station controller 1.

[0062] After the data update is complete and a new data version number is generated, the master station 2 that initiated the data synchronization task releases its access permissions. The hard real-time operating system uses a data change notification mechanism to send a data update notification to the receiving master station 2. That is, the hard real-time operating system immediately notifies other master stations to acquire access permissions via a semaphore. The semaphore uses a built-in permission counter (the initial value is usually the maximum concurrency of the resource) to quantitatively manage access permissions. When the master station 2 that initiated the data synchronization task releases its permissions, it executes the `release()` operation, atomically incrementing the counter value, triggering the receiving master station 2 to compete for permissions through the `acquire()` operation. After the master station 2 that initiated the data synchronization task releases its permissions, if there is a receiving master station 2 in the waiting queue that is blocked by executing `acquire()`, the semaphore will immediately wake up the receiving master station 2 and allocate resources. If there are no waiting stations, the counter continues to increment until the receiving master station 2 initiates a request.

[0063] When receiving master station 2 receives a data update notification, it obtains access permissions to the shared data area through an atomic access mechanism. This includes determining whether the shared data area is being used by other master stations 2. If the shared data area is being used by other master stations 2, receiving master station 2 requests access permissions to the shared data area at preset time intervals until it successfully obtains access permissions. Then, receiving master station 2 updates its local data version number according to the new data version number in the data update notification, thus completing data synchronization.

[0064] The atomic access mechanism ensures the uninterruptibility of operations within a single instruction cycle through CPU atomic instructions, guaranteeing that the operation is either fully executed or not executed at all. This atomic access mechanism effectively avoids the overhead caused by process context switching and is suitable for scenarios with short data operation times and high real-time requirements. Due to the high efficiency of the hardware-based operating system, the time that master station 2 waits to acquire data access permissions is extremely short, thus ensuring the independence of data operations and preventing data conflicts caused by multiple master stations 2 operating on the same data simultaneously.

[0065] It should be noted that during the process of obtaining access to the shared data area through the atomic access mechanism, when the shared data area is used by other master stations 2, the master station 2 that wants to obtain access requests to the shared data area at preset time intervals. Due to the high efficiency of the hardware operating system, the time that the master station 2 waits to obtain access to the shared data area is extremely short.

[0066] When the master station 2 updates the data in the shared data area, the receiving master station 2 is included in the waiting queue for the data update notification. The waiting queue for the data update notification is set with a hard time limit to ensure that the data update notification is delivered to the receiving master station 2 within the deadline.

[0067] In some embodiments, at least one master station among multiple master stations is set as a data synchronization master station, and only the data synchronization master station starts a data synchronization task once every preset time interval.

[0068] By combining the data change notification mechanism with the atomic access mechanism, data synchronization between multiple master stations can be achieved efficiently, ensuring that each master station can obtain the latest data in a timely and accurate manner when data changes, thus guaranteeing data consistency.

[0069] Through the above technical solution, this method triggers a hardware interrupt via the interrupt controller when the time synchronization task is started. Relying on the preemption mechanism of the hard real-time operating system, the time synchronization task preempts the currently low-priority task, endowing it with the ability to execute stably in complex system environments. Even under complex conditions such as high load and network fluctuations, the time synchronization task can always prioritize acquiring system resources, ensuring the accuracy and continuity of time synchronization. This fully meets the near-stringent synchronization accuracy requirements of application scenarios such as robot collaboration and ultra-precision multi-arm collaborative industrial processing, providing a solid guarantee for the precise collaborative execution of complex tasks.

[0070] This application also discloses a multi-master station synchronization device, including:

[0071] The multi-master configuration module is used to set the priority of each master process and configure the network parameters for time synchronization between master stations.

[0072] The time synchronization task generation module is used to preset the master station to start a time synchronization task at a preset time interval. The time synchronization task includes the master station that starts the time synchronization task generating a time synchronization message and sending it to the receiving master station.

[0073] The time synchronization task response module is used to receive the master station's time synchronization message, trigger a hardware interrupt, receive the master station's execution of the time synchronization task, receive the master station's calculation of the time deviation based on the time synchronization message, and adjust the local clock based on the time deviation.

[0074] The data synchronization task generation module is used to preset the master station to start a data synchronization task at a preset time interval. The data synchronization task includes the master station that starts the data synchronization task updating the data in the shared data area and sending a data update notification to the receiving master station.

[0075] The data synchronization task response module is used to receive data update notifications from the main station, access the shared data area, and obtain the latest data.

[0076] This application also discloses a storage medium, which is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a multi-core processor, it implements the above-described multi-master station synchronization method.

[0077] Specific embodiments have been used to illustrate the principles and implementation methods of this invention. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.

Claims

1. A multi-master station synchronization method for performing synchronization tasks for multiple master stations, characterized in that, Includes the following steps: Set priorities for each master station process and configure network parameters for time synchronization between master stations; Each master station initiates a time synchronization task at a preset time interval. The time synchronization task includes the master station that initiates the time synchronization task generating a time synchronization message and sending it to the receiving master station. After receiving the time synchronization message, the receiving master station triggers a hardware interrupt, executes the time synchronization task, calculates the time deviation based on the time synchronization message, and adjusts the local clock according to the time deviation. Each master station initiates a data synchronization task at a preset time interval. The data synchronization task includes the master station that initiates the data synchronization task updating the data in the shared data area and sending a data update notification to the receiving master station. The receiving master station accesses the shared data area based on the data update notification to obtain the latest data. The steps to initiate a data synchronization task on the main site include updating the data in the shared data area, including: The master station that initiates the data synchronization task acquires access permissions to the shared data area through an atomic access mechanism. After acquiring access permissions, the master station that initiated the data synchronization task releases the access permissions only after the data in the shared data area has been updated. When the master station that initiates the data synchronization task updates the data in the shared data area, the receiving master station is included in the waiting queue for the data update notification. The waiting queue for the data update notification is set with a hard time limit. The atomic access mechanism includes: Determine whether the shared data area is being used by the receiving master station. If the shared data area is being used by other stations, the master station that initiates the data synchronization task requests access to the shared data area at preset time intervals until it successfully obtains access. The steps to send data update notifications to the receiving master station include: The data change notification mechanism is used to send data update notifications to the receiving master station. When the master station that started the data synchronization task releases the access permission, it immediately notifies the receiving master station to obtain the access permission through a semaphore. The steps for receiving data update notifications from the main station and accessing the shared data area include: The receiving master station obtains access permissions to the shared data area through an atomic access mechanism; The steps involve the master station initiating a data synchronization task updating the data in the shared data area and sending a data update notification to the receiving master station. The receiving master station then accesses the shared data area based on the data update notification to obtain the latest data, including: After the master station initiates the data synchronization task, it updates the data in the shared data area and generates a new data version number; the new data version number is included in the data update notification sent to the receiving master station; the receiving master station updates its local data based on the new data version number in the data update notification; The master station is an EtherCAT master station; the network parameters for time synchronization between master stations include synchronization frequency, time deviation, and timeout.

2. A multi-master station synchronization device, applied in the multi-master station synchronization method as described in claim 1, characterized in that, include: The multi-master configuration module is used to set the priority of each master process and configure the network parameters for time synchronization between master stations. A time synchronization task generation module is used to preset the master station to start a time synchronization task at a preset time interval. The time synchronization task includes the master station that starts the time synchronization task generating a time synchronization message and sending it to the receiving master station. The time synchronization task response module is used to receive the master station's time synchronization message, trigger a hardware interrupt, receive the master station's execution of the time synchronization task, receive the master station's calculation of the time deviation based on the time synchronization message, and adjust the local clock based on the time deviation. The data synchronization task generation module is used to preset the master station to start a data synchronization task at a preset time interval. The data synchronization task includes the master station that starts the data synchronization task updating the data in the shared data area and sending a data update notification to the receiving master station. The data synchronization task response module is used to receive data update notifications from the main station, access the shared data area, and obtain the latest data.

3. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a multi-core processor, it implements the multi-master station synchronization method as described in claim 1.

Citation Information

Patent Citations

  • Database accessing method and device and system

    CN102156700A

  • Multi-master station and multi-master station creation method

    CN117336114A

  • Hybrid real-time task scheduling method and system, storage medium and terminal

    CN118733220A