Synchronization method and device for time synchronization of network system
By sending dynamic compensation synchronization frames and calculating timestamps in the network system, the problem of large clock synchronization errors under dynamic jitter is solved, achieving nanosecond-level stable synchronization, which is suitable for precision manufacturing and power control.
Patent Information
- Application Number
- CN202511775779.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-03-03
AI Technical Summary
Existing technologies suffer from excessive clock synchronization errors in network systems when faced with dynamic jitter, which affects timing consistency and system reliability in industrial automation systems.
The master station sends dynamic compensation synchronization frames to the slave station, records the compensation sending and receiving timestamps, and calculates the dynamic compensation time information by parsing the TYPE type field and CMD command field. Combined with the fixed link delay and compensation calculation formula, the clock synchronization of the master and slave devices is achieved.
It achieves nanosecond-level stable synchronization when faced with dynamic jitter, eliminates delay jitter, and improves synchronization accuracy, making it suitable for high-precision collaborative scenarios such as precision manufacturing and power control.
Smart Images

Figure CN121603138A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and device for synchronizing time in a network system. Background Technology
[0002] In industrial automation systems, high-precision clock synchronization is a key technological foundation for achieving distributed control, real-time data acquisition, and collaborative operation of multiple devices. It directly determines the timing consistency of task execution and system reliability.
[0003] In related technologies, time synchronization is mainly achieved through message exchange between the master station and the slave station, and the dwell time generated during message transmission is set. However, this scheme sets the dwell time as a fixed time based on the latency measured in the initial interactive phase. Therefore, by forcibly including the dwell time in the overall latency, there is a defect of latency fixation, which leads to excessive errors when facing dynamic jitter.
[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main purpose of this application is to provide a method for synchronizing time in a network system, which aims to solve the technical problem of excessive error when facing dynamic jitter.
[0006] To achieve the above objectives, this application proposes a method for time synchronization in a network system, the method comprising: The master station sends a dynamic compensation synchronization frame to the first slave station in the forward transmission direction, and senses the identification field and records the compensation transmission timestamp at the sending port of the master station. When the first slave station receives the dynamic compensation synchronization frame, it senses and determines the compensation receiving timestamp corresponding to the first slave station at the receiving port by sensing the identification field and parsing the TYPE type field, and records it locally. The first slave station determines the compensation transmission timestamp by sensing the identifier field of the dynamic compensation synchronization frame at the forward transmission port and records it locally; After the first slave station receives the dynamic compensation synchronization frame in the reverse transmission direction, it deletes the compensation receiving timestamp sensed by the reverse transmission and reads and writes the dynamic compensation time information calculated by the compensation receiving timestamp and compensation sending timestamp corresponding to the first slave station into the dynamic compensation synchronization frame by parsing the TYPE type field and CMD command field and according to the corresponding batch write and read method. The dynamic compensation synchronization frame returns the dynamic compensation time information corresponding to the first slave station to the master station. Based on the dynamic compensation time information, the fixed link delay, and the compensation calculation formula, the dynamic compensation values corresponding to the master station and the slave station are calculated, and the dynamic compensation values are written into the local time correction registers of the master station and the corresponding slave station to complete the clock synchronization of the master station and the slave station.
[0007] In one embodiment, the first slave station receives and forwards the dynamic compensation synchronization frame, and each of the downstream slave stations is sequentially connected to the first slave station according to the transmission path in the forward transmission direction; The downstream slave station receives the forward-transmitted dynamic compensation synchronization frame and forwards the dynamic compensation synchronization frame to other slave stations. At the receiving port of the downstream slave station, the identification field of the dynamic compensation synchronization frame is sensed to determine the compensation receiving timestamp corresponding to the downstream slave station. After parsing the TYPE type field of the dynamic compensation synchronization frame, the compensation receiving timestamp is recorded locally, and the compensation sending timestamp is sensed and recorded locally at the sending port of the downstream slave station through the identifier field.
[0008] In one embodiment, after the downstream slave station transmits the dynamic compensation synchronization frame to the last slave station in the forward transmission direction, the downstream slave station transmits the dynamic compensation synchronization frame back in the reverse direction. According to the reverse transmission path, the dynamic compensation synchronization frames are transmitted one by one from the downstream slave station to the first slave station; After each slave station receives the reverse-transmission dynamic compensation synchronization frame, it parses the TYPE type field of the dynamic compensation synchronization frame and deletes the compensation receiving timestamp sensed by the slave station during the corresponding reverse transmission. Based on the batch write / read method corresponding to the TYPE type field and CMD command field, the dynamic compensation time information of each slave station is read and written into the corresponding field of the dynamic compensation synchronization frame.
[0009] In one embodiment, the first slave station transmits the dynamic compensation synchronization frame to the master station along the reverse transmission path; After receiving the dynamic compensation synchronization frame, the master station deletes the compensation reception timestamp sensed during the corresponding reverse transmission.
[0010] In one embodiment, after the master station receives the dynamic compensation synchronization frame returned by the slave station, it parses and extracts the dynamic compensation time information corresponding to each slave station from the corresponding fields of the dynamic compensation synchronization frame, and obtains the compensation receiving timestamp and dynamic dwell time of each slave station. Based on the dynamic dwell time of each slave station, combined with the compensation receiving timestamp corresponding to the first slave station and the link delay fixed during the initial synchronization phase, the backtracking time value of each slave station is calculated. Based on the backtracking time value and compensation receiving timestamp of each slave station, the dynamic compensation value corresponding to the slave station is calculated according to the compensation calculation formula. Based on the compensation sending timestamp sensed by the master station itself and the link delay, the dynamic compensation value corresponding to the master station is calculated according to the formula.
[0011] In one embodiment, the master station corrects its local high-precision clock using a hardware counter based on a corresponding dynamic compensation value, so that the master station's local high-precision clock is aligned with the local high-precision clock of the first slave station. Based on the association between the slave station and its dynamic compensation value, a batch addressing data frame for the dynamic compensation value is generated, and the dynamic compensation value corresponding to each slave station is written into the data field of the batch addressing data frame; After receiving the batch addressing data frame, the slave station writes the corresponding dynamic compensation value in the data field of the batch addressing data frame into the local time correction register, triggers the hardware counter to correct the local high-precision clock, and completes the clock synchronization between the slave station and the first slave station.
[0012] In one embodiment, the master station sends an initial synchronization frame, and at the master station port, the initial sending timestamp corresponding to the master station is determined by sensing the identifier field of the initial synchronization frame; After receiving the initial synchronization frame, the first slave station transmits the initial synchronization frame to the downstream slave station, and the first slave station and the downstream slave station receive and send the initial synchronization frame in the forward transmission and reverse backhaul. The initial reception timestamp is obtained from the receiving port sensing identifier field of each slave station, the TYPE type field of the data frame is parsed and the initial reception timestamp is recorded, and the initial transmission timestamp is obtained from the sending port sensing identifier field of each slave station and recorded locally. After the last downstream slave station in the forward transmission direction sends the initial synchronization frame back to the master station, the master station receives the initial synchronization frame and senses the initial receiving timestamp corresponding to the master station at the receiving port of the master station.
[0013] In one embodiment, after the master station sends the initial follow frame, each slave station senses the identification field at the corresponding receiving port when transmitting the initial follow frame in the forward direction, determines the initial receiving timestamp corresponding to the slave station, and deletes the initial receiving timestamp after parsing the TYPE type field of the data frame. Each slave station parses the TYPE field and CMD command field of the initial follow frame, and completes the read and write operations of the initial synchronization time information and the initial follow frame corresponding to the slave station through the corresponding batch write and read. After reaching the last downstream slave station in the forward transmission, the initial follow frame is transmitted in reverse to the master station. Based on the initial follow frame received by the master station, and the initial synchronization time information in the initial follow frame, the fixed link delay and initial time deviation are calculated.
[0014] In one embodiment, the master station sends the initial time deviation to each of the slave stations, and corrects the local high-precision clock corresponding to each of the slave stations using the initial time deviation; Meanwhile, the master station stores the link delay in a fixed value in the relevant register of the master station.
[0015] In addition, to achieve the above objectives, this application also proposes a network system time synchronization device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the network system time synchronization method described above.
[0016] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the network system time synchronization method described above.
[0017] This application provides a network system time synchronization method, including a master station sending a dynamic compensation synchronization frame to at least one slave station and recording the compensation transmission timestamp in the frame's identifier field at its own transmission port. When a slave station receives and forwards a dynamic compensation synchronization frame in the forward transmission direction, it determines the corresponding compensation reception timestamp and compensation transmission timestamp at its port by sensing the same identifier field. When a slave station recognizes a reverse-transmission dynamic compensation synchronization frame, it triggers the calculation of each dynamic compensation time information based on the sensed timestamp and reads and writes it to the corresponding field of the frame. The master station aggregates the dynamic compensation time information of each slave station through the reverse-transmission dynamic compensation synchronization frame, and calculates the dynamic compensation value corresponding to the master and slave devices by combining the fixed link delay in the initial synchronization stage with a dedicated compensation calculation formula. Finally, the master station uses this value to correct its local high-precision clock and writes the compensation value into the slave station's local time correction register through batch addressing data frames, thus completing system-level clock synchronization. This application overcomes the accuracy degradation problem caused by fixed processing dwell time in the fast addressing mode, achieves nanosecond-level stable synchronization under disturbances such as industrial temperature drift and network congestion, and eliminates the delay jitter caused by slave station actively sending messages, providing underlying guarantee for high-precision collaborative scenarios such as precision manufacturing and power control.
[0018] In summary, this application, by designing corresponding synchronization data frames and their corresponding interaction logic, eliminates the need for slave stations to actively send synchronization messages. Drawing on the PTP protocol, it constructs a clock synchronization method for master-slave systems based on dynamically compensated time information. Without using store-and-forward methods and without slave stations actively sending messages, it removes the jitter effect of dwell time and improves synchronization accuracy. Attached Figure Description
[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating the first embodiment of the network system time synchronization method of this application; Figure 2 This is a diagram showing the encapsulation structure of the clock synchronization frame in this application; Figure 3 This is a diagram showing the encapsulation structure of a conventional instruction-type bulk addressing data frame in this application; Figure 4 This is a timing diagram for the initial synchronization phase of this application; Figure 5 This is a schematic diagram of the time synchronization device in the network system of this application.
[0022] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0023] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0024] In related technologies, time synchronization is mainly achieved through message exchange between the master and slave stations, and the dwell time generated during message transmission is set. However, this scheme sets the dwell time as a fixed value based on the delay measured during the initial synchronization phase. Therefore, by forcibly including the dwell time in the overall delay, there is a defect of fixed delay, which leads to excessive errors when facing dynamic jitter.
[0025] This application provides a solution: First, the master station sends a dynamic compensation synchronization frame to the slave station in the forward transmission direction. The master station senses an identifier field at its transmission port and records the compensation transmission timestamp. Then, the slave station determines the compensation transmission timestamp at its forward transmission port by sensing the identifier field of the dynamic compensation synchronization frame and records it locally. When the slave station receives the dynamic compensation synchronization frame in the reverse transmission direction, it deletes the compensation reception timestamp sensed in the reverse transmission. It then parses the TYPE field and CMD command field, and reads and writes the dynamic compensation time information calculated from the compensation reception timestamp and compensation transmission timestamp corresponding to the slave station into the dynamic compensation synchronization frame according to the corresponding batch write / read method. The dynamic compensation synchronization frame then returns the dynamic compensation time information corresponding to the slave station to the master station. Finally, based on the dynamic compensation time information, the fixed link delay, and the compensation calculation formula, the dynamic compensation values corresponding to the master station and the slave station are calculated and written into the local time correction registers of the master station and the corresponding slave station, completing the clock synchronization between the master station and the slave station.
[0026] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or network system time synchronization device capable of performing the above functions. The following description uses a network system time synchronization device as an example to illustrate this embodiment and the subsequent embodiments.
[0027] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0028] This application provides a method for time synchronization in a network system, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the network system time synchronization method of this application.
[0029] In this embodiment, the network system time synchronization method includes steps S10 to S60: Step S10: The master station sends a dynamic compensation synchronization frame to the first slave station in the forward transmission direction, and senses the identification field at the sending port of the master station and records the compensation sending timestamp.
[0030] In this embodiment, the master station is the core device that initiates clock synchronization and sends dynamic compensation synchronization frames. The first slave station is the first slave device to receive the dynamic compensation synchronization frame sent by the master station in the forward transmission direction. The dynamic compensation synchronization frame is a synchronization message carrying time sensing information and used to implement dynamic clock compensation, including functional fields such as the TYPE type field and the CMD command field. The forward transmission direction is the basic transmission direction for the master station to send data frames to the slave station. The master station's sending port is the physical interface used by the master station to send dynamic compensation synchronization frames. The identification field is a feature field in the dynamic compensation synchronization frame used to trigger time sensing and distinguish frame types, and can be a preamble, an Ethertype type field, a TYPE type field, etc. The structure of the dynamic compensation synchronization frame sent by the master station is as follows: Figure 2 As shown, Figure 2 This is a diagram illustrating the encapsulation structure of the clock synchronization frame in this application. The field parsing of the PDU area is shown in Table 1, where the TYPE field of the data frame is configured as a dynamic compensation synchronization frame. The compensation transmission timestamp is the time information recorded by the master station when transmitting the dynamic compensation synchronization frame, indicating the actual transmission time of the frame.
[0031] Table 1. Fields and contents of the clock synchronization frame sub-message PDU
[0032] As an optional implementation, the master station first constructs a dynamic compensation synchronization frame, integrating core components such as the Ethernet frame header, Head field, and PDU area. It then configures the transmission parameters of its own transmitting port to adapt to the requirements of the forward transmission link. Simultaneously, it activates the identification field sensing module at the transmitting port, which pre-loads the feature sequence of the identification field of the dynamic compensation synchronization frame to prepare for identification. Next, the master station initiates the forward transmission process, loading the constructed dynamic compensation synchronization frame into the transmission buffer of the transmitting port. As the buffer begins pushing frame data to the link, the sensing module monitors the frame transmission status in real time. Once it detects the complete feature sequence of the identification field passing through the transmitting port, it immediately triggers the timestamp acquisition mechanism, retrieving real-time time data from the local high-precision clock module and accurately writing this data into the master station's system forward transmission time register, completing the recording of the compensation transmission timestamp. This method ensures that the sensing module and the transmission process are prepared in advance, resulting in strong synchronization between timestamp acquisition and frame transmission actions, and extremely low acquisition latency.
[0033] As an alternative implementation, the master station first parses the complete structure of the dynamic compensation synchronization frame, clarifying the positional distribution and characteristic rules of the identification field within the frame. Based on these rules, it configures the sensing trigger conditions for the sending port, including the detection priority and recognition threshold of the identification field. Then, all data of the dynamic compensation synchronization frame is formatted according to the transmission protocol requirements to ensure that the frame data conforms to the forward transmission link specifications. Afterward, the format-converted dynamic compensation synchronization frame data is pushed to the sending port, and the identification field detection program is initiated. Once the module captures the key feature fragments of the identification field and completes verification, it immediately initiates the timestamp recording process, collecting the current local high-precision clock time information, adapting the format, and writing it to the corresponding storage register to complete the recording of the compensation transmission timestamp. This method, by pre-parses the frame structure and configures the trigger conditions, can adapt to dynamic compensation synchronization frames of different formats, exhibiting strong compatibility.
[0034] In step S20, the first slave station receives the dynamic compensation synchronization frame, and through sensing the identification field and parsing the TYPE type field, it senses and determines the compensation receiving timestamp corresponding to the first slave station at the receiving port and records it locally.
[0035] In this embodiment, the sensing identifier field is the operation of detecting and capturing the identifier field characteristics in the dynamic compensation synchronization frame. The receiving port of the first slave station is the physical interface used by the first slave station to receive the dynamic compensation synchronization frame. The compensation reception timestamp is the time information recorded when the first slave station senses the dynamic compensation synchronization frame at the receiving port, indicating the moment the frame is received. Recording locally involves storing the compensation reception timestamp in the corresponding system forward receive register of the first slave station.
[0036] As an optional implementation, upon detecting the arrival of a dynamic compensation synchronization frame at the receiving port of the first slave station, the identification field sensing module at the port is immediately activated. This module scans the identification field feature sequence in the frame data in real time. When the complete identification field feature is captured and matched with the pre-stored dynamic compensation synchronization frame identification, real-time time data from the local high-precision clock is acquired. Then, the TYPE type field parsing process is initiated, extracting the TYPE type field content according to the frame structure definition and identifying it as the type corresponding to the dynamic compensation synchronization frame. Upon confirming the validity of the TYPE type field, the data is converted to the format stored in the adaptation register and written to the system's forward receiving time register, completing the determination and local recording of the compensation receiving timestamp. This method first quickly locks the target frame through the identification field, and then parses the TYPE type field to verify its validity, which can improve the accuracy of data frame sensing, reduce the impact of jitter within the system, and achieve high processing efficiency.
[0037] As an alternative implementation, after the first slave station receiving port receives the dynamic compensation synchronization frame, it first activates the field parsing module to extract the TYPE type field according to the frame structure order. The field content is compared with a pre-stored list of frame types. Once the type is confirmed to be the frame type it needs to process, the receiving port's identifier field sensing unit is activated, and the sensing trigger condition is configured as the core feature fragment of the identifier field. Then, when the sensing unit detects an identifier field feature in the frame data that meets the conditions, it immediately sends a time acquisition request to the local high-precision clock module. The current time information returned by the local high-precision clock module is verified and stored in the corresponding system forward receiving time register, completing the determination and recording of the compensation receiving timestamp. This method first verifies the TYPE type field, avoiding time sensing operations on non-target type frames, resulting in low resource consumption and accurate focus on the target frame for timestamp recording.
[0038] In step S30, the first slave station determines the compensation transmission timestamp by sensing the identifier field of the dynamic compensation synchronization frame at the forward transmission port and records it locally.
[0039] In this embodiment, the sending port corresponding to the first slave station is the physical interface used by the first slave station to forward the dynamic compensation synchronization frame. The compensation sending timestamp is the time information recorded by the first slave station at the sending port when forwarding the frame, indicating the actual time of frame transmission.
[0040] As an optional implementation, before forward transmission, the first slave station activates the identification field sensing module at the transmitting port, loads the complete feature sequence of the identification field of the dynamic compensation synchronization frame to complete calibration, and simultaneously binds the storage address of the system forward transmission time register to the sensing module. Subsequently, preparation for forwarding the dynamic compensation synchronization frame is initiated. When frame data is pushed to the link, the sensing module monitors the frame transmission status in real time, captures the moment the feature sequence of the identification field passes through the transmitting port, immediately collects the real-time time data of the local high-precision clock, and directly writes it into the bound system forward transmission time register, completing the determination and local recording of the compensation transmission timestamp. This method features a pre-calibrated sensing module bound to the register, resulting in strong synchronization between timestamp acquisition and frame transmission, and low latency.
[0041] As an alternative implementation, the first slave station first parses the structure of the dynamic compensation synchronization frame, clearly defining the starting position and characteristic rules of the identifier field within the frame, and configuring the sensing trigger threshold of the sending port based on these rules. Subsequently, it performs format verification of the frame data to ensure compliance with the forward transmission link requirements, pushes the verified frame data to the sending port, and simultaneously initiates the identifier field detection process. Once the core feature fragment of the identifier field in the frame data is detected and verified, a collection command is sent to the local high-precision clock module. The returned time information is received, format adapted, and stored in the corresponding system forward transmission time register, completing the determination and recording of the compensation transmission timestamp. This method, by pre-parses the frame structure and configures the trigger conditions, can adapt to different formats of dynamic compensation synchronization frames, exhibiting strong compatibility.
[0042] Step S40: After the first slave station receives the dynamic compensation synchronization frame in the reverse backhaul direction, it deletes the compensation receiving timestamp sensed by the reverse backhaul, and reads and writes the dynamic compensation time information calculated by the compensation receiving timestamp and compensation sending timestamp corresponding to the first slave station into the dynamic compensation synchronization frame by parsing the TYPE type field and CMD command field according to the corresponding batch write-read method.
[0043] In this embodiment, the reverse transmission direction is the transmission direction of the dynamic compensation synchronization frame from the slave station to the master station. The TYPE type field is a feature field in the frame that distinguishes the frame type. The CMD command field is a function field in the frame that indicates the batch write / read operation instruction. The batch write / read mode is an operation form that performs content interaction between the locally pointed-to data information and the specified message field according to the requirements of the mapping table between the message field of the corresponding batch write / read mode under the frame type corresponding to the TYPE type field and the CMD command field and the register physical area. The dynamic compensation time information is the time data calculated by the compensation reception timestamp and the compensation transmission timestamp of the first slave station itself.
[0044] As an optional implementation, after the first slave station receives the dynamic compensation synchronization frame in the reverse transmission direction, it immediately senses the compensation reception timestamp corresponding to the reverse transmission. Then, it initiates a field parsing process, extracts the TYPE field from the frame to confirm it is a dynamic compensation synchronization frame type, and clears the sensed timestamp. The CMD command field is parsed to determine the corresponding batch write / read instruction. Next, the self-compensation reception timestamp and compensation transmission timestamp stored in the local register are retrieved to calculate the dynamic compensation time information. According to the batch write / read method specified by the TYPE field and CMD command field, this information is written into the preset data field of the dynamic compensation synchronization frame in one go, according to the mapping table between the message field and the register physical area of the batch write / read method corresponding to the dynamic compensation synchronization frame type, while simultaneously marking the write completion status. This method performs deletion actions beforehand, avoids redundant data interference, completes batch write / read in one go, and has a simple process.
[0045] As an alternative implementation, after the first slave station receives the reverse-transmission dynamic compensation synchronization frame, it first extracts the TYPE type field and CMD command field from the frame. The TYPE type field is parsed to verify the frame's validity. If the verification passes, the compensation reception timestamp during the reverse transmission is no longer sensed. The CMD command field is parsed to determine the addressing rules and data format requirements for batch write / read. Subsequently, the system retrieves its own compensation reception timestamp and compensation transmission timestamp to calculate the dynamic compensation time information. According to the batch write / read addressing rules specified in the CMD command field, and based on the mapping table between the message field and register physical area of the batch write / read method corresponding to the dynamic compensation synchronization frame type, information is exchanged in batches to the corresponding data segment of the frame. After each batch is written, data integrity is verified. Once all data is written without errors, the frame's status flag is updated. This method, which parses and verifies before execution, offers high data security, and the batch writing and verification process provides strong fault tolerance.
[0046] In step S50, the dynamic compensation synchronization frame returns the dynamic compensation time information corresponding to the first slave station to the master station.
[0047] In this embodiment, the dynamic compensation time information corresponding to the first slave station is the time data calculated by the first slave station through its own compensation receiving timestamp and compensation sending timestamp.
[0048] As an optional implementation, after receiving the frame header of the data frame, the first slave station activates the sending port in the reverse transmission direction, configures the link transmission parameters to adapt to the master station's receiving specifications, and immediately pushes the data frame along the reverse transmission path after completing the read and write operations of each field until the frame is sent. Simultaneously, the port transmission status is monitored to confirm the frame data transmission progress in real time, and the dynamic compensation time information is returned to the master station. This method has a direct transmission flow, no additional intermediate processing steps, and short processing time; its effect is to quickly complete the time information return.
[0049] Step S60: Based on the dynamic compensation time information, fixed link delay, and compensation calculation formula, calculate the dynamic compensation values corresponding to the master station and the slave station, and write the dynamic compensation values into the local time correction registers of the master station and the corresponding slave station to complete the clock synchronization of the master station and the slave station.
[0050] In this embodiment, the fixed link delay is the fixed time consumed for data transmission between the master station and the slave station, which is pre-stored after initial calibration. The compensation calculation formula is a preset logical rule used to calculate the compensation value by combining dynamic compensation time information and fixed link delay. The dynamic compensation value is the specific value used to adjust the clocks of the master station and the slave station to achieve synchronization. The local time correction register is a dedicated storage area in the master station and the slave station used to store the dynamic compensation value and trigger clock calibration. Clock synchronization is the process of adjusting the time of the master station and the slave station through the dynamic compensation value to keep their times consistent.
[0051] As an optional implementation, the master station first aggregates the dynamic compensation time information returned by all slave stations, retrieves the pre-stored fixed link delay, and, following the preset steps of the compensation calculation formula, sequentially substitutes the two types of data into the calculation to gradually derive the dynamic compensation values for the master station itself and each corresponding slave station. Then, it directly locates the local time correction register addresses of the master station and each slave station, and writes the corresponding dynamic compensation values into the local time correction registers all at once using batch addressing instructions. After the write operation is completed, the registers automatically trigger a clock calibration mechanism, adjusting the local high-precision clock according to the stored compensation values to complete the clock synchronization between the master station and the slave stations. This method has a simple and direct calculation and writing process, without additional verification steps, and high processing efficiency.
[0052] As an alternative implementation, the master station first performs integrity verification on the dynamic compensation time information of each slave station, eliminating data with abnormal formats or logical contradictions. Then, it retrieves the fixed link delay and matches it with the verified valid time information. Following the hierarchical calculation logic of the compensation formula, data calculation is completed in stages, with each stage's results cross-verified. Once confirmed to be error-free, the results are aggregated to generate dynamic compensation values for both the master station and each slave station. Subsequently, the dynamic compensation values are sorted by slave station address and written to the local time correction register of the corresponding slave station in batches, while simultaneously being written to the master station's own register. The storage status of the registers is verified after each batch of writing. Once the data writing is confirmed to be error-free, clock calibration of the corresponding device is triggered until all devices have completed adjustment and clock synchronization is achieved. This method, with its multi-round verification and batch writing, avoids invalid data and writing errors, resulting in high reliability.
[0053] For example, refer to Figure 2 , Figure 2 This is a diagram showing the encapsulation structure of the clock synchronization frame in this application. The master station generates a dynamic compensation synchronization frame Sync_dcom with the type identifier field set to 0x3. At the master station's transmission port, a preamble identifier is sensed and the compensation transmission timestamp Mastertimestamp is recorded. The frame structure conforms to... Figure 2 The defined encapsulation format. After the slave station receives the frame transmitted in the forward direction, it triggers the receiving port to sense the compensation receiving timestamp. At the media access control layer chip, the TYPE type field is parsed as 0x3, which corresponds to a dynamic compensation synchronization frame. The compensation receiving timestamp Rx_timestamp is recorded in the system forward receiving time register, and the compensation sending timestamp Tx_timestamp is sensed and sent in the system forward sending time register. When the slave station recognizes the dynamic compensation follow-up frame during the reverse transmission, it calculates the relevant dynamic compensation time information using the compensation receiving timestamp and the compensation receiving timestamp stored in the local register. ; ; ; In the formula and Compensation sending and compensation receiving timestamps sensed during positive message transmission; and These are the compensated send and receive timestamps sensed during reverse message transmission; both are 0 during the reverse transmission of the Sync_dcom frame. The compensated receive timestamp sensed during forward transmission is written to the Timestamp1 field of this frame, and the calculated... The value is written to the correction field of the frame. , The field is left blank for future reference. The master station parses the returned dynamic compensation synchronization frame, aggregates the dynamic compensation time information from the correction field fields of each slave station, and combines it with the fixed link delay during the initial synchronization phase. The backtracking time fusion mechanism in the compensation calculation formula: .
[0054] Calculate the main station compensation value Compensation value from slave station : ; ; Where in the formula The timestamp sensed when the master station sends a Sync_dcom frame. The correction field of the message stores the dwell time of each slave station; The reference Rx_timestamp sensed by the first slave station connected to the master station; When the nth slave station receives the Sync_dcom frame, backtrack the running time of the reference clock at that time; Rx_timestamp is the local high-precision clock running time when the nth slave station receives the Sync_dcom frame, which is the compensated receive timestamp.
[0055] The main site will Write to the local time correction register. Simultaneously construct a regular instruction-type bulk addressing data frame, referring to... Figure 3 As shown, Figure 3 This is a diagram illustrating the encapsulation structure of a conventional instruction-based bulk addressing data frame in this application. In this data frame, the TYPE field is 0, the CMD command field represents the bulk write operation instruction, the ADO address field maps to the physical address of the slave's local time correction register, and ADP represents the number of slaves to be operated on. The Area region in the DATA field is written sequentially according to the connection order between the slaves and the master in the forward transmission direction. The value will be automatically transferred after being received by the slave station. Write to the corresponding register and trigger the hardware counter to correct the local high-precision clock.
[0056] By employing a dynamic compensation time information separation mechanism and a passive response architecture, the system solves the problem of synchronization accuracy degradation caused by fixed processing dwell time under the fast addressing method, as well as the additional latency jitter caused by store-and-forward dependency, providing reliable underlying synchronization support for high-precision industrial collaborative scenarios such as precision manufacturing and smart grids.
[0057] Based on any of the above embodiments, in Embodiment 2 of this application, after step S10, steps A11 to A13 are further included: Step A11: The first slave station receives and forwards the dynamic compensation synchronization frame, and each of the downstream slave stations is connected to the first slave station in sequence according to the transmission path in the forward transmission direction.
[0058] In this embodiment, the downstream slave station is a slave device located after the first slave station that receives the frame along the forward path. The transmission path is a preset device connection order that guides the sequential transmission of frames. Connecting sequentially to the first slave station means that each downstream slave station establishes a connection with the first slave station and subsequent slave stations according to the transmission path order.
[0059] As an optional implementation, the first slave station pre-retrieves and stores the complete forward transmission path, specifying the connection order and interface information of each downstream slave station. Upon receiving the dynamic compensation synchronization frame, it immediately parses the frame's transmission identifier to confirm that it meets the forward forwarding requirements. Then, it locates the corresponding connection interface of the first downstream slave station in the path, configures the interface transmission parameters, and directly pushes the frame data to that downstream slave station. After receiving the frame, the first downstream slave station locates the next downstream slave station according to the pre-stored path, repeating the forwarding operation until all downstream slave stations receive the dynamic compensation synchronization frame in sequence. This method has a direct forwarding logic, requires no additional verification process, and has high transmission efficiency.
[0060] Step A12: The downstream slave station receives the forward-transmitted dynamic compensation synchronization frame and forwards the dynamic compensation synchronization frame to other slave stations. The downstream slave station senses the identification field of the dynamic compensation synchronization frame at its receiving port and determines the compensation receiving timestamp corresponding to the downstream slave station.
[0061] In this embodiment, the receiving port of the downstream slave station is its physical interface used to receive the frame. The identification field is a feature field in the frame that triggers the time sensing and distinguishes the frame type. The compensation receiving timestamp corresponding to the downstream slave station is the receiving time information recorded by the downstream slave station when it senses the frame at the receiving port.
[0062] As an optional implementation, after the downstream slave station's receiving port detects a forward-transmitted dynamic compensation synchronization frame, it immediately activates the identifier field sensing module at the port. This module scans the identifier field feature sequence in the frame data in real time. After matching it with the pre-stored dynamic compensation synchronization frame identifier features, it triggers a timestamp acquisition mechanism, retrieves the real-time time data from the local high-precision clock, converts the data into a format suitable for the adapter register's storage, and writes it into the system's forward receiving time register to determine the compensation receiving timestamp. Subsequently, it locates the corresponding connection interfaces of other slave stations that need to be forwarded, configures the interface transmission parameters, pushes the frame data to the target other slave stations, and completes the forwarding operation. This method has strong synchronization between timestamp acquisition and frame reception, low latency, and high acquisition accuracy.
[0063] Step A13: After parsing the TYPE type field of the dynamic compensation synchronization frame, the compensation receiving timestamp is recorded locally, and the compensation sending timestamp is sensed and recorded locally at the sending port of the downstream slave station through the identification field.
[0064] In this embodiment, the transmitting port of the downstream slave station is its physical interface used to forward the frame. The compensation transmission timestamp corresponding to the downstream slave station is the transmission time information determined by the downstream slave station after sensing the frame at the transmitting port.
[0065] As an optional implementation, the downstream slave station extracts the TYPE field from the dynamic compensation synchronization frame, parses the field content, and compares it one by one with a pre-stored type list. After confirming that the frame type meets the processing requirements, it retrieves the determined compensation receiving timestamp, converts it to a storage format adapted to the local register, and accurately writes it into the system's forward receiving time register to complete the recording. Subsequently, the transmission configuration process of the sending port is initiated to adapt to the forward transmission link parameters. At the same time, the identification field sensing module at the sending port is activated, and the complete feature sequence of the identification field is loaded to complete the calibration. When frame data is pushed to the link and the identification field passes through the sending port, the sensing module triggers the time acquisition mechanism, retrieves the real-time time data from the local high-precision clock, and writes it into the system's forward sending time register to complete the local recording of the compensation sending timestamp. This method features type verification beforehand, logical coherence between timestamp recording and frame processing, and high accuracy.
[0066] By using a two-level identifier sensing mechanism, the problems of timestamp recording delay and invalid frame processing overhead in traditional clock synchronization technology are solved, thus improving the accuracy of data storage.
[0067] Based on any of the above embodiments, in Embodiment 3 of this application, after step A13, steps B11 to B14 are further included: Step B11: After the downstream slave station transmits the dynamic compensation synchronization frame to the last slave station in the forward transmission direction, the downstream slave station transmits the dynamic compensation synchronization frame back in the reverse direction.
[0068] In this embodiment, the last slave station is the terminal slave device that ultimately receives the frame in the forward transmission path. Reverse transmission is the operation of transmitting the frame from the last slave station back to the master station in the reverse direction of the forward transmission.
[0069] As an optional implementation, the downstream slave station pre-retrieves complete node information of the forward transmission path to determine if there are other slave stations connected to it in the forward transmission path. When receiving and forwarding the dynamic compensation synchronization frame, it compares the current forwarding target slave station with the identifier of the last slave station in the path in real time. Once it confirms that the frame has been transmitted to the last slave station, it immediately stops the forward transmission configuration, switches the transmission direction parameters of the sending port to adapt to the link requirements of the reverse backhaul, pushes frame data according to the sending port of the reverse backhaul path, and starts the reverse backhaul process. This method quickly confirms the destination based on the pre-stored path, starts the backhaul in a timely manner, has a simple process, improves the overall synchronization efficiency, and is suitable for scenarios with fixed paths and clear node identifiers.
[0070] Step B12: According to the reverse transmission path, the dynamic compensation synchronization frames are transmitted one by one from the downstream slave station to the first slave station.
[0071] In this embodiment, sequential transmission is the operation of passing frames one by one to the connected previous slave device in reverse path order.
[0072] As an optional implementation, the downstream slave station pre-retrieves and stores the complete reverse backhaul transmission path, determining the interface addresses and connection order of each front-end slave device along the path. Before initiating reverse backhaul, the corresponding connection interface of the first front-end slave device is located according to the path order, and the interface transmission parameters are configured to adapt to the reverse link requirements. Frame data is pushed to this front-end slave device until the frames are transmitted one by one to the first slave station along the reverse path. This method has a pre-defined path, strong transmission directionality, and requires no additional path exploration.
[0073] Step B13: After each slave station receives the reverse-transmission dynamic compensation synchronization frame, it parses the TYPE type field of the dynamic compensation synchronization frame and deletes the compensation reception timestamp sensed by the slave station during the reverse transmission.
[0074] As an optional implementation, after each slave station receives the reverse-transmission dynamic compensation synchronization frame, it immediately initiates a field extraction process. It locates the TYPE field from the frame header according to a preset structure, extracts the field content, and compares it with a pre-stored frame type library to confirm that the frame type meets the reverse-transmission processing requirements of the dynamic compensation synchronization frame. Subsequently, a data clearing command is sent to clear the sensed reverse-transmission compensation reception timestamp to empty, and a deletion completion feedback signal is generated to ensure that no timestamp remains. This method verifies the frame's validity before deleting data, avoiding invalid operations on illegal frames and ensuring high data security.
[0075] Step B14: According to the batch write / read method corresponding to the TYPE type field and CMD command field, read and write the dynamic compensation time information of each slave station into the corresponding field of the dynamic compensation synchronization frame.
[0076] In this embodiment, the batch write-read method is an operation form that performs data interaction according to the requirements of the batch write-read method message field and register physical area mapping table based on the TYPE type field and CMD command field.
[0077] As an optional implementation, the TYPE type field and CMD command field in the dynamic compensation synchronization frame are first extracted. The TYPE type field is parsed to confirm the frame is a dynamic compensation-specific type, and the CMD command field is parsed to clarify the addressing rules for batch write / read. The locally stored dynamic compensation time information is matched one-to-one with the corresponding field positions in the frame according to the mapping table between the message fields of the batch write / read method corresponding to the TYPE type field and the CMD command field and the register physical area. The dynamic compensation time information is then interactively applied to the corresponding fields in one go according to this table. After writing is complete, a field verification mechanism is triggered to check the integrity and format correctness of the written data. Once confirmed to be error-free, the field is marked as valid. This method combines centralized parsing with batch write / read, resulting in simple operation steps and fast processing speed.
[0078] For example, the slave station receives a reverse-transmission dynamic compensation synchronization frame (Sync_dcom, TYPE=0x3). When this frame passes through the slave station receiver, a sensing action is triggered at the physical layer chip by identifying the preamble. The TYPE type field in the frame is parsed and XORed with a pre-stored frame type list. If the verification passes, the type identifier field of the frame is determined to be a valid synchronization instruction, and then the compensation reception timestamp Rx_timestamp is deleted. The data frame parses the CMD command field and finds the mapping table between the batch write / read addressing message fields and register physical areas in the Sync_dcom frame according to the TYPE type field and the CMD command field, as shown in Table 2. The dynamic compensation time information in the relevant local time registers is then interacted with the specified message fields one by one according to the mapping relationship in the table.
[0079] Table 2. Mapping Table of Message Fields and Register Physical Areas for Batch Write / Read Addressing in Sync_dcom Frames
[0080] Based on any of the above embodiments, in Embodiment 4 of this application, after step B14, steps C11-C12 are further included: Step C11: The first slave station transmits the dynamic compensation synchronization frame to the master station according to the reverse transmission path.
[0081] As an optional implementation, the first slave station pre-retrieves the pre-stored complete reverse backhaul path and determines the interface address and transmission parameters for connection with the master station. After receiving the dynamic compensation synchronization frame containing dynamic compensation time information from each slave station, the transmission process is initiated. Frame data is directionally pushed to the master station along the reverse backhaul path, and the transmission status is monitored synchronously until all frame data has been transmitted. This method features path pre-setting, strong transmission directionality, no additional path exploration steps, and a simple and efficient process.
[0082] Step C12: After receiving the dynamic compensation synchronization frame, the master station deletes the compensation receiving timestamp sensed during the corresponding reverse transmission.
[0083] As an optional implementation, after receiving the reverse-transmission dynamic compensation synchronization frame, the master station first initiates a frame parsing process to extract the TYPE type field from the frame. The field content is then compared with pre-stored frame type characteristics to confirm the frame's legality and relevance. Subsequently, a data clearing command is sent to completely overwrite the timestamp data and release storage space. After the clearing operation is complete, a check is performed to determine if the storage unit is empty. If no data remains, a deletion completion flag is generated. This method, by first verifying frame legality before deletion, avoids invalid operations on illegal frames, prevents accidental deletion of valid data, and ensures high data security.
[0084] By dynamically compensating for and correcting time information in real time, the influence of environmental disturbances is eliminated, and the accumulation of errors is suppressed at the source, thus improving the accuracy of clock synchronization.
[0085] Based on any of the above embodiments, in Embodiment 5 of this application, step S60 includes steps D11 to D13: Step D11: After receiving the dynamic compensation synchronization frame returned by the slave station, the master station parses and extracts the dynamic compensation time information corresponding to each slave station from the corresponding fields of the dynamic compensation synchronization frame, and obtains the compensation receiving timestamp and dynamic dwell time of each slave station.
[0086] In this embodiment, parsing and extraction refers to the process by which the main station reads and decodes the data within the frame, which can be achieved through CPU + software or underlying hardware mapping.
[0087] As an optional implementation, after receiving the dynamic compensation synchronization frame returned by the slave station, the master station first performs an integrity check on the entire frame data. After confirming that all corresponding fields are complete and formatted correctly, it starts the centralized parsing module to extract the dynamic compensation time information stored in each corresponding field according to the slave station address order. Then, according to a preset data structure, it extracts the compensation receiving timestamp and dynamic dwell time from each piece of dynamic compensation time information. All two types of time data from all slave stations are sorted by address association and stored in the master station's dedicated data buffer, while simultaneously generating a parsing completion identifier. This method combines centralized parsing with batch processing, resulting in simple operation steps and high parsing efficiency.
[0088] Step D12: Based on the dynamic dwell time of each slave station, combined with the compensation receiving timestamp corresponding to the first slave station and the link delay fixed in the initial synchronization phase, calculate the backtracking time value of each slave station.
[0089] In this embodiment, the compensation reception timestamp corresponding to the first slave station refers to the precise time point sensed when the first slave station directly connected to the master station receives the dynamic compensation synchronization frame during the dynamic compensation phase, serving as a reference clock base. The fixed link delay during the initial synchronization phase refers to the fixed delay of signal propagation between the master station and slave stations calculated through the interaction of the initial synchronization frame during the initial synchronization phase, independent of the disturbance of the dynamic dwell time. The backtracking time value refers to the running time of the reference clock when other slave stations receive the message, calculated by the master station, used to correct the local high-precision clock deviation.
[0090] As an optional implementation, the master station at the media access control layer chip reads and parses the compensation reception timestamps and dynamic dwell times of each slave station from the message field of the dynamic compensation synchronization frame. It then automatically aggregates the data by combining the compensation reception timestamp of the first slave station with a fixed link delay, generating a backtracking time value and storing it in a local buffer. Through the mapping relationship between the MAC layer intelligent sorting engine and the register group, high-throughput aggregation and dynamic topology adaptation are achieved, making it suitable for large-scale industrial systems. However, it suffers from computational overhead and high-temperature sensitivity bottlenecks.
[0091] Step D13: Based on the backtracking time value and compensation receiving timestamp of each slave station, calculate the dynamic compensation value corresponding to the slave station according to the compensation calculation formula, and calculate the dynamic compensation value corresponding to the master station according to the compensation sending timestamp sensed by the master station itself and the link delay.
[0092] In this embodiment, the compensation reception timestamp reported by each slave station refers to the current running time of the slave station's local high-precision clock when receiving the dynamic compensation synchronization frame. The dynamic compensation value corresponding to the slave station refers to the deviation calculated by the master station for correcting the slave station's clock, which is written into the corresponding local time correction register of the slave station to correct the time. The compensation transmission timestamp sensed by the master station itself refers to the precise time point sensed by the physical layer or media access control layer chip when the master station outputs the dynamic compensation synchronization frame at the transmission port. The dynamic compensation value corresponding to the master station refers to the correction amount of the master station's own clock, used to eliminate local clock drift.
[0093] As an optional implementation, the master station parses the backtracking time value and the compensation receiving timestamp at the media access control layer chip. Based on the compensation sending timestamp and link delay, it calculates the dynamic compensation values for the master and slave stations using a compensation calculation formula. The master station then sends the dynamic compensation values to each slave station via a batch addressing mechanism. The master station's dynamic compensation values are automatically stored in the corresponding local time correction register. The advantages of this method are low computational latency and strong anti-interference capability, making it suitable for high-temperature and strong electromagnetic environments. However, its disadvantages include functional rigidity, supporting only slave stations with fixed formulas and a limited processing capacity. The advantages of this method are high flexibility and efficient batch processing, making it suitable for large-scale systems. However, its disadvantages include computational power dependence and instability at high temperatures.
[0094] By employing a dynamic compensation time information separation mechanism and a dual-ended closed-loop compensation algorithm, the problem of synchronization accuracy degradation caused by fixed dwell time processing in fast addressing mode, as well as the systematic deviation caused by local clock drift, is solved, thus improving the accuracy of clock synchronization.
[0095] Based on any of the above embodiments, in Embodiment Six of this application, step S60 includes steps E11 to E13: In step E11, the master station corrects its local high-precision clock using a hardware counter based on the corresponding dynamic compensation value, so that the master station's local high-precision clock is aligned with the local high-precision clock of the first slave station.
[0096] In this embodiment, the hardware counter refers to the physical timer component in the master station, which can be directly driven by registers to correct time values. Alignment refers to the process of precisely matching the local high-precision clock in the master station with the local high-precision clock in the first slave station, which serves as the reference clock, through calibration.
[0097] As an optional implementation, the master station utilizes dynamic compensation values at the media access control layer chip. Through a batch addressing mechanism controlled by the CMD command field, the values are written to the register address corresponding to the hardware counter to correct the local high-precision clock, ensuring that the master station's local high-precision clock is synchronized with the local high-precision clock of the first slave station. Flexible synchronization of complex topologies is achieved through programmable control at the protocol layer, providing adaptive capabilities for large-scale industrial systems, but this is limited by protocol stack latency.
[0098] Step E12: Based on the association between the slave station and its dynamic compensation value, generate a batch addressing data frame for the dynamic compensation value, and write the dynamic compensation value corresponding to each slave station into the data field of the batch addressing data frame.
[0099] In this embodiment, the association relationship refers to the one-to-one binding logic between the dynamic compensation value and the target slave device, which is implemented by mapping the address field to the physical address of the register. Generation refers to the process of the master station constructing a data frame, including field assignment and encapsulation.
[0100] Step E13: After receiving the batch addressing data frame, the slave station writes the corresponding dynamic compensation value in the data field of the batch addressing data frame into the local time correction register, triggers the hardware counter to correct the local high-precision clock, and completes the clock synchronization between the slave station and the first slave station.
[0101] As an optional implementation, batch addressing data frames are processed at the media access control layer chip, and addressing instructions are identified through the CMD command field. Based on the starting physical address specified in the address field, the dynamically compensated values stored in segments in the data field are written to the target's local time correction register. After successful verification, a hardware counter is activated to correct the local high-precision clock, and the operation status is returned via the interrupt status flag field. Through a protocol-layer scalable architecture, the innovation depth of the industrial internet is covered, enabling large-scale node synchronization.
[0102] By using a self-calibrating reference chain at the master station and a hardware direct-drive compensation closed loop, the long-standing problems of accuracy drift and latency jitter in industrial network synchronization have been solved, thus improving the accuracy of clock synchronization.
[0103] Based on any of the above embodiments, in Embodiment 7 of this application, before step S10, steps F11 to F14 are further included: In step F11, the master station sends an initial synchronization frame and determines the initial transmission timestamp corresponding to the master station by sensing the identifier field of the initial synchronization frame at the master station port.
[0104] In this embodiment, the initial synchronization frame is the basic message for the master station to initiate clock synchronization. It contains an identifier field used to trigger time sensing. The structure of the initial synchronization frame sent by the master station is as follows: Figure 2 As shown in Table 1, the field parsing of the PDU area is configured to the value corresponding to the initial synchronization frame type of the data frame.
[0105] As an optional implementation, the master station first activates the identification field sensing module at the port, loads the complete feature sequence of the initial synchronization frame's identification field to complete calibration, and simultaneously constructs the initial synchronization frame, integrating the Ethernet frame header, Head field, PDU area, etc. Then, the port's transmission parameters are configured to adapt to the synchronization frame's transmission requirements, and the constructed initial synchronization frame is loaded into the transmission buffer. The transmission process is initiated. When the buffer pushes frame data to the link, the sensing module monitors the frame transmission status in real time. Once it captures the complete feature sequence of the identification field passing through the port, it immediately triggers the timestamp acquisition mechanism, retrieves the real-time time data from the local high-precision clock, and accurately writes it into the master station's initial transmission time register, thus determining the initial transmission timestamp. This method features pre-calibrated sensing modules, strong synchronization between timestamp acquisition and frame transmission, and extremely low latency, making it suitable for scenarios with stringent initial synchronization accuracy requirements.
[0106] Step F12: After receiving the initial synchronization frame, the first slave station transmits the initial synchronization frame to the downstream slave station, and the first slave station and the downstream slave station receive and send the initial synchronization frame in the forward transmission and reverse backhaul.
[0107] As an optional implementation, the first slave station pre-retrieves complete node information of the forward transmission path, clarifying the connection order and interface parameters of downstream slave stations. After receiving the initial synchronization frame, it parses the frame's identifier field to confirm its legitimacy. It configures its own sending port parameters to adapt to the forward link and pushes the frame data to the first downstream slave station in the path order. The downstream slave station receives the frame and repeats this forwarding process until the frame is transmitted to the last slave station on the forward path. Subsequently, the last slave station switches its transmission direction and transmits the frame back to the previous slave stations station by station along the reverse path. The first slave station and each downstream slave station sequentially receive the frames transmitted back in the reverse direction, completing their receiving and sending operations in both transmission directions. This method is based on a preset path transmission, has strong action directionality, and requires no additional path exploration.
[0108] Step F13: Obtain the initial reception timestamp from the receiving port sensing identifier field of each slave station, parse the TYPE type field of the data frame and record the initial reception timestamp obtained by sensing, and obtain the initial transmission timestamp from the sending port sensing identifier field of each slave station and record it locally.
[0109] As an optional implementation, after each slave station detects the initial synchronization frame, it immediately activates the identifier field sensing module at the port, scans the identifier field feature sequence in the frame data, matches it with pre-stored features, captures the reception time information, and generates an initial reception timestamp. Then, the TYPE type field parsing process is initiated to extract the field content and confirm that the frame is of the initial synchronization type. After verification, the initial reception timestamp is converted to an adapted format and written to the local system forward reception time register or system reverse reception register to complete the recording. Next, the transmission parameters of the sending port are configured, and the initial synchronization frame is pushed to the link. When the identifier field passes through the sending port, the sensing unit collects the transmission time information to generate an initial transmission timestamp, which is directly stored in the local system forward transmission time register and system reverse transmission time register to complete the recording. This method executes the operation steps in a logical order, with timestamp acquisition and type verification mutually verifying each other, resulting in high accuracy and strong reliability of the time data.
[0110] In step F14, after the last downstream slave station in the forward transmission direction sends the initial synchronization frame back to the master station, the master station receives the initial synchronization frame and senses the initial receiving timestamp corresponding to the master station at the receiving port of the master station.
[0111] In this embodiment, the initial reception timestamp corresponding to the master station is the actual reception time information recorded by the master station when it receives the frame.
[0112] As an optional implementation, the last downstream slave station pre-retrieves the master station interface information for the reverse backhaul path. After confirming the link parameters, it pushes the initial synchronization frame to the master station along a preset path. The master station pre-activates the identifier field sensing module of the receiving port, loads the complete feature sequence of the frame identifier field to complete calibration, and configures the port receiving parameters to adapt to the backhaul link. When the receiving port detects the arrival of frame data, the sensing module scans the identifier field features in real time, captures the moment the complete sequence passes through the port, and immediately triggers the timestamp acquisition mechanism. It retrieves the real-time time data from the local high-precision clock and accurately writes it into the master station's initial receiving time register, completing the sensing and recording of the initial receiving timestamp. This method, through pre-configuration of the backhaul path and sensing module, achieves strong synchronization between frame transmission and time sensing, with extremely low latency, and is suitable for scenarios with fixed reverse backhaul paths and stable link transmission.
[0113] For example, refer to Figure 4 , Figure 4This is a timing diagram for the initial synchronization phase of this application. The initial synchronization phase is as follows: The master station sends an initial synchronization Sync_init data frame to sense time information, sensing and recording the initial transmission timestamp T upon leaving the port. Each slave station, upon receiving the Sync_init frame, senses the identifier to obtain the initial reception timestamp Rx_timestamp, parses the TYPE field to identify the initial synchronization frame, records this timestamp locally, and senses and records the initial transmission timestamp Tx_timestamp locally at the transmission port. When the Sync_init frame returns in a loop, each slave station senses and records the RX and TX timestamps in the same way. When the master station receives the returned Sync_init data frame, it marks the initial reception timestamp at the reception port. .
[0114] Based on any of the above embodiments, in Embodiment 8 of this application, after step F11, steps G11~G13 are further included: In step G11, after the master station sends the initial follow frame, each slave station senses the identifier field at the corresponding receiving port when transmitting the initial follow frame in the forward direction, determines the initial receiving timestamp corresponding to the slave station, and deletes the initial receiving timestamp after parsing the TYPE type field of the data frame.
[0115] In this embodiment, the structure of the initial follow-up frame sent by the master station is as follows: Figure 2 As shown in Table 1, the field parsing of the PDU area is configured to the value corresponding to the initial following frame type of the data frame.
[0116] As an optional implementation, after the master station sends the initial follow frame, the receiving ports of each slave station detect the incoming frame data and immediately activate the identifier field sensing module. This module scans the complete feature sequence of the identifier field in the frame, matches it with pre-stored features, captures the reception time information, and determines the initial reception timestamp. Subsequently, the TYPE type field parsing process is initiated, extracting the field content and comparing it with the frame type library to confirm the frame's legitimacy. After successful verification, a clear command is sent to overwrite the data, and after the deletion operation is completed, the frame is forwarded again. This method features logically coherent steps, with the timestamp and frame type verification mutually reinforcing each other, resulting in high accuracy.
[0117] In step G12, each slave station parses the TYPE field and CMD command field of the initial follow frame, completes the read and write operations of the initial synchronization time information and the initial follow frame corresponding to the slave station through the corresponding batch write and read, and after reaching the last downstream slave station in the forward transmission, transmits the initial follow frame in reverse to the master station.
[0118] As an optional implementation, after receiving the initial follower frame, each slave station first extracts the TYPE field from the frame and compares it with the pre-stored initial follower frame type characteristics to confirm the frame's legitimacy. Then, it parses the CMD command field to determine the batch write / read addressing message field and register physical area mapping table corresponding to that frame type. Next, it retrieves the initial synchronization time information stored in its local register and sequentially interacts the initial synchronization time information with the corresponding message field of the frame according to the batch write / read addressing message field and register physical area mapping table for that frame type. Then, it forwards the frame to the next slave station along the forward transmission path until the frame reaches the last downstream slave station. Upon receiving the frame, the slave station confirms itself as the forward transmission endpoint, switches the transmission direction parameters of its sending port to adapt to the reverse link requirements, and pushes the frame back to the master station along the reverse path, completing the reverse transmission. This method features a coherent process logic, dual guarantees of type and data verification, and high data read / write accuracy.
[0119] Step G13: Based on the initial follow frame received by the master station, calculate the fixed link delay and initial time deviation based on the initial synchronization time information in the initial follow frame.
[0120] In this embodiment, the initial time deviation refers to the clock difference between the master station and each slave station during the initial synchronization phase, which is used to perform initial synchronization correction on the clocks of the master station and slave stations.
[0121] As an optional implementation, after receiving the initial follow frame, the master station first extracts the initial synchronization time information of all slave stations in the frame, categorizes and organizes them according to slave station addresses, and determines the correspondence between the initial receive timestamp of the forward transmission, the initial send timestamp of the reverse transmission, the difference between the forward and reverse dwell times and the sum of the dwell times, and the master station's own initial send timestamp and initial receive timestamp. Then, a centralized calculation process is initiated, substituting each set of time data into the calculation according to preset logic to derive the link delay between each slave station and the master station in batches, and taking the average of all link delays as the fixed link delay. Simultaneously, based on this average and each set of time data, the initial time deviation between the master station and each slave station is calculated centrally. After the calculation is completed, all results are verified as a whole, and after confirming that there are no logical contradictions, they are stored in a dedicated register. This method has high batch calculation efficiency, a simple process, and can quickly output results.
[0122] For example, after sending the initial synchronization Sync_init frame, the master station immediately sends an initial follow-up_init data frame with batch write / read commands to collect time information sensed by each slave station. After receiving the data frame, the slave station parses the TYPE field to identify the initial follow-up frame, deletes the Rx_timestamp sensed in this frame, and does not sense the Tx_timestamp during transmission. Based on the message field of the batch write / read addressing mode corresponding to the TYPE field and CMD command field, and the register physical area mapping table, it completes the read / write operations of the content data, as shown in Table 3. The initial time information, consisting of the forward receive timestamp, reverse transmit timestamp, and two correction values recorded locally in the local registers, is then interacted with the corresponding fields in the Follow_up_init frame according to the message field of the batch write / read addressing mode and the register physical area mapping table.
[0123] Table 3. Mapping Table of Message Fields and Register Physical Areas for Batch Write / Read Addressing in Follow_up_init Frames
[0124] The Timestamp1 field in the Follow_up_init frame reads the forward reception timestamp. The Timestamp2 field reads the reverse transmission timestamp. . and The time information read from field 2 is calculated as follows: ; ; ; ; In the formula and These are the sending and receiving timestamps sensed during forward message transmission. and These are the sending and receiving timestamps sensed during reverse message transmission. After receiving the Follow_up_init frame, the master station parses the time information of each slave station carried in the Follow_up_init frame and uses this time information to calculate the delay and offset. The master station and each slave station... The calculation method for the sum and offset is as follows: Main site: ; ; ; From station n The offset is calculated as follows, where n is the current slave value and N is the total number of slaves in the system.
[0125] ; ; In the formula and The two correction fields, correctionField1 and correctionField2, in the corresponding synchronization message correspond to the dwell time and the difference between the dwell time and the dwell time of each slave station. The timestamp sensed by the data frame received by the slave station. The timestamp sensed when the slave station sends a data frame. The timestamp sensed when the master station sends a synchronization message. This is the timestamp sensed by the master station when it receives synchronization messages. The master station records the initial time deviation between itself and all slave stations. and link delay and according to Calibrate the local high-precision clock of the master station.
[0126] By using the initial synchronization frame and the initial follow-up frame, the link delay is separated and fixed during the initial synchronization phase to prepare for the calculation of dynamic compensation time information. By separating the link delay and dwell time, the accuracy of the dwell time is improved, thereby improving the accuracy of clock synchronization.
[0127] Based on any of the above embodiments, in Embodiment Nine of this application, after step G13, steps H11~H12 are further included: In step H11, the master station sends the initial time deviation to each of the slave stations and corrects the local high-precision clock corresponding to each of the slave stations using the initial time deviation.
[0128] In this embodiment, the local high-precision clock corresponding to each slave station is corrected so that the slave station adjusts its own timing reference based on the initial time deviation.
[0129] As an optional implementation, the master station first associates and sorts the initial time deviations of all slave stations by address, generates a batch addressing data frame containing slave station identifiers and corresponding deviation data, configures the transmission parameters of the sending port to adapt to the requirements of the forward transmission link, and initiates the batch sending process, synchronously pushing the instruction frame to all slave stations along the forward transmission path. After receiving the instruction frame, each slave station extracts the corresponding initial time deviation by matching its own identifier, and directly transmits the deviation data to the correction unit of its local high-precision clock. The correction unit adjusts the corresponding timing value of its local high-precision clock according to the initial time deviation, completing the correction of the local high-precision clock in real time. This method combines batch sending with synchronous correction, resulting in a simple operation process and high processing efficiency.
[0130] In step H12, the master station simultaneously stores the link delay in a fixed value in the relevant register of the master station.
[0131] As an optional implementation, after the master station completes the link delay calculation, it immediately extracts the link delay data and verifies its format standardization and logical rationality to confirm that the data meets the register storage requirements. Then, using the storage address index table, it accurately locates the preset dedicated link delay register, activates the register's write enable signal, and adapts and converts the link delay data according to the register's storage format. After conversion, the data is completely written to the register. During the writing process, the data transmission status is monitored in real time to ensure no transmission interruption or data loss. After writing is complete, the register's locking mechanism is triggered, marking the storage unit as read-only to prevent accidental rewriting in subsequent operations. Simultaneously, a storage completion flag is generated and fed back to the master station's synchronization control module. This method offers a direct and efficient storage process with no additional redundant operations, fast data writing speed, and the ability to quickly complete the fixed storage of link delay.
[0132] By sending the initial time deviation correction local high-precision clock to each slave station through the master station, and storing the link delay in the relevant registers of the master station, the problems of low synchronization accuracy and poor efficiency caused by excessive initial clock deviation and repeated calculation of link delay in clock alignment scenarios are solved, improving the efficiency of time synchronization and meeting the clock alignment requirements of data transmission in high-speed automated production lines.
[0133] This application provides a network system time synchronization device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the network system time synchronization method in Embodiment 1 above.
[0134] The following is for reference. Figure 5The diagram illustrates a structural schematic of a network system time synchronization device suitable for implementing embodiments of this application. The network system time synchronization device in embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, personal digital assistants (PDAs), in-vehicle time synchronization devices, etc., and fixed terminals such as programmable logic controllers (PLCs), desktop computers, embedded devices, etc. Figure 5 The network system time synchronization device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0135] like Figure 5 As shown, the network system time synchronization device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The random access memory 1004 also stores various programs and data required for the operation of the network system time synchronization device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the network system time synchronization device to communicate wirelessly or wiredly with other devices to exchange data. Although network system time synchronization devices with various systems are shown in the figure, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented or possessed alternatively.
[0136] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0137] The network system time synchronization device provided in this application, employing the network system time synchronization method described in the above embodiments, can solve the technical problem of excessive errors when facing dynamic jitter. Compared with the prior art, the beneficial effects of the network system time synchronization device provided in this application are the same as those of the network system time synchronization method described in the above embodiments, and other technical features of this network system time synchronization device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0138] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0139] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0140] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function.
[0141] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A time synchronization method for a network system, applied to a network system comprising a master station and a first slave station, characterized in that, The method includes: The master station sends a dynamic compensation synchronization frame to the first slave station in the forward transmission direction, and senses the identification field and records the compensation transmission timestamp at the sending port of the master station. When the first slave station receives the dynamic compensation synchronization frame, it senses and determines the compensation receiving timestamp corresponding to the first slave station at the receiving port by sensing the identification field and parsing the TYPE type field, and records it locally. The first slave station determines the compensation transmission timestamp by sensing the identifier field of the dynamic compensation synchronization frame at the forward transmission port and records it locally; After the first slave station receives the dynamic compensation synchronization frame in the reverse transmission direction, it deletes the compensation receiving timestamp sensed by the reverse transmission and reads and writes the dynamic compensation time information calculated by the compensation receiving timestamp and compensation sending timestamp corresponding to the first slave station into the dynamic compensation synchronization frame by parsing the TYPE type field and CMD command field and according to the corresponding batch write and read method. The dynamic compensation synchronization frame returns the dynamic compensation time information corresponding to the first slave station to the master station. Based on the dynamic compensation time information, the fixed link delay, and the compensation calculation formula, the dynamic compensation values corresponding to the master station and the slave station are calculated, and the dynamic compensation values are written into the local time correction registers of the master station and the corresponding slave station to complete the clock synchronization of the master station and the slave station.
2. The network system time synchronization method as described in claim 1, characterized in that, The network system further includes downstream slave stations. After the step of sending a dynamic compensation synchronization frame to the first slave station through the master station in the forward transmission direction, the time synchronization method of the network system further includes: The first slave station receives and forwards the dynamic compensation synchronization frame, and each of the downstream slave stations is connected to the first slave station in sequence according to the transmission path in the forward transmission direction; The downstream slave station receives the forward-transmitted dynamic compensation synchronization frame and forwards the dynamic compensation synchronization frame to other slave stations. At the receiving port of the downstream slave station, the identification field of the dynamic compensation synchronization frame is sensed to determine the compensation receiving timestamp corresponding to the downstream slave station. After parsing the TYPE type field of the dynamic compensation synchronization frame, the compensation receiving timestamp is recorded locally, and the compensation sending timestamp is sensed and recorded locally at the sending port of the downstream slave station through the identifier field.
3. The network system time synchronization method as described in claim 2, characterized in that, After parsing the TYPE type field of the dynamic compensation synchronization frame, recording the compensation reception timestamp locally, and sensing the compensation transmission timestamp through the identifier field and recording it locally at the downstream slave station's transmission port, the network system time synchronization method further includes: After the downstream slave station transmits the dynamic compensation synchronization frame to the last slave station in the forward transmission direction, the downstream slave station transmits the dynamic compensation synchronization frame back in the reverse direction. According to the reverse transmission path, the dynamic compensation synchronization frames are transmitted one by one from the downstream slave station to the first slave station; After each slave station receives the reverse-transmission dynamic compensation synchronization frame, it parses the TYPE type field of the dynamic compensation synchronization frame and deletes the compensation receiving timestamp sensed by the slave station during the corresponding reverse transmission. Based on the batch write / read method corresponding to the TYPE type field and CMD command field, the dynamic compensation time information of each slave station is read and written into the corresponding field of the dynamic compensation synchronization frame.
4. The network system time synchronization method as described in claim 3, characterized in that, After the step of reading and writing the dynamic compensation time information of each slave station into the corresponding field of the dynamic compensation synchronization frame according to the batch write / read method corresponding to the TYPE type field and the CMD command field, the network system time synchronization method further includes: The first slave station transmits the dynamic compensation synchronization frame to the master station according to the reverse transmission path; After receiving the dynamic compensation synchronization frame, the master station deletes the compensation reception timestamp sensed during the corresponding reverse transmission.
5. The network system time synchronization method as described in claim 1, characterized in that, The step of calculating the dynamic compensation values corresponding to the master station and slave station based on the dynamic compensation time information, the fixed link delay, and the compensation calculation formula includes: After receiving the dynamic compensation synchronization frame returned by the slave station, the master station parses and extracts the dynamic compensation time information corresponding to each slave station from the corresponding fields of the dynamic compensation synchronization frame, and obtains the compensation receiving timestamp and dynamic dwell time of each slave station. Based on the dynamic dwell time of each slave station, combined with the compensation receiving timestamp corresponding to the first slave station and the link delay fixed during the initial synchronization phase, the backtracking time value of each slave station is calculated. Based on the backtracking time value and compensation receiving timestamp of each slave station, the dynamic compensation value corresponding to the slave station is calculated according to the compensation calculation formula. Based on the compensation sending timestamp sensed by the master station itself and the link delay, the dynamic compensation value corresponding to the master station is calculated according to the formula.
6. The network system time synchronization method as described in claim 1, characterized in that, The step of writing the dynamic compensation value into the local time correction registers of the master station and the corresponding slave station to complete the clock synchronization between the master station and the slave station includes: The master station corrects its local high-precision clock using a hardware counter based on the corresponding dynamic compensation value, so that the master station's local high-precision clock is aligned with the local high-precision clock of the first slave station. Based on the association between the slave station and its dynamic compensation value, a batch addressing data frame for the dynamic compensation value is generated, and the dynamic compensation value corresponding to each slave station is written into the data field of the batch addressing data frame; After receiving the batch addressing data frame, the slave station writes the corresponding dynamic compensation value in the data field of the batch addressing data frame into the local time correction register, triggers the hardware counter to correct the local high-precision clock, and completes the clock synchronization between the slave station and the first slave station.
7. The network system time synchronization method as described in claim 1, characterized in that, Before the step of sending a dynamic compensation synchronization frame from the master station to the first slave station in the forward transmission direction, and sensing the identifier field and recording the compensation transmission timestamp at the master station's transmission port, the network system time synchronization method further includes: The master station sends an initial synchronization frame, and at the master station port, by sensing the identifier field of the initial synchronization frame, determines the initial sending timestamp corresponding to the master station; After receiving the initial synchronization frame, the first slave station transmits the initial synchronization frame to the downstream slave station, and the first slave station and the downstream slave station receive and send the initial synchronization frame in the forward transmission and reverse backhaul. The initial reception timestamp is obtained from the receiving port sensing identifier field of each slave station, the TYPE type field of the data frame is parsed and the initial reception timestamp is recorded, and the initial transmission timestamp is obtained from the sending port sensing identifier field of each slave station and recorded locally. After the last downstream slave station in the forward transmission direction sends the initial synchronization frame back to the master station, the master station receives the initial synchronization frame and senses the initial receiving timestamp corresponding to the master station at the receiving port of the master station.
8. The network system time synchronization method as described in claim 7, characterized in that, After the steps of the master station sending an initial synchronization frame and determining the initial transmission timestamp corresponding to the master station at the master station port by sensing the identifier field of the initial synchronization frame, the network system time synchronization method further includes: After the master station sends the initial follow frame, when each slave station transmits the initial follow frame in the forward direction, it senses the identification field at the corresponding receiving port to determine the initial receiving timestamp of the slave station. After each slave station parses the TYPE type field of the data frame, it deletes the initial receiving timestamp. Each slave station parses the TYPE field and CMD command field of the initial follow frame, and completes the read and write operations of the initial synchronization time information and the initial follow frame corresponding to the slave station through the corresponding batch write and read. After reaching the last downstream slave station in the forward transmission, the initial follow frame is transmitted in reverse to the master station. Based on the initial follow frame received by the master station, and the initial synchronization time information in the initial follow frame, the fixed link delay and initial time deviation are calculated.
9. The network system time synchronization method as described in claim 8, characterized in that, After the step of calculating the fixed link delay and initial time deviation based on the initial synchronization time information in the initial follow-up frame received by the master station, the network system time synchronization method further includes: The master station sends the initial time deviation to each of the slave stations, and corrects the local high-precision clock of each slave station using the initial time deviation. Meanwhile, the master station stores the link delay in a fixed value in the relevant register of the master station.
10. A network system time synchronization device, characterized in that, The network system time synchronization device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the method as described in any one of claims 1 to 9.
Citation Information
Cited By
A time code comparison method and system for a multi-station multi-channel scene monitoring receiver
CN122348808A
A time code comparison method and system for a multi-station multi-channel scene monitoring receiver
CN122348808B