PPS-pulse-free high-precision clock synchronization method, device, equipment and medium
By obtaining the time error information of the external clock source and the GPS clock, generating time messages and analyzing them at preset times, the problem of large errors in the timing of the external clock source is solved, and high-precision timing of milliseconds is achieved, and the time synchronization accuracy and system reliability of the distribution system are improved.
Patent Information
- Application Number
- CN202510774585.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2045-06-11
AI Technical Summary
In the existing intelligent power distribution system, there are large errors in the timing function provided by the external clock source, resulting in inaccurate time recording and inability to meet the high-precision time requirements.
By obtaining the time error information of the external clock source and the GPS clock, generating time messages, and analyzing them at preset times, combining delay error calculations, high-precision timing of milliseconds can be achieved, simplifying external wiring, reducing costs, and improving system anti-interference reliability.
It realizes high-precision time synchronization in milliseconds, reduces time stamp errors, and improves the time-based accuracy of the distribution system and the anti-interference ability of the system.
Smart Images

Figure CN120567352A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent power distribution fault processing, and in particular to a high-precision synchronous clock method, device, equipment and medium without PPS pulses. Background Art
[0002] In the intelligent power distribution system, there are a large number of intelligent power distribution terminals. The intelligent power distribution terminals need to process a large number of hardware telesignaling changes and software telesignaling changes into records, as well as sequence event records of various faults, which are used to analyze the operating status and operating accidents of the intelligent power distribution system. These event records need to be time-stamped to analyze the sequence of events. The intelligent power distribution terminal is usually configured with an external clock source so that the intelligent power distribution terminal can read the internal GPS generated time of the external clock source through the serial port.
[0003] However, the time synchronization function provided by the external clock source in the existing technology is mostly the time when the external clock source outputs the synchronization message, which usually has a large error from the real time at that time. As a result, there is a certain delay time between the time when the smart distribution terminal receives the message and the time when it starts to process the message, resulting in a superimposed time error, which is far from meeting the high-precision time requirements of the distribution system for recording. Summary of the Invention
[0004] The present invention aims to address at least one of the technical problems existing in the prior art. To this end, the present invention provides a high-precision PPS-free synchronous clock method, apparatus, device, and medium. This method, which does not rely on PPS pulses, achieves millisecond-level high-precision time synchronization. While improving time synchronization accuracy, it also simplifies external wiring, reduces costs, and enhances system anti-interference reliability.
[0005] In a first aspect, an embodiment of the present invention provides a high-precision synchronous clock method without a PPS pulse, comprising:
[0006] Obtaining time error information between an external clock source and a GPS clock, and generating a time message based on the time error information;
[0007] confirming that the GPS clock sends a first time value of the time message and a second time value of the time message, wherein the first time value represents a falling edge of a start bit of a first byte of the time message;
[0008] When the external clock source receives the completion signal sent by the GPS clock, the external clock source responds to the time synchronization request of the smart power distribution terminal, parses the time message at a preset first moment, obtains a third time value, and obtains a first delay error of the smart power distribution terminal according to the first time value, the second time value, and the third time value;
[0009] The current time information of the GPS clock is confirmed according to the first delay error. The external clock source performs self-timer according to the current time information. When the external clock source receives the time synchronization request message sent by the intelligent power distribution terminal, it obtains a fourth time value at the second moment, organizes the fourth time value into a synchronization message, and sends the synchronization message to the intelligent power distribution terminal at a third moment.
[0010] The intelligent power distribution terminal parses the synchronization message to obtain a second delay error of the synchronization message, and confirms a first current time value of the synchronization message according to the second delay error;
[0011] The first current time value is written into the real-time clock of the intelligent power distribution terminal, and the second current time value of the real-time clock is re-read.
[0012] In some embodiments of the present invention, obtaining time error information between an external clock source and a GPS clock includes:
[0013] confirming that the GPS clock sends the first time value of the time message at a first shift moment of an integer number of milliseconds, and that the content of the time message is the second time value;
[0014] When the external clock source reads the time message, it confirms the first reception completion time of the first byte, and the real-time clock records the first current time of the first reception completion time in microseconds;
[0015] Obtaining the current baud rate at the first moment, and calculating the first byte transmission time of the first byte;
[0016] After receiving the complete time message sent by the GPS clock, the intelligent power distribution terminal parses the time message at the second moment to obtain the first time value, and calculates the second current moment according to the first time value;
[0017] The external clock source performs self-time keeping according to the first current time and the second current time.
[0018] In some embodiments of the present invention, arranging the fourth time value into a synchronization message includes:
[0019] The external clock source obtains the fourth time value according to the third time value and a preset number of milliseconds in response to the time synchronization request message sent by the intelligent power distribution terminal;
[0020] Arrange the fourth time value into a time response message, and confirm whether the intelligent power distribution terminal is at the fourth time;
[0021] When the intelligent power distribution terminal is at the fourth moment, sending the start bit of the first byte of the time synchronization response message at the fourth moment;
[0022] The preset terminal device and timer drive the start bit of the first byte of the time synchronization response message to adjust the control error of the time synchronization response message.
[0023] In some embodiments of the present invention, the intelligent power distribution terminal parses the synchronization message, including:
[0024] When the intelligent power distribution terminal receives the synchronization message from the external clock source, determining a first reception completion time of the first byte of the synchronization message;
[0025] Recording a third current moment of the first receiving completion moment in microseconds, and calculating a second byte transmission time of the first byte according to a current baud rate of the intelligent power distribution terminal and the third current moment;
[0026] Parsing the synchronization message at the fifth time value to obtain the fourth time value;
[0027] Recording the fourth time value as a fourth current moment in microseconds, and calculating a first real time of the synchronization message based on the third current moment, the fourth current moment, the second byte transmission time, and the fifth time value;
[0028] The external clock source performs self-timing according to the first real-time time to write the second current time value into the real-time clock.
[0029] In some embodiments of the present invention, after writing the second current time value into the real-time clock, the method further includes:
[0030] Acquire the byte transmission rate and the number of byte transmissions of the intelligent power distribution terminal, and calculate the third byte transmission time of the communication bus according to the byte transmission rate and the number of byte transmissions;
[0031] Starting the timer according to the third byte transmission time, and controlling the timer to generate an interrupt according to the first real time, the third byte transmission time and a first preset number of seconds;
[0032] When the timer is interrupted, the second current moment and the first preset described whole second time are written into the real-time clock, so that the sixth time value written into the real-time clock is equal to the whole second time.
[0033] In some embodiments of the present invention, after making the sixth time value written into the real-time clock equal to the whole second time, the method further includes:
[0034] Powering off and re-powering on the intelligent power distribution terminal, and calculating a fourth byte transmission time after the intelligent power distribution terminal is re-powered based on the byte transmission rate and the number of bytes transmitted;
[0035] Adjust the intelligent power distribution terminal to count down in a loop until the current countdown time value obtained by the intelligent power distribution terminal after two consecutive countdowns changes by seconds, and set the current countdown time value read last time as the current second time of the intelligent power distribution terminal;
[0036] The timer is initialized with half the fourth byte transmission time to adjust the error between the real-time clock and the presetter.
[0037] In some embodiments of the present invention, after the intelligent power distribution terminal is powered off and then powered on again, the method further includes:
[0038] When the intelligent power distribution terminal loses power, the real-time clock maintains the automatic running time of the intelligent power distribution terminal;
[0039] When the intelligent power distribution terminal is powered on again, the intelligent power distribution terminal reads the second real-time time of the real-time clock.
[0040] In a second aspect, an embodiment of the present invention provides a high-precision synchronous clock device without PPS pulses, comprising at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to execute the high-precision synchronous clock method without PPS pulses as described in the first aspect above.
[0041] In a third aspect, an embodiment of the present invention provides an electronic device comprising the high-precision synchronous clock device without PPS pulses as described in the second aspect above.
[0042] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the high-precision synchronous clock method without PPS pulses as described in the first aspect above.
[0043] The high-precision synchronous clock method without PPS pulses according to an embodiment of the present invention has at least the following beneficial effects:
[0044] The hardware-level precise detection of the falling edge of the start bit of each byte of the time-marking message replaces the traditional software parsing method of the message start time, avoids the timestamp error caused by the protocol parsing delay, and then records the time when the message is sent as a whole, which is used to calculate the sending duration of the single packet message. Combined with the first time value, the hardware processing delay in the message sending process is sorted out, providing a basis for subsequent error calculation; further, after receiving the completion signal of the GPS clock, the external clock source does not parse the message immediately, but parses it at the preset first time, thereby eliminating the random error of the parsing time caused by the uncertainty of the real-time processing of the receiving end (such as interrupt delay response, task scheduling priority), so that the acquisition of the third time value has a deterministic delay; in the third time value calculated by the first time value, the second time value and the third time value A delay error is used to determine the transmission delay and processing delay of the time message from the GPS clock to the external clock source, thereby avoiding the compensation error caused by the inability to disassemble the "end-to-end total delay" in the traditional solution; when the external clock source receives the synchronization request from the smart distribution terminal, it records the fourth time value at the second moment and sends the synchronization message at the third moment. Combined with the two-way timestamp, it eliminates the asymmetry of the path delay (such as the network two-way delay difference). The external clock source performs self-time according to the current time information of the GPS clock after the first delay error correction. When the GPS signal is interrupted, the self-time error can be predicted and compensated by historical calibration data to ensure long-term accuracy. The smart distribution terminal eliminates the software time update lag error caused by operating system task scheduling, bus delay, etc. by detecting the second current time value of the write operation. In summary, the technical solution of this embodiment uses timestamp refinement to mark and compensate for the message transmission time, program response time, and first byte transmission time error. By adjusting the write and read transmission time and second alignment time, accurate second alignment input is achieved, thereby improving the synchronization accuracy of the distribution system. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is a flow chart of a high-precision synchronous clock method without PPS pulses provided by one embodiment of the present invention;
[0046] Figure 2 This is a flowchart of obtaining time error information between an external clock source and a GPS clock provided by an embodiment of the present invention;
[0047] Figure 3 A flowchart of arranging a fourth time value into a synchronization message is provided in one embodiment of the present invention;
[0048] Figure 4 This is a flow chart of parsing a synchronization message by a smart power distribution terminal provided by an embodiment of the present invention;
[0049] Figure 5is a flow chart after writing a second current time value into a real-time clock according to an embodiment of the present invention;
[0050] Figure 6 This is a flow chart provided by one embodiment of the present invention after making the sixth time value written by the real-time clock equal to the whole second time;
[0051] Figure 7 This is a flow chart of powering off and powering on a smart power distribution terminal according to an embodiment of the present invention;
[0052] Figure 8 is a structural diagram of a high-precision synchronous clock device without PPS pulses provided by another embodiment of the present invention;
[0053] Figure 9 A timing diagram of a high-precision synchronous clock method without PPS pulses provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and are not to be construed as limiting the present invention.
[0055] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, they cannot be understood as limitations on the present invention.
[0056] In the description of the present invention, "several" means one or more, "many" means more than two, "greater than," "less than," and "exceed" are understood to exclude the number itself, while "above," "below," and "within" are understood to include the number itself. The use of "first" and "second" in the description is solely for the purpose of distinguishing technical features and should not be construed as indicating or implying relative importance, implicitly specifying the number of the indicated technical features, or implicitly specifying the order of the indicated technical features.
[0057] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, and connecting should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.
[0058] Reference Figure 9The embodiment of the present invention provides a high-precision synchronous clock method without PPS pulse, comprising obtaining time error information between an external clock source and a GPS clock, generating a time message according to the time error information; confirming a first time value of a time message sent by the GPS clock and a second time value of the time message, wherein the first time value represents a falling edge of a start bit of a first byte of the time message; when the external clock source receives a completion signal sent by the GPS clock, the external clock source responds to a time synchronization request from a smart distribution terminal, parses the time message at a preset first moment, obtains a third time value, and obtains a time synchronization time of the smart distribution terminal according to the first time value, the second time value, and the third time value. The first delay error of the terminal; the current time information of the GPS clock is confirmed based on the first delay error, and the external clock source performs self-time according to the current time information. When the external clock source receives the synchronization request message sent by the intelligent power distribution terminal, it obtains the fourth time value at the second moment, and organizes the fourth time value into a synchronization message, and sends the synchronization message to the intelligent power distribution terminal at the third moment; the intelligent power distribution terminal parses the synchronization message to obtain the second delay error of the synchronization message, and confirms the first current time value of the synchronization message based on the second delay error; the first current time value is written into the real-time clock (RTC) of the intelligent power distribution terminal, and the second current time value of the real-time clock is re-read. According to the technical solution of this embodiment, it is possible to not rely on the millisecond-level high-precision synchronization solution of the second pulse PPS, while improving the synchronization accuracy, simplifying external wiring, reducing costs, and improving the anti-interference reliability of the system.
[0059] It should be noted that this embodiment analyzes the external clock source (ETS) and the serial port reading time and serial port synchronization of the intelligent distribution terminal (TU), analyzes the cause of the time error, and performs reasonable and effective time compensation, optimizes the internal synchronization algorithm of the external clock source and the synchronization algorithm of the intelligent distribution terminal, and finally realizes a high-precision serial port synchronization mechanism with a serial port synchronization time error of less than 0.1 second.
[0060] The control method of the embodiment of the present invention is further described below based on the accompanying drawings.
[0061] Reference Figure 1 , Figure 1 A flowchart of a high-precision synchronous clock method without PPS pulses provided in an embodiment of the present invention includes but is not limited to the following steps:
[0062] Step S11, obtaining time error information between the external clock source and the GPS clock, and generating a time message according to the time error information;
[0063] It should be noted that the GPS clock provides the message latitude and longitude and time message in GPRMC format through the UART serial port, which is expressed as: $GPRMC, <1> , <2> , <3> , <4> , <5> , <6> , <7> , <8> , <9> , <10> , <11> , <12> ,CRC
[0064] Specifically, the time resolution is 1 ms.
[0065] It should be noted that the name segments of the message latitude and longitude and time message are described as follows:
[0066] <1> UTC time, in the format of hhmmss.sss, representing hours, minutes, seconds, and milliseconds;
[0067] <2> Positioning status, A = valid positioning, V = invalid positioning;
[0068] <3> Latitude in ddmm.mmmm (degrees and minutes) format (leading zeros will also be transmitted);
[0069] <4> Latitude hemisphere N (northern latitude) or S (southern latitude);
[0070] <5> Longitude in dddmm.mmmm (degrees and minutes) format (leading zeros will also be transmitted);
[0071] <6> Longitude hemisphere E (east longitude) or W (west longitude);
[0072] <7> Ground speed (000.0 to 999.9 knots, the leading 0 will also be transmitted);
[0073] <8> Ground heading (azimuth), equivalent to a two-dimensional compass (000.0 to 359.9 degrees, referenced to true north, with the leading zero also transmitted);
[0074] <9> UTC date, DDMMYY (day-month-year) format;
[0075] <10> Magnetic declination (000.0 to 180.0 degrees, the leading 0 will also be transmitted);
[0076] <11> Magnetic declination direction, E (east) or W (west);
[0077] <12> Mode indication (output only for NMEA0183 version 3.0, A = autonomous positioning, D = differential, E = estimated, N = invalid data);
[0078] The last two bytes of the CRC are the checksum.
[0079] Step S12, confirming the first time value of the time message sent by the GPS clock and the second time value of the time message, wherein the first time value represents the falling edge of the start bit of the first byte of the time message;
[0080] It should be noted that the second time value t1 of the time message sent by the GPS clock is the falling edge of the start bit of the first byte of the time message and the first time value t0 of the time content of the message. There is an error between the first time value t0 and the second time value t1, usually 0ms≤t2-t1≤800ms.
[0081] Step S13: After the external clock source receives the completion signal sent by the GPS clock, the external clock source responds to the time synchronization request of the smart power distribution terminal, parses the time message at the preset first moment, obtains a third time value, and obtains a first delay error of the smart power distribution terminal based on the first time value, the second time value, and the third time value;
[0082] It should be noted that after the external clock source receives the completion signal sent by the GPS clock, it parses the time message at the preset first moment to obtain the third time value. Due to the delay in task scheduling, it is usually 0ms≤t2-t1≤800ms.
[0083] It should be noted that there is a first delay error between the external clock source and the GPS clock. The first delay error is expressed by the following first formula:
[0084] (t1-t0)+(t2-t1)=t2-t0.
[0085] Step S14: confirming the current time information of the GPS clock based on the first delay error, and the external clock source self-operating based on the current time information. When the external clock source receives the synchronization request message sent by the smart power distribution terminal, it obtains a fourth time value at the second moment, organizes the fourth time value into a synchronization message, and sends the synchronization message to the smart power distribution terminal at the third moment;
[0086] It should be noted that the external clock source responds to the synchronization request of the smart distribution terminal and sends the time message to the first delay error of the smart distribution terminal. After receiving the time of the GPS clock, the external clock source performs self-time. When receiving the synchronization request message sent by the smart distribution terminal, it organizes the current time (i.e., the fourth time value t3) into a synchronization message at the second moment and sends the start bit of the first byte of the message (including the time content of the fourth time value t3) at the third moment. Due to the task scheduling delay of the system, usually 0ms<t4-t3≤800ms
[0087] Step S15: The intelligent power distribution terminal parses the synchronization message to obtain a second delay error of the synchronization message, and confirms the first current time value of the synchronization message according to the second delay error;
[0088] It should be noted that by parsing the second delay error of the synchronization message to correct the first current time value, it is possible to effectively compensate for the delay in the signal transmission process, reduce the time synchronization error, and make the time of the smart distribution terminal more accurately consistent with the time of the synchronization source.
[0089] Step S16: writing the first current time value into the real-time clock of the intelligent power distribution terminal, and re-reading the second current time value of the real-time clock.
[0090] It should be noted that during operation, the internal clock of a smart power distribution terminal may experience errors due to various factors, such as crystal oscillator frequency drift and temperature changes. Writing the accurate first current time value obtained by parsing the synchronization message into the real-time clock can promptly correct clock errors, prevent error accumulation, and ensure long-term time accuracy. Even for short periods of time, the clock may experience slight drift. Rereading the real-time clock to obtain the second current time value confirms that the clock is operating accurately as expected, allowing for timely detection and resolution of clock anomalies, ensuring that the smart power distribution terminal always maintains accurate time synchronization.
[0091] It should be noted that this embodiment analyzes the external clock source and the serial port reading time and serial port synchronization of the intelligent distribution terminal, analyzes the cause of the time error, and performs reasonable and effective time compensation, optimizes the internal synchronization algorithm of the external clock source and the synchronization algorithm of the intelligent distribution terminal, and finally realizes a high-precision serial port synchronization mechanism with a serial port synchronization time error of less than 0.1 seconds.
[0092] In addition, in one embodiment, referring to Figure 2 ,exist Figure 1 Step S11 of the illustrated embodiment also includes but is not limited to the following steps:
[0093] Step S21, confirming that the GPS clock sends a first time value of a time message at a first shift moment of an integer millisecond, and the content of the time message is a second time value;
[0094] Step S22, when the external clock source reads the time message, confirming the first reception completion time of the first byte, and the real-time clock records the first current time of the first reception completion time in microseconds;
[0095] Step S23, obtaining the current baud rate at the first moment, and calculating the first byte transmission time of the first byte;
[0096] Step S24: After receiving the complete time message sent by the GPS clock, the intelligent power distribution terminal parses the time message at the second moment to obtain the first time value, and calculates the second current moment based on the first time value;
[0097] Step S25 : The external clock source performs self-time keeping according to the first current time and the second current time.
[0098] It should be noted that the GPS clock is internally controlled to send the start bit of the first byte of the message at the first bit change moment of an integer millisecond. In this way, the error of the time value can be greatly reduced and the error can be controlled to be less than 10us.
[0099] When the external clock source reads the time message sent by the GPS clock through the serial port, at the moment when the first byte of the time message is first received, the timer is used to record the first current moment in microseconds, and the first byte transmission time is calculated based on the current baud rate of the external clock source.
[0100] After the external clock source receives the complete message sent by the GPS clock, it parses the message at the second moment to obtain the first time value, uses the internal timer to record the second current moment in microseconds, and calculates the second real time according to the following formula:
[0101] ta=t0+(ut2-ut1+dut0) / 1000;
[0102] The calculation result is retained in ms. The remainder of (ut2-ut1+dut0)%1000 is directly assigned to the internal auto-timer to compensate for the error within milliseconds. The error can be controlled to be less than 20us.
[0103] The external clock source keeps time based on the current time.
[0104] In addition, in one embodiment, referring to Figure 3 ,exist Figure 1 Step S14 of the illustrated embodiment also includes but is not limited to the following steps:
[0105] Step S31: the external clock source responds to the time synchronization request message sent by the intelligent power distribution terminal and obtains a fourth time value according to the third time value and a preset number of milliseconds;
[0106] Step S32: arranging the fourth time value into a time response message, and confirming whether the smart power distribution terminal is at the fourth moment;
[0107] Step S33: When the intelligent power distribution terminal is at the fourth moment, the start bit of the first byte of the time synchronization response message is sent at the fourth moment;
[0108] In step S34, the preset terminal device and timer drive the start bit of the first byte of the time synchronization response message to adjust the control error of the time synchronization response message.
[0109] It should be noted that after the external clock source receives the time synchronization request message sent by the intelligent power distribution terminal, it will convert the current time (t3+1ms) into a time synchronization response message at the third moment, and send the start bit of the first byte of the message (including the time content of t4) at the next millisecond self-running interrupt t4 (integer millisecond t4=t3+1). Through the interrupt system and timer drive, the error is controlled to be less than 30us
[0110] In addition, in one embodiment, referring to Figure 4 ,exist Figure 1 Step S15 of the illustrated embodiment also includes but is not limited to the following steps:
[0111] Step S41: When the intelligent power distribution terminal receives a synchronization message from an external clock source, it determines a first reception completion time of the first byte of the synchronization message;
[0112] Step S42: Record the third current moment of the first receiving completion moment in microseconds, and calculate the second byte transmission time of the first byte according to the current baud rate of the intelligent power distribution terminal and the third current moment;
[0113] Step S43, parsing the synchronization message at the fifth time value to obtain a fourth time value;
[0114] Step S44, recording the fourth time value as a fourth current moment in microseconds, and calculating a first real-time time of the synchronization message based on the third current moment, the fourth current moment, the second byte transmission time, and the fifth time value;
[0115] Step S45 : The external clock source performs self-timing according to the first real-time time to write the second current time value into the real-time clock.
[0116] It should be noted that when the intelligent distribution terminal receives the time synchronization response message from the external clock source at the serial port, at the first reception completion moment of the first byte of the time synchronization corresponding message, it uses the internal timer to record the third current moment in microseconds, and calculates the second byte transmission time of one byte based on the current baud rate of the external clock source.
[0117] After receiving the complete message from the external clock source, the intelligent power distribution terminal parses the message at the third current moment to obtain a fourth time value, uses an internal timer to record the fourth current moment in microseconds, and calculates the first real-time time according to the following formula:
[0118] tb=t4+(ut6-ut5+dut2) / 1000;
[0119] The calculation result is retained in ms. The remainder of (ut6-ut5+dut2)%1000 is directly assigned to the internal automatic timer to compensate for the error within milliseconds. The error can be controlled to be less than 40us.
[0120] The intelligent power distribution terminal performs self-propelled timing based on the first real-time time.
[0121] In addition, in one embodiment, referring to Figure 5 ,exist Figure 4 After step S45 in the illustrated embodiment, the following steps are also included but not limited to:
[0122] Step S51, obtaining the byte transmission rate and the number of byte transmissions of the intelligent power distribution terminal, and calculating the third byte transmission time of the communication bus according to the byte transmission rate and the number of byte transmissions;
[0123] Step S52, starting a timer according to the third byte transmission time, and controlling the timer to generate an interrupt according to the first real time, the third byte transmission time, and a first preset number of seconds;
[0124] Step S53, when the timer is interrupted, the second current moment and the first preset description of the whole second time are written into the real-time clock, so that the sixth time value written into the real-time clock is equal to the whole second time.
[0125] It should be noted that since the time of the intelligent distribution terminal and the real-time clock is written into the time data through the communication bus, the third byte transmission time of the communication bus is calculated through the transmission rate (for example, 1MBPS) and the number of bytes, and a timer is started to control the interruption at the moment of tb (first real-time time) + 2s (first preset seconds) - dtu3 (third byte transmission time), and write the whole second time of tb (first real-time time) + 2s to the real-time clock, so that the moment t7 when the real-time clock receives the write clock command is exactly equal to the whole second time of tb+2s, so that the control error is less than 50us.
[0126] In addition, in one embodiment, referring to Figure 6 ,exist Figure 5 After step S53 in the illustrated embodiment, the following steps are also included but not limited to:
[0127] Step S61: The intelligent power distribution terminal is powered off and then powered on again, and the fourth byte transmission time after the intelligent power distribution terminal is powered on again is calculated based on the byte transmission rate and the number of bytes transmitted;
[0128] Step S62: The smart power distribution terminal is adjusted to a cyclic countdown mode until the current countdown time value obtained by the smart power distribution terminal after two consecutive countdowns changes by a second, and the current countdown time value read last is set as the current second time of the smart power distribution terminal;
[0129] In step S63, the timer is initialized with half the fourth byte transmission time to adjust the error between the real-time clock and the customizer.
[0130] It should be noted that when the intelligent power distribution terminal is powered on again, the time of the internal real-time clock is read through the communication bus (resolution in seconds). The fourth byte transmission time dut4 of the communication bus can be calculated through the transmission rate (for example, 1MBPS) and the number of bytes. Generally, dtu4 is less than 100us. The intelligent power distribution terminal adopts a cyclic reading time until the time of two consecutive readings changes by seconds. The time of the last reading is set as the current second time tc, and the self-running millisecond timer is initialized with half the time of the fourth byte transmission time dut4 (0.5*dtu4) to realize the internal precise millisecond timer, and then the control error is less than 50us+50us=100us, that is, the error does not exceed 0.1ms
[0131] In addition, in one embodiment, referring to Figure 7 ,exist Figure 6 After step S61 in the illustrated embodiment, the following steps are also included but not limited to:
[0132] Step S71, when the intelligent power distribution terminal loses power, the real-time clock maintains the automatic running time of the intelligent power distribution terminal;
[0133] Step S72: After the intelligent power distribution terminal is powered on again, the intelligent power distribution terminal reads the second real-time time of the real-time clock.
[0134] It is important to ensure that the intelligent power distribution terminal can still record the passage of time during a power outage. When power is restored, the second real-time time read will remain continuous with the time before the power outage, without time gaps or jumps. This provides a continuous and accurate time reference for subsequent time-related operations and data recording. Accurate chronological recording of various events in the intelligent power distribution system, such as fault occurrences and protection activations, is crucial. Even in the event of a power outage, the real-time clock's self-timer function ensures accurate timestamp recording of these events. The time read after power is restored can be used to accurately analyze the chronological order of events, facilitating rapid fault location and analysis of system operation.
[0135] like Figure 8 As shown, Figure 8This is a structural diagram of a high-precision synchronous clock device without PPS pulses provided by one embodiment of the present invention. The present invention also provides a high-precision synchronous clock device without PPS pulses, comprising:
[0136] The processor 801 may be implemented as a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is configured to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0137] The memory 802 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 802 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 802 and is called by the processor 801 to execute the high-precision synchronous clock method without PPS pulses in the embodiments of this application.
[0138] Input / output interface 803, used to implement information input and output;
[0139] Communication interface 804, used to implement communication interaction between the apparatus and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.);
[0140] Bus 805 , which transmits information between various components of the device (e.g., processor 801 , memory 802 , input / output interface 803 , and communication interface 804 );
[0141] The processor 801 , the memory 802 , the input / output interface 803 and the communication interface 804 are connected to each other in communication within the device via a bus 805 .
[0142] An embodiment of the present application further provides an electronic device, comprising the high-precision synchronous clock device without PPS pulses as described above.
[0143] An embodiment of the present application further provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the above-mentioned high-precision synchronous clock method without PPS pulses is implemented.
[0144] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory optionally includes a memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of the above-mentioned networks include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and are located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0145] Those skilled in the art will appreciate that all or some of the steps and systems in the method disclosed above can be implemented as software, firmware, hardware, and appropriate combinations thereof. Some physical components or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, and the computer-readable medium can include computer storage media (or non-transitory media) and communication media (or temporary media). As known to those skilled in the art, the term computer storage media is included in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data) and is volatile and non-volatile, removable, and non-removable. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory, or other memory technology, CD-ROM, digital versatile disks (DVD), or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage, or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically includes computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0146] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above implementation. Those skilled in the art can also make various equivalent modifications or substitutions under the shared conditions that do not violate the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present invention.
Claims
1. A high-precision synchronous clock method without PPS pulse, characterized in that: include: Obtaining time error information between an external clock source and a GPS clock, and generating a time message based on the time error information; confirming that the GPS clock sends a first time value of the time message and a second time value of the time message, wherein the first time value represents a falling edge of a start bit of a first byte of the time message; When the external clock source receives the completion signal sent by the GPS clock, the external clock source responds to the time synchronization request of the smart power distribution terminal, parses the time message at a preset first moment, obtains a third time value, and obtains a first delay error of the smart power distribution terminal according to the first time value, the second time value, and the third time value; The current time information of the GPS clock is confirmed according to the first delay error. The external clock source performs self-timer according to the current time information. When the external clock source receives the time synchronization request message sent by the intelligent power distribution terminal, it obtains a fourth time value at the second moment, organizes the fourth time value into a synchronization message, and sends the synchronization message to the intelligent power distribution terminal at a third moment. The intelligent power distribution terminal parses the synchronization message to obtain a second delay error of the synchronization message, and confirms a first current time value of the synchronization message according to the second delay error; The first current time value is written into the real-time clock of the intelligent power distribution terminal, and the second current time value of the real-time clock is re-read.
2. The high-precision synchronous clock method without PPS pulse according to claim 1, characterized in that The obtaining of time error information between the external clock source and the GPS clock includes: confirming that the GPS clock sends the first time value of the time message at a first shift moment of an integer number of milliseconds, and that the content of the time message is the second time value; When the external clock source reads the time message, it confirms the first reception completion time of the first byte, and the real-time clock records the first current time of the first reception completion time in microseconds; Obtaining the current baud rate at the first moment, and calculating the first byte transmission time of the first byte; After receiving the complete time message sent by the GPS clock, the intelligent power distribution terminal parses the time message at the second moment to obtain the first time value, and calculates the second current moment according to the first time value.
3. The high-precision synchronous clock method without PPS pulse according to claim 1, characterized in that Arranging the fourth time value into a synchronization message includes: The external clock source obtains the fourth time value according to the third time value and a preset number of milliseconds in response to the time synchronization request message sent by the intelligent power distribution terminal; Arrange the fourth time value into a time response message, and confirm whether the intelligent power distribution terminal is at the fourth time; When the intelligent power distribution terminal is at the fourth moment, sending the start bit of the first byte of the time synchronization response message at the fourth moment; The preset terminal device and timer drive the start bit of the first byte of the time synchronization response message to adjust the control error of the time synchronization response message.
4. The high-precision synchronous clock method without PPS pulse according to claim 1, characterized in that: The intelligent power distribution terminal parses the synchronization message, including: When the intelligent power distribution terminal receives the synchronization message from the external clock source, determining a first reception completion time of the first byte of the synchronization message; Recording a third current moment of the first receiving completion moment in microseconds, and calculating a second byte transmission time of the first byte according to a current baud rate of the intelligent power distribution terminal and the third current moment; Parsing the synchronization message at the fifth time value to obtain the fourth time value; Recording the fourth time value as a fourth current moment in microseconds, and calculating a first real time of the synchronization message based on the third current moment, the fourth current moment, the second byte transmission time, and the fifth time value; The external clock source performs self-timing according to the first real-time time to write the second current time value into the real-time clock.
5. The high-precision synchronous clock method without PPS pulse according to claim 4, characterized in that: After writing the second current time value into the real-time clock, the method further includes: Acquire the byte transmission rate and the number of byte transmissions of the intelligent power distribution terminal, and calculate the third byte transmission time of the communication bus according to the byte transmission rate and the number of byte transmissions; Starting the timer according to the third byte transmission time, and controlling the timer to generate an interrupt according to the first real time, the third byte transmission time and a first preset number of seconds; When the timer is interrupted, the second current moment and the first preset described whole second time are written into the real-time clock, so that the sixth time value written into the real-time clock is equal to the whole second time.
6. The high-precision synchronous clock method without PPS pulse according to claim 5, characterized in that: After making the sixth time value written by the real-time clock equal to the whole second time, the method further includes: Powering off and then powering on the intelligent power distribution terminal, and calculating a fourth byte transmission time after the intelligent power distribution terminal is powered on again according to the byte transmission rate and the number of bytes transmitted; Adjust the intelligent power distribution terminal to count down in a loop until the current countdown time value obtained by the intelligent power distribution terminal after two consecutive countdowns changes by seconds, and set the current countdown time value read last time as the current second time of the intelligent power distribution terminal; The timer is initialized with half the fourth byte transmission time to adjust the error between the real-time clock and the presetter.
7. The high-precision synchronous clock method without PPS pulse according to claim 6, characterized in that: After the intelligent power distribution terminal is powered off and then powered on again, the method further includes: When the intelligent power distribution terminal loses power, the real-time clock maintains the automatic running time of the intelligent power distribution terminal; When the intelligent power distribution terminal is powered on again, the intelligent power distribution terminal reads the second real-time time of the real-time clock.
8. A high-precision synchronous clock device without PPS pulse, characterized in that: comprising at least one control processor and a memory for communicatively coupling with the at least one control processor; The memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to perform the high-precision synchronous clock method without PPS pulses according to any one of claims 1 to 7.
9. An electronic device, characterized in that: A high-precision synchronous clock device without PPS pulses as described in claim 8.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the high-precision synchronous clock method without PPS pulses according to any one of claims 1 to 7.
Citation Information
Patent Citations
Clock synchronization method and device based on SNTP and PPS
CN114614935A
Time synchronization method and device, time synchronization equipment and readable storage medium
CN118740301A
Method and apparatus for monitoring ethernet clock synchronization
WO2016004644A1