Relative time synchronization system and method based on Ethernet, and storage medium
By connecting the master clock device and slave clock device via Ethernet, and combining time processing and network time synchronization modules, the problems of GNSS dependence and cable laying in existing technologies are solved, achieving high-precision relative time synchronization, which is suitable for scenarios such as mines, tunnels and building laboratories.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-03-24
AI Technical Summary
Existing relative time synchronization schemes require GNSS to provide a time reference, cannot set the start time when there is no GNSS signal, and have excessive drift and poor timekeeping performance, making it impossible to achieve sub-millisecond time synchronization in an Ethernet environment.
The system employs a master clock device and a slave clock device connected via Ethernet. The master clock device operates in NTP server or PTP master clock mode, providing NTP or PTP time synchronization. The time processing module includes a phase detector, filter, and error adjustment unit. Time synchronization is achieved using a network time synchronization module, enabling both local timekeeping and network time synchronization.
It achieves sub-millisecond time synchronization in Ethernet environments without the need for cabling, offering high cost-effectiveness and suitability for scenarios such as mines, tunnels, and building laboratories.
Smart Images

Figure CN121727675A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of time system, and particularly to an Ethernet-based relative time synchronization system, method and storage medium. BACKGROUND
[0002] Here, the relative time synchronization refers to that the relative time difference between devices in a system is small, and it is not required to be consistent with absolute UTC time or Beijing time. The main application scenarios include data acquisition, multi-terminal collaborative work, and do not require absolute accuracy, but require certain time keeping performance.
[0003] At present, the relative time synchronization solution and the existing defects and deficiencies are as follows: absolute time synchronization is adopted, GNSS is required to provide a time reference, an outdoor antenna is required to be used, 1PPS synchronization is required to be used, and coaxial lines and optical fibers are required to be laid. When there is no GNSS signal, the initial time setting is not supported, and the drift is too large, and the time keeping performance is poor. SUMMARY
[0004] The present application mainly solves the technical problem of providing an Ethernet-based relative time synchronization system, method and storage medium to solve the defects and deficiencies of the above relative time synchronization solution in the prior art.
[0005] To solve the above technical problems, one technical solution adopted by the present application is to provide a relative time synchronization system, which comprises a master clock device, a slave clock device and a time-using device, the master clock device is connected with the slave clock device and the time-using device through a network, the master clock device works in an NTP server or PTP master clock mode, the slave clock device works in an NTP client and PTP slave clock mode, and the master clock device provides NTP or PTP time service to the slave clock device and / or the time-using device through the network.
[0006] In some embodiments, the master clock device and the slave clock device have the same circuit composition, and each comprises a GNSS navigation module, a time processing module and a network time service module, the time processing module is electrically connected with the GNSS navigation module and the network time service module, and the network time service module is used for accessing the network; the GNSS navigation module is used for receiving an external satellite navigation signal to provide an external time source for the time processing module; when there is no external time source, the time processing module enters a local time keeping mode; and the network time service module receives a second pulse and time information provided by the time processing module to generate a local time.
[0007] In some embodiments, the time processing module includes a phase detector, a first filter, an error adjustment unit, a second pulse generation unit, and a local time unit; the phase detector includes two input terminals and one output terminal, wherein the output terminal is connected to the first filter, and the phase detector is used to receive externally input second pulses and local second pulses for phase detection, and input the phase detection result into the first filter for filtering to obtain a first time deviation. The first filter is also electrically connected to an error adjustment unit, which is used to adjust the first time deviation. The first frequency word is output after calculation. The second pulse generation unit is electrically connected to the error adjustment unit and is used to receive the first frequency word. The local second pulse is generated; the local second pulse is input to the phase detector on one hand and to the local time unit on the other hand, and the local time unit uses the local second pulse to perform timing and time error correction on the local time.
[0008] In some embodiments, the error adjustment unit includes two branches, the first branch including a first multiplier for adjusting the first time deviation. Multiply by the first coefficient The second branch includes a second multiplier and a first accumulator, used to process the first time deviation. Multiply by the second coefficient The first branch and the second branch are also combined through a first adder to output the first frequency word. The second pulse generation unit includes a second adder and a second accumulator. The second adder is used to process the first frequency word output by the error adjustment unit. The sum is added to the initial frequency word, and the result is used as the accumulation step size for accumulation. If the accumulated value is exactly equal to or greater than the threshold value corresponding to a 1-second time interval, the local second pulse is output through the selector.
[0009] In some embodiments, in local timekeeping mode, the time processing module reads a stored frequency word to replace the first frequency word output by the error adjustment unit. The stored frequency word is added to the initial frequency word to generate the local second pulse output.
[0010] In some embodiments, the network time synchronization module includes a protocol analysis unit, a time difference calculation unit, and a second filter; wherein, the protocol analysis unit is used to receive network time synchronization signals, run the PTP network time synchronization protocol, and obtain timestamps; the protocol analysis unit is electrically connected to the time difference calculation unit, the time difference calculation unit is electrically connected to the second filter, and the time difference calculation unit uses the timestamps to calculate a second time deviation. The second filter is also electrically connected to the error adjustment unit for adjusting the second time deviation. After filtering, error calculation is performed and the result is converted into a second frequency word. To generate a local second pulse.
[0011] In some embodiments, the second time deviation The calculation method is as follows: , Where T1 is the time when the PTP Sync frame leaves the master clock, T2 is the time when the PTP Sync frame arrives at the slave clock, T3 is the time when the PTP DelayRequest frame leaves the slave clock, and T4 is the time when the PTP DelayRequest frame arrives at the master clock.
[0012] Based on the same inventive concept, a relative time synchronization method is also provided, which utilizes the aforementioned relative time synchronization system for time synchronization. In the master clock operating mode, the method includes the following steps: The system receives an input second pulse from an external time source, performs phase detection on the input second pulse and the local second pulse, and obtains a first time deviation after filtering. For the first time deviation Error calculation is performed to obtain the first frequency word to be adjusted. The first frequency word Calculation method: , in, , Related to the selected bandwidth, the larger the bandwidth, the larger its value, and the faster the error calculation process; in the first frequency word The local second pulse is generated under the control of the system, the local time is adjusted using the local second pulse, and NTP or PTP network time synchronization is generated externally.
[0013] In some embodiments, in clock-based operating mode, the steps include: Receive network time signal from master clock, run PTP network time protocol, obtain timestamp; use timestamp to calculate second time deviation. ; Regarding the second time deviation Error calculations are performed to obtain the second frequency word to be adjusted. , The calculation method is as follows: , In the formula , Related to the selected bandwidth, the larger the bandwidth, the larger the value, and the faster the error calculation process; exist Under the control of [the system], a local second pulse is generated, and the local time is adjusted using the local second pulse. Then, the process returns to the starting stage and the time difference is calculated again. Specifically, when the second time deviation [is calculated]... Once the time falls below a preset threshold, the device's time is synchronized to an external time source. When the time of multiple terminals is synchronized to the master clock, it can be considered that all terminals in the network have achieved relative time synchronization.
[0014] Based on the same inventive concept, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of the aforementioned relative time synchronization method.
[0015] The beneficial effects of this application are as follows: This application discloses a relative time synchronization system, method, and storage medium based on Ethernet. The system includes a master clock device, a slave clock device, and a time-using device. The master clock device is connected to the slave clock device and the time-using device via a network. The master clock device operates in NTP server or PTP master clock mode, and the slave clock devices operate in NTP client and PTP slave clock modes respectively. The master clock device provides NTP or PTP time synchronization to the slave clock device and / or the time-using device via the network. This application eliminates the need for cabling in environments with Ethernet, and can achieve sub-millisecond time synchronization using existing networks and switches, offering high cost-effectiveness and suitability for scenarios such as mines, tunnels, and building laboratories. Attached Figure Description
[0016] Figure 1 This is a schematic diagram illustrating the composition of an embodiment of the Ethernet-based relative time synchronization system of this application; Figure 2 This is a circuit diagram of the master clock device and slave clock device according to an embodiment of the Ethernet-based relative time synchronization system of this application; Figure 3 This is a schematic diagram of the internal circuit composition of the time processing module in an embodiment of the Ethernet-based relative time synchronization system of this application; Figure 4 This is a schematic diagram of the internal circuit composition of the network time synchronization module in an embodiment of the Ethernet-based relative time synchronization system of this application; Figure 5 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium provided in this application. Detailed Implementation
[0017] To facilitate understanding of this application, a more detailed description is provided below with reference to the accompanying drawings and specific embodiments. Preferred embodiments of this application are shown in the drawings. However, this application can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of this application.
[0018] It should be noted that, unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.
[0019] The embodiments will now be described in detail with reference to the accompanying drawings.
[0020] like Figure 1 As shown, the relative time synchronization system embodiment of this application includes one master clock device and multiple slave clock devices. The master clock device and slave clock devices employ the same hardware design, and their operating modes can be configured simply through a serial port or an embedded web page. The master clock device operates in NTP (Network Time Protocol) server and PTP (Precision Time Protocol) master clock mode, simultaneously providing NTP and PTP time synchronization to slave clock devices and / or time-using devices via the network. Slave clock devices can also operate in NTP server and PTP master clock mode, used for time synchronization to time-using devices (such as…). Figure 1 The timekeeping devices (2 to 4) are used in the middle, so the slave clock device can operate in both master clock mode and slave clock mode. The master clock device can access GNSS signals to provide high-precision time information, and can also operate without GNSS signals, thus having high timekeeping performance.
[0021] Network time synchronization slave clock devices and time-using devices operate on NTP clients (such as...) Figure 1 The timing device 1) and PTP from clock mode (such as Figure 1 Time-using devices (such as those using network synchronization devices) can directly synchronize with the master clock device via the network, achieving a high synchronization accuracy of 1PPS based on the IEEE 1588 protocol. Time-using devices that do not use network synchronization cannot directly synchronize with the master clock device and require indirect synchronization via a slave clock device (such as...). Figure 1 (Equipment 2 to 4 used in the middle).
[0022] The specific approach involves the slave clock device synchronizing its time with the master clock device via the network, while simultaneously providing 1PPS and TOD information or BeiDou satellite timing signals (referred to as B-code timing signals) to time-using devices. The time-using devices receive the 1PPS and TOD information or the BeiDou satellite timing signals, synchronize their time with the slave clock device, and thus indirectly synchronize their own time with the master clock device, ultimately achieving time synchronization for all time-using devices within the network.
[0023] pass Figure 1 The relative time system shown requires no cabling in an Ethernet environment and can utilize existing networks. For sub-microsecond accuracy requirements, simply replace the switch with one supporting the PTP protocol; for sub-millisecond accuracy requirements, existing switches can be used directly. It can provide 1PPS+TOD, as well as NTP / PTP and B-code interfaces to meet the needs of different types of timing devices. It is suitable for mines, tunnels, building laboratories, etc.
[0024] Furthermore, both the master and slave clock devices use the same hardware design, and their operating modes can be configured via an embedded web page or serial port. Combined with... Figure 2 As shown, both the master and slave clock devices consist of three parts: a GNSS navigation module, a time processing module, and a network time synchronization module. The time processing module mainly comprises the AG32VF407SOC chip (containing an MCU and FPGA, enabling programmable implementation of program control and digital circuits), while the network time synchronization module mainly consists of the CH32V307 processor chip and the RTL8201FS network chip. Additionally, it includes a power supply, LED indicators, a download port, a debug port, and other necessary data input / output interfaces.
[0025] The temperature-controlled crystal oscillator module is electrically connected to the time processing module, providing a high-stability clock input of 10MHz. The GNSS navigation module receives navigation signals from external GPS and BDS, providing a time source for the time processing module. This module is inactive without external GNSS signal input. The external 1PPS+TOD module provides the time processing module with high-precision second pulses and time information. The GNSS navigation module and the external 1PPS+TOD module, as high-precision clock and time inputs, serve as the basis for the time processing module to generate its local clock.
[0026] When the time processing module is used as the master clock, it receives the timing source signal from the GNSS navigation module and restores the local time when satellite time or an external 1PPS is available. When no external time source is available, it enters local timekeeping mode, maintains its local time automatically, and sends the local time to the network timing module in 1PPS+TOD format. When the time processing module is used as a slave clock, it receives time error information from the network timing module, uses this information to restore the local time, and outputs the local time externally in 1PPS+TOD format.
[0027] The function of the network time synchronization module is to receive the 1PPS+TOD signal provided by the time processing module as a time reference to restore the local time. When used as a master clock device, the network time synchronization module provides PTP and NTP time synchronization services to remote time-using devices: for PTP time synchronization, the network time synchronization module acts as a PTP master clock to provide PTP time synchronization to other time-using devices; for NTP time synchronization, the network time synchronization module acts as an NTP server to provide NTP time synchronization to other time-using devices.
[0028] When used as a slave clock device, the network time synchronization module receives network time synchronization information from the master clock device and sends the time difference information back to the time processing module. Specifically, when acting as an NTP client, the network time synchronization module performs NTP time difference measurement: as an NTP client, it performs NTP deviation measurement and sends the measurement results to the time processing module via serial port. Alternatively, when operating in PTP slave clock mode, the network time synchronization module performs PTP time difference measurement: as a PTP slave clock, it performs PTP deviation measurement and sends the measurement results to the time processing module via serial port. Figure 2 The hardware components shown also include the ability to query or modify relevant parameters via an embedded webpage or configuration serial port. For firmware upgrades: firmware upgrades can be performed on the onboard CPU via the network port, or the time processing module can be upgraded via serial port relay. Other processing functions include: network port debugging: used for network port debugging; embedded webpage: providing query and configuration of relevant parameters; protocol processing: performing different processing based on the message code and message type of the protocol frame; serial port transmission and reception: receiving the entire frame completely and performing different processing based on the different frame headers.
[0029] Furthermore, such as Figure 3 As shown, the internal components of the time processing module and the network time synchronization module are displayed. With the device operating in master clock mode, the time synchronization principle is shown, which mainly includes phase detection, error adjustment, and network time synchronization.
[0030] Specifically, the system comprises a phase detector A1, a first filter A2, an error adjustment unit A3, a second pulse generation unit A4, and a local time unit. The phase detector A1 has two input terminals and one output terminal, with the output terminal connected to the first filter A2. The phase detector A1 receives externally input second pulses (1PPS) and local second pulses (1PPS), and the result of phase detection is input to the first filter A2 for filtering to obtain the first time deviation. The first filter A2 is also electrically connected to an error adjustment unit A3, which includes two branches. The first branch includes a first multiplier A31 for adjusting time deviations. Multiply by the first coefficient ,Right now The second branch includes a second multiplier A32 and a first accumulator A33, used for time deviation. Multiply by the second coefficient ,Right now And summing the results of multiplication. The first and second branches are also combined through the first adder to output the first frequency word. ,Right now: .
[0031] The second pulse generation unit A4 includes a second adder A41 and a second accumulator A42. The second adder A41 is used to process the first frequency word output by the error adjustment unit. The sum is added to the initial frequency word M0, and the result is used as the accumulation step size Step for accumulation. When accumulating continuously at the set frequency, if the accumulated value is exactly equal to or greater than the threshold value corresponding to the 1-second time interval, a second pulse is output through the selector A43, and the accumulator is also cleared to start accumulating again.
[0032] The phase detector A1, first filter A2, error adjustment unit A3, and second pulse generation unit A4 are all located within the time processing module. The local second pulse output by the second pulse generation unit A4 is input to both the phase detector A1 and the local time unit B1. The local time maintenance subunit B11 within the local time unit B1 uses the local second pulse to perform timing and error adjustment, maintaining the accuracy of the local time. The local time maintenance subunit B11 outputs the second pulse and time information TOD to the network time synchronization protocol subunit B12, which can then perform time synchronization via network communication based on the network time synchronization protocol. The local time unit B1 is located within the network time synchronization module and acts as the master clock device, thus enabling network time synchronization via Ethernet.
[0033] based on Figure 3Under the master clock mode shown and with an external clock source, the following network relative time synchronization methods are included: Step 1: Receive an external 1PPS time source (which can be from GNSS or directly from an external source), perform phase detection on the external input 1PPS and the local 1PPS, and after filtering, obtain the first time deviation between the local time and the external time. ; Step 2: Adjusting the first time deviation Error calculation is performed to obtain the first frequency word to be adjusted. , The calculation method is as follows: , In the formula , It is closely related to the selected bandwidth; the larger the bandwidth, the larger its value, and the faster the error calculation process. Step 3: In Local 1PPS is generated under control; the specific method is... The output step size Step is obtained by adding it to the initial frequency word M0. The result is accumulated at 1-second intervals to generate a local 1PPS output, which corresponds to the local 1PPS in step 1.
[0034] Step 4: Use the local 1PPS to adjust the local time and generate NTP or PTP network time synchronization.
[0035] Among them, when Once the value is less than the preset threshold, the device time can be considered synchronized with the external time source, and the ΔFTF at this time is stored in the MCU's internal Flash memory.
[0036] Furthermore, when the device is powered on, if there is an external time source, the above process is followed. If there is no external time source, the stored ΔFTF is read from the Flash memory, directly calculated with M0 to generate Step, and after accumulation and gating, a local 1PPS is generated.
[0037] Furthermore, such as Figure 4 As shown, the network time synchronization module includes a protocol analysis unit B13, a time difference calculation unit B14, and a second filter B15. The protocol analysis unit B13 receives the network time synchronization signal from the master clock, runs the PTP network time synchronization protocol, and obtains four timestamps: T1, T2, T3, and T4. T1 is the time the PTP Sync frame leaves the master clock, T2 is the time the PTP Sync frame arrives at the slave clock, T3 is the time the PTP DelayRequest frame leaves the slave clock, and T4 is the time the PTP DelayRequest frame arrives at the master clock.
[0038] Protocol analysis unit B13 is electrically connected to time difference calculation unit B14. The four timestamps T1, T2, T3, and T4 are input into time difference calculation unit B14 for calculation, determining the second time deviation between the local time and the time synchronization from the master clock. : .
[0039] The time difference calculation unit B14 is electrically connected to the second filter B15 and is used to calculate the second time deviation. Filtering is performed. The second filter B15 is also electrically connected to the error adjustment unit A3 in the time processing module, and is used to adjust the second time deviation. After filtering, error calculation is performed and the result is converted into a second frequency word. To generate a local second pulse. Figure 4 The error adjustment unit A3 and the second pulse generation unit A4 in the middle Figure 3 The same applies as shown, so I will not repeat it here.
[0040] based on Figure 4 As shown, when the device operates in PTP slave clock or NTP client mode, its time synchronization method mainly includes NTP / PTP network time protocol parsing, time difference calculation, and error adjustment. Specifically: Step 1: The network time synchronization module receives the network time synchronization signal from the master clock (taking PTP as an example), runs the PTP network time synchronization protocol, and obtains four timestamps, namely T1, T2, T3, and T4.
[0041] T1 is the time when the PTP Sync frame leaves the master clock, T2 is the time when the PTP Sync frame arrives at the slave clock, T3 is the time when the PTP DelayRequest frame leaves the slave clock, and T4 is the time when the PTP DelayRequest frame arrives at the master clock.
[0042] Step 2: Calculate the second time deviation between the local time and the master clock using the following formula. After filtering, the difference is submitted to the error adjustment unit via serial port. .
[0043] Step 3: Adjusting the second time deviation Error calculations are performed to obtain the second frequency word to be adjusted. , The calculation method is as follows: , In the formula , It is closely related to the selected bandwidth; the larger the bandwidth, the larger its value, and the faster the error calculation process. Step 4: In Local 1PPS is generated under control; the specific method is... The output step size Step is obtained by adding it to the initial frequency word M0. The result is accumulated at 1-second intervals to generate a local 1PPS output, which corresponds to the local 1PPS in step 1.
[0044] Step 5: Use the local 1PPS to adjust the local time, then go back to step 1 and calculate the time difference again.
[0045] When the second time deviation Once the time falls below a preset threshold, the device time can be considered synchronized with an external time source. When the time of multiple terminals is synchronized with the master clock, it can be considered that all terminals within the network have achieved relative time synchronization.
[0046] Based on the inventive concept of the above embodiments, this application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, performs the steps of the method described in any of the above embodiments. The following is in conjunction with... Figure 5 This describes the execution process of the above embodiments on a computer-readable storage medium.
[0047] like Figure 5 As shown, it illustrates the computer-readable storage medium of this application. If the aforementioned synchronization method is implemented as a software functional unit and sold or used as an independent product, it can be stored in the computer-readable storage medium 200. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions / computer programs to cause an Internet of Things device (which may be a personal computer, server, or network terminal, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, as well as electronic terminals such as computers, mobile phones, laptops, tablets, cameras, and dedicated devices that have the aforementioned storage media.
[0048] The execution process of program data in a computer-readable storage medium can be described with reference to the above-described method embodiments of this application, and will not be repeated here.
[0049] The above are merely embodiments of this application and do not limit the scope of this patent application. Any equivalent structural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of this application.
Claims
1. A relative time synchronization system, characterized in that, It includes a master clock device, a slave clock device, and a time-using device. The master clock device is connected to the slave clock device and the time-using device via a network. The master clock device operates in NTP server or PTP master clock mode. The master clock device provides NTP or PTP time synchronization to the slave clock device and / or the time-using device via the network.
2. The relative time synchronization system according to claim 1, characterized in that, The master clock device and the slave clock device have the same circuit composition, both including a GNSS navigation module, a time processing module and a network time synchronization module. The time processing module is electrically connected to the GNSS navigation module and the network time synchronization module respectively. The network time synchronization module is used to access the network. The GNSS navigation module is used to receive navigation signals from external satellites and provide an external time source for the time processing module. When there is no external time source, the time processing module enters local timekeeping mode; the network time synchronization module receives the second pulse and time information provided by the time processing module to generate local time.
3. The relative time synchronization system according to claim 2, characterized in that, The time processing module includes a phase detector, a first filter, an error adjustment unit, a second pulse generation unit, and a local time unit. The phase detector includes two input terminals and one output terminal, with the output terminal connected to the first filter. The phase detector receives external input second pulses and local second pulses for phase detection, and inputs the phase detection result to the first filter for filtering to obtain the first time deviation. ; The first filter is also electrically connected to an error adjustment unit, which is used to adjust the first time deviation. Perform calculations and output the first frequency word. The second pulse generation unit is electrically connected to the error adjustment unit and is used to receive the first frequency word. This generates the local second pulse; The local second pulse is input to the phase detector on one hand and to the local time unit on the other hand, and the local time unit uses the local second pulse to keep track of the local time and correct time errors.
4. The relative time synchronization system according to claim 3, characterized in that, The error adjustment unit includes two branches. The first branch includes a first multiplier for adjusting the first time deviation. Multiply by the first coefficient The second branch includes a second multiplier and a first accumulator, used to process the first time deviation. Multiply by the second coefficient The first branch and the second branch are also added together by a first adder to output a first frequency word. ; The second pulse generation unit includes a second adder and a second accumulator. The second adder is used to process the first frequency word output by the error adjustment unit. The sum is added to the initial frequency word, and the result is used as the accumulation step size for accumulation. If the accumulated value is exactly equal to or greater than the threshold value corresponding to a 1-second time interval, the local second pulse is output through the selector.
5. The relative time synchronization system according to claim 4, characterized in that, In local timekeeping mode, the time processing module reads the stored frequency word and replaces the first frequency word output by the error adjustment unit. The stored frequency word is added to the initial frequency word to generate the local second pulse output.
6. The relative time synchronization system according to claim 3, characterized in that, The network time synchronization module includes a protocol analysis unit, a time difference calculation unit, and a second filter; wherein, the protocol analysis unit is used to receive network time synchronization signals, including running the PTP network time synchronization protocol and obtaining timestamps; The protocol analysis unit is electrically connected to the time difference calculation unit, and the time difference calculation unit is electrically connected to the second filter. The time difference calculation unit calculates the second time deviation using the timestamp. ; The second filter is also electrically connected to the error adjustment unit for adjusting the second time deviation. After filtering, the second frequency word is calculated based on the error. To generate a local second pulse.
7. The relative time synchronization system according to claim 6, characterized in that, Second time deviation The calculation method is as follows: , Where T1 is the time when the PTP Sync frame leaves the master clock, T2 is the time when the PTP Sync frame arrives at the slave clock, T3 is the time when the PTP DelayRequest frame leaves the slave clock, and T4 is the time when the PTP DelayRequest frame arrives at the master clock.
8. A relative time synchronization method, using the relative time synchronization system of any one of claims 1-7 for time synchronization, characterized in that, In master clock operating mode, the steps include: The system receives an input second pulse from an external time source, performs phase detection on the input second pulse and the local second pulse, and obtains a first time deviation after filtering. ; For the first time deviation Error calculation is performed to obtain the first frequency word to be adjusted. The first frequency word Calculation method: , in, , Related to the selected bandwidth, the larger the bandwidth, the larger the value, and the faster the error calculation process; In the first frequency word The local second pulse is generated under the control of the system, the local time is adjusted using the local second pulse, and NTP or PTP network time synchronization is generated externally.
9. The relative time synchronization method according to claim 8, characterized in that, In clock-based operating mode, the following steps are included: Receive network time signal from the master clock, run the PTP network time protocol, and obtain the timestamp; Calculate the second time deviation using the timestamp. ; For the second time deviation Error calculations are performed to obtain the second frequency word to be adjusted. , The calculation method is as follows: , In the formula , Related to the selected bandwidth, the larger the bandwidth, the larger the value, and the faster the error calculation process; exist Under the control of the system, a local second pulse is generated, and the local time is adjusted using the local second pulse. Then, the system returns to the starting stage and performs the time difference calculation again. Among them, when the second time deviation Once the time falls below a preset threshold, the device's time is synchronized to an external time source. When the time of multiple terminals is synchronized to the master clock, it can be considered that all terminals in the network have achieved relative time synchronization.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-9.