Method, device and relay protection device for determining timestamp

By using counters and comparison registers in the time synchronization of the power system, combined with crystal oscillator, the accuracy of timestamps is improved, the problem of insufficient time synchronization accuracy in the prior art is solved, and high-precision time synchronization in microseconds is achieved.

CN115765906BActive Publication Date: 2025-03-04SIEMENS POWER AUTOMATION
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211307907.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-25
Publication Date
2025-03-04
Estimated Expiration
2042-10-25

AI Technical Summary

Technical Problem

When the prior art performs time synchronization in power systems, the accuracy is insufficient, and usually only reaches the millisecond level, and cannot meet the high precision requirements of the microsecond level.

Method used

By using a counter and a comparison register in the first component, combined with the oscillation period of the crystal oscillator, the first time in the target time accuracy is determined, thereby improving the accuracy of the timestamp.

Benefits of technology

Without changing the hardware design, the accuracy of determining the timestamp is improved to reach the microsecond level, meeting the high-precision requirements of the power system for time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115765906B_ABST
    Figure CN115765906B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device and relay protection device for determining a timestamp, wherein a first component corresponds to a counter, a comparison register and a crystal oscillator, and the method comprises: if it is identified that the first component performs a first operation for a first message, a first time is determined according to a first current value of the counter and a current value of the comparison register, the first time is used to represent the time of the target time accuracy of the first component when performing the first operation, the target time accuracy is higher than the reference time accuracy, the reference time accuracy is the highest time accuracy that can be determined by the first component, the update period of the counter value is equal to the oscillation period of the crystal oscillator, the value of the counter is equal to the value of the comparison register every time a reference time accuracy passes, and the update period of the value of the comparison register is 1 reference time accuracy; the target time for the first component to perform the first operation is determined according to the first time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of time synchronization, and in particular to a method, a device and a relay protection device for determining a timestamp. Background Art

[0002] Accurate and unified time is the most basic requirement of the power system. Unified and accurate time is an important measure to ensure the safe operation of the power system and improve the operation level. For example, a relay protection device with a recording function needs to keep the time consistent with the corresponding equipment. In the event of an accident, the cause and process of the accident can be accurately analyzed based on the sequence and accurate time of the actions of each switch and circuit breaker.

[0003] When each device in the power system performs time synchronization, it can all be synchronized according to a master clock device. PTP (Precision Time Protocol) is a time synchronization protocol, which can be used for high-precision time synchronization between devices. Many power systems use the PTP protocol to calibrate the clock. For example, the master clock device sends PTP messages to other devices for time synchronization. During the clock calibration process, it is necessary to collect the time when the message is sent from the master clock device as a timestamp and the time when the device in the power system receives the message as another timestamp, and then synchronize the clocks of the devices in the power system based on the timestamp.

[0004] There are two ways to calibrate the slave clock time based on the PTP protocol: hardware and software. The software method is more versatile and can be applied to all hardware devices. Specifically, the timestamp can be obtained from the network layer of the time synchronization system, such as from the application layer or driver layer. However, its time synchronization accuracy is much lower than that of the hardware method, and can only achieve millisecond-level synchronization accuracy, such as 1ms or even 10ms. Summary of the invention

[0005] In view of this, the present invention proposes a method for determining a timestamp, wherein a first component corresponds to a counter, a comparison register and a crystal oscillator, and the method comprises:

[0006] If it is identified that the first component performs a first operation for a first message, a first time is determined according to the first current value of the counter and the current value of the comparison register, the first time is used to represent the time of the target time accuracy of the first component when performing the first operation, the target time accuracy is higher than the reference time accuracy, the reference time accuracy is the highest time accuracy that can be determined by the first component, the update period of the value of the counter is equal to the oscillation period of the crystal oscillator, the value of the counter is equal to the value of the comparison register every time a reference time accuracy passes, and the update period of the value of the comparison register is 1 reference time accuracy;

[0007] A target time for the first component to perform the first operation is determined according to the first time.

[0008] According to the method as described above, optionally, determining a first time according to the first current value of the counter and the current value of the comparison register includes:

[0009] Obtaining a first current value of the counter, wherein the first current value of the counter is generated according to a first portion, wherein the first portion corresponds to the number of oscillations of the crystal oscillator;

[0010] Obtaining a current value of the comparison register, where the current value of the comparison register is generated according to a second part, where the second part is n*f, where f is a frequency value of the crystal oscillator, and n is a positive integer;

[0011] The first time is determined according to the acquired first current value of the counter and the current value of the comparison register.

[0012] According to the method as described above, optionally, determining the first time according to the acquired first current value of the counter and the current value of the comparison register includes:

[0013] The first time=(f-|tick-curCMP|)*1000 / f, where tick is the first current value of the counter and curCMP is the current value of the comparison register.

[0014] According to the method as described above, optionally, it also includes:

[0015] If it is determined that the current value of the counter is equal to the current value of the comparison register, the value of n is updated to n+1 as the updated value of n, and the value of the comparison register is triggered to be updated according to the updated value of n.

[0016] According to the method as described above, optionally, the target time accuracy is microseconds, and the reference time accuracy is milliseconds; or

[0017] The first component performing a first operation on a first message includes: the first component receiving the first message or the first component sending the first message.

[0018] According to the method as described above, optionally, determining a target time for the communication board to perform the first operation according to the first time includes:

[0019] If it is identified that the first component performs a first operation on a first message, determining a current second time from the network layer of the time synchronization system;

[0020] The target time is determined according to the following formula: the target time=the second time+the first time.

[0021] According to the method as described above, optionally, the method further comprises:

[0022] If a second component is identified to have received the first message sent by the first component, a second current value of the counter is obtained, the second component corresponding to the counter, the comparison register and the crystal oscillator;

[0023] Obtain a delay time according to the first current value and the second current value, wherein the delay time=|tick–tick1|*1000 / f, wherein tick is the first current value of the counter, tick1 is the value of the counter when the counter has the second current value, and f is the frequency of the crystal oscillator;

[0024] The time when the second component receives the first message is determined according to the target time and the delay time.

[0025] According to the method as described above, optionally, the first message is generated based on the PTP protocol; or

[0026] After determining the target time for the first component to perform the first operation according to the first time, the method further includes:

[0027] It is determined whether a clock of the first target component needs to be corrected according to the target time.

[0028] The present invention also provides a device for determining a timestamp, a first component corresponding to a counter, a comparison register and a crystal oscillator, and the device comprises:

[0029] a first determination unit, configured to determine a first time according to a first current value of the counter and a current value of the comparison register if it is identified that the first component performs a first operation on a first message, wherein the first time is used to represent a time of a target time precision of the first component when performing the first operation, the target time precision is higher than a reference time precision, the reference time precision is a highest time precision that can be determined by the first component, an update period of the value of the counter is equal to an oscillation period of the crystal oscillator, the value of the counter is equal to the value of the comparison register every time a reference time precision passes, and an update period of the value of the comparison register is 1 reference time precision;

[0030] A second determining unit is used to determine a target time for the first component to perform the first operation according to the first time.

[0031] According to the device as described above, optionally, the first determining unit includes:

[0032] a first acquisition subunit, configured to acquire a first current value of the counter, wherein the first current value of the counter is generated according to a first portion, wherein the first portion corresponds to the number of oscillations of the crystal oscillator;

[0033] a second acquisition subunit, configured to acquire a current value of the comparison register, wherein the current value of the comparison register is generated according to a second part, wherein the second part is n*f, where f is a frequency value of the crystal oscillator and n is a positive integer;

[0034] A first determining subunit is used to determine the first time according to the acquired first current value of the counter and the current value of the comparison register.

[0035] According to the device as described above, optionally, the first determining subunit is specifically configured to:

[0036] First time=(f-|tick-curCMP|)*1000 / f, where tick is the first current value of the counter and curCMP is the current value of the comparison register; or

[0037] The device also includes an update unit, which is used to update the value of n to n+1 as the updated value of n if it is determined that the current value of the counter is equal to the current value of the comparison register, and trigger the value of the comparison register to be updated according to the updated value of n.

[0038] According to the device as described above, optionally, the target time accuracy is microseconds, and the reference time accuracy is milliseconds; or

[0039] The first component performing a first operation on a first message includes: the first component receiving the first message or the first component sending the first message; or

[0040] The device also includes:

[0041] A synchronization unit is used to determine whether the clock of the first target component needs to be corrected according to the target time.

[0042] According to the device as described above, optionally, the second determining unit is specifically configured to:

[0043] If it is identified that the first component performs a first operation on a first message, determining a current second time from the network layer of the time synchronization system;

[0044] The target time is determined according to the following formula: the target time=the second time+the first time.

[0045] According to the device as described above, optionally, it further comprises:

[0046] a first acquisition unit, configured to acquire a second current value of the counter if it is identified that a second component receives the first message sent by the first component, the second component corresponding to the counter, the comparison register and the crystal oscillator;

[0047] a second acquisition unit, configured to acquire a delay time according to the first current value and the second current value, wherein the delay time=|tick–tick1|*1000 / f, wherein tick is the first current value of the counter, tick1 is the value of the counter when the counter has the second current value, and f is the frequency of the crystal oscillator;

[0048] A third determining unit is used to determine the time when the second component receives the first message according to the target time and the delay time.

[0049] The present invention further provides a relay protection device, comprising any of the above-mentioned devices for determining a timestamp.

[0050] The present invention further provides a device for determining a timestamp, comprising:

[0051] at least one memory for storing instructions;

[0052] At least one processor is configured to execute the method for determining a timestamp according to any one of the above items according to instructions stored in the memory.

[0053] The present invention further provides a readable storage medium, wherein the readable storage medium stores machine-readable instructions. When the machine-readable instructions are executed by a machine, the machine executes the method for determining a timestamp as described in any one of the above items.

[0054] According to the present invention, the first time at the target time accuracy can be determined through the counter and comparison register in the first component. The target time accuracy is higher than the highest time accuracy that can be determined by the first component itself. Therefore, without changing the hardware design, the time accuracy of determining that the first component performs the first operation on the first message can be improved, thereby improving the accuracy of the timestamp. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings so that the above and other features and advantages of the present invention will be more apparent to those skilled in the art. In the accompanying drawings:

[0056] Figure 1 FIG. 4 is a flow chart of a method for determining a timestamp according to an embodiment of the present invention.

[0057] Figure 2 FIG. 4 is a flow chart of a method for determining a timestamp according to another embodiment of the present invention.

[0058] Figure 3 FIG. 4 is a flow chart of a method for determining a timestamp according to another embodiment of the present invention.

[0059] Figure 4A FIG. 4 is a schematic diagram of the structure of a device for determining a timestamp according to an embodiment of the present invention.

[0060] Figure 4B FIG. 4 is a schematic diagram of the structure of an apparatus for determining a timestamp according to another embodiment of the present invention.

[0061] Figure 5 FIG. 4 is a schematic diagram of the structure of an apparatus for determining a timestamp according to yet another embodiment of the present invention.

[0062] Figure 6 FIG. 4 is a schematic diagram of the structure of an apparatus for determining a timestamp according to another embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail with reference to the following embodiments.

[0064] Time accuracy is a classification based on the time measurement required by each user, and is a method used for measurement. Time accuracy can be divided into the following levels: picoseconds (ps), nanoseconds (ns), microseconds (us), milliseconds (ms), seconds (s), minutes (min), and hours (h), with their accuracy decreasing in sequence. For example, the accuracy of picoseconds is higher than that of nanoseconds, and the accuracy of nanoseconds is higher than that of microseconds, and so on.

[0065] The power system includes a target device, which is, for example, a relay protection device. The target device may also include a first component. The target device has a timer, which includes a counter, a comparison register, and a crystal oscillator. The master clock device and the first component can be synchronized through a PTP message. The first component corresponds to the timer and the comparison register in the target device. More specifically, the first component may be a communication board for receiving and sending messages. When the master clock device sends a message based on the PTP protocol to the first component, a first timestamp is recorded to indicate the time when the message is sent. When the first component receives the message sent by the master clock device based on the PTP protocol, a second timestamp is recorded to indicate the time when the message is received. Similarly, when the first component sends the message based on the PTP protocol, a timestamp is also recorded to indicate the time when the message is sent.

[0066] Since timestamps have many functions, such as clock synchronization and encryption, the accuracy of timestamps is very important.

[0067] Embodiment 1

[0068] This embodiment provides a method for determining a timestamp, wherein the first component corresponds to a counter, a comparison register, and a crystal oscillator. The execution subject of this embodiment is a device for determining a timestamp, which may be located in a target device where the first component is located. The target device may be a relay protection device.

[0069] Step 101, if it is identified that the first component performs a first operation on a first message, a first time is determined according to the first current value of the counter and the current value of the comparison register. The first component may be a communication board capable of receiving or sending messages, and the specific implementation of the first component belongs to the prior art and will not be described here. The first message may be specifically transmitted based on the PTP protocol. In addition, the first message may also be a message sent by a master clock device for correcting the clock of the first component, or a message sent by other devices, which is not limited here.

[0070] The first time here is used to represent the time of the target time accuracy of the first component when performing the first operation. For example, if the target time accuracy is microseconds, then the time of the target time accuracy is the time at the microsecond level. The target time accuracy is higher than the reference time accuracy. The reference time accuracy is the highest time accuracy that the first component can determine. The update period of the counter value is equal to the oscillation period of the crystal oscillator. The oscillation period is the inverse of the crystal oscillator frequency of the crystal oscillator, that is, the value of the counter is updated once every time the crystal oscillator oscillates once. In addition, every time a reference time accuracy passes, the value of the counter is equal to the value of the comparison register, and the update period of the value of the comparison register is 1 reference time accuracy, that is, every time the number of times the crystal oscillator oscillates is equal to the frequency value of the crystal oscillator, the value of the counter is equal to the value of the comparison register, and then the value of the comparison register is updated once. 1 reference time accuracy is, for example, 1 millisecond.

[0071] The first component performs a first operation on the first message, which may be the first component receiving the first message or the first component sending the first message. When the device for determining the timestamp recognizes that the first component performs the first operation, it immediately obtains the first current value of the counter and the current value of the comparison register.

[0072] For the counter, its value is updated once, for example, minus 1, every time the crystal oscillator oscillates once. For the comparison register, the number of times the crystal oscillator oscillates is equal to its frequency value, and the value of the comparison register is updated once. As an exemplary illustration, the target time accuracy can be microseconds, and the reference time accuracy is milliseconds. For example, if the crystal oscillator frequency is 66000Hz and the reference time accuracy is 1ms, the counter value is updated once every 1 / 66000 milliseconds, and the comparison register value is updated once every 1ms. Every time the crystal oscillator oscillates 66000 times, the values ​​of the counter and the comparison register are equal. When it is identified that the values ​​of the counter and the comparison register are equal, the value of the comparison register is triggered to be updated, and after the crystal oscillator oscillates 66000 times again, it is identified that the values ​​of the counter and the comparison register are equal again, and then the value of the comparison register is triggered to be updated. Of course, when it is recognized that the values ​​of the counter and the comparison register are equal, both can be triggered to restore to the default values. For example, the default value of the counter is 100000, and the default value of the comparison register is 34000. If it is recognized that the two values ​​are equal, both values ​​are reset to the default values. The specific method can be determined according to the characteristics of different timers, which will not be repeated here.

[0073] Since the value of the timer is updated at the target time accuracy, for example, at the time accuracy at the microsecond level, and the value of the comparison register is updated at the millisecond level, the first time of the target time accuracy can be determined based on the values ​​of the two.

[0074] In this embodiment, the mode of the timer is a free-running mode.

[0075] Step 102: Determine a target time for a first component to perform a first operation according to the first time.

[0076] If it is identified that the first component performs the first operation on the first message, a current second time can be immediately determined from the network layer. The second time is the time with the highest accuracy that can be directly determined by the clock of the target device.

[0077] The first time refers to the time at the target time accuracy for the first component. Therefore, the target time for the first component to perform the first operation is a second time that the first component itself can determine plus the first time.

[0078] The target time includes not only the time at the reference time accuracy but also the time at the target time accuracy.

[0079] After step 102, the method may further include: determining whether the first clock of the first component needs to be corrected according to the target time. For example, if it is identified that the deviation between the target time and the time of the master clock device exceeds a preset threshold, it is determined that the first clock of the first component needs to be corrected, for example, by transmitting a synchronization message between the master clock device and the target device. The specific correction method belongs to the prior art and will not be described in detail here.

[0080] It should be noted that, since the timestamp of the first message by the master clock device and the target device is required during the calibration process, the accuracy of the timestamp is improved, which is equivalent to improving the accuracy of clock synchronization.

[0081] According to the present invention, the first time at the target time accuracy can be determined through the counter and comparison register in the first component. The target time accuracy is higher than the highest time accuracy that can be determined by the first component itself. Therefore, without changing the hardware design, the time accuracy of determining that the first component performs the first operation on the first message can be improved, thereby improving the accuracy of the timestamp.

[0082] Embodiment 2

[0083] This embodiment further supplements the method for determining the timestamp in the first embodiment.

[0084] In this embodiment, the target device also includes a second component, which is, for example, a mainboard for processing data. The second component also has its own clock, that is, when the second component receives or sends a message, it will also record the corresponding timestamp according to its own clock. The second component can communicate with the first component. For example, the first component processes the received first message, for example, converts it into a message corresponding to the protocol used for communication with the second component, and sends the processed first message to the second component for clock calibration. Although the first component and the second target are both located in the same target device, they each have their own clocks to meet different needs.

[0085] In this embodiment, since the time at the target time accuracy can be obtained, the time delay between the first component and the second component can also be calculated.

[0086] like Figure 2 As shown, the method for determining a timestamp in this embodiment further includes:

[0087] Step 201, if it is identified that a second component receives a first message sent by a first component, then a second current value of a counter is obtained, and the second component corresponds to a counter, a comparison register and a crystal oscillator.

[0088] The device for determining the timestamp can immediately obtain the second current value of the counter after recognizing that the second component receives the first message sent by the first component.

[0089] The second component corresponds to a counter, a comparison register and a crystal oscillator, which means that the second component and the first component can calculate the subsequent delay time based on the same counter, the comparison register and the crystal oscillator, and it can also be explained that the two are actually located in the same target device, or the physical locations of the two are very close.

[0090] Step 202: Obtain a delay time according to the first current value and the second current value.

[0091] As an exemplary illustration, the delay time = |tick−tick1|*1000 / f, where tick is the first current value of the counter, tick1 is the value of the counter at the second current value of the counter, and f is the frequency of the crystal oscillator.

[0092] For example, if tick 1 is 14200, tick is 1000, and f is 66000hz, then the delay time is (14200-1000)*1000 / 66000=200 microseconds. In this way, the delay time is 200 microseconds.

[0093] Step 203: Determine the time when the second component receives the first message according to the target time and the delay time.

[0094] Specifically, the second time plus the delay time is the time when the second component receives the first message. For example, the second time when the first component receives the first message is 15:10:06.117, that is, 15:10:06:117, that is, 117 milliseconds, the first time is 888 microseconds, and the delay time is 200 microseconds. Then, the time when the second component receives the first message is 15:10:06.118.88, that is, 15:10:06:118:88. In this way, the clock corresponding to the second component can be corrected according to the time when the first message is received.

[0095] According to this embodiment, by calculating the time delay between the first component and the second component when transmitting the first message, the precise time when the second component receives the first message is determined, which not only improves the time accuracy but also helps to improve the accuracy of time synchronization.

[0096] Embodiment 3

[0097] This embodiment further supplements the method for determining the timestamp in the first embodiment. This embodiment takes the first component receiving the first message sent by the master clock device as an example. The target device includes a first component and a second component.

[0098] like Figure 3 FIG. 1 is a flow chart of a method for determining a timestamp according to this embodiment. The method includes:

[0099] Step 301: Identify that a first component receives a first message sent by a master clock device based on the PTP protocol.

[0100] The first message may be a message for clock calibration, so that the clock of the first component is synchronized with the clock of the master clock device.

[0101] Step 302, obtaining a first current value of the counter, and obtaining a current value of the comparison register.

[0102] In this embodiment, the time at a target time precision can be determined by the first current value of the counter and the current value of the comparison register. The target time precision is higher than the reference time precision, and the reference time precision is the highest time precision that can be determined by the first component.

[0103] As an example, the first current value of the counter is generated according to a first part, which corresponds to the number of oscillations of the crystal oscillator. The current value of the comparison register is generated according to a second part, which is n*f, where f is the frequency value of the crystal oscillator and n is a positive integer.

[0104] For example, the values ​​of the counter and the comparison register are both in hexadecimal. The value of the counter is generated by subtracting the first part from the initial value. The default value of the initial value of the counter is 0xFFFFFFFF when expressed in hexadecimal, which corresponds to the value 4,294,967,295. The value of the counter = 0xFFFFFFFF-the number of oscillations of the crystal oscillator. The crystal oscillator frequency of the timer is 66000Hz, which means 66000 oscillations in 1 millisecond. In this way, the value of the counter is reduced by 1 every 1 / 66000 milliseconds. After 1 millisecond, the value of the counter = 4294967295-66000. If the value of the counter is equal to 0, the cycle ends and enters the next cycle, and the counter is restored to the default value. The value of the compare register is generated by subtracting the second part from the initial value. The default initial value of the compare register is 0xFFFFFFFF in hexadecimal, which corresponds to the value 4,294,967,295. The value of the compare register = 4294967295-n*66000, and the initial value of n is 1. Whenever the value of the counter is equal to the value of the compare register, the compare register can be triggered to update the value of n, that is, n+1 is used as the updated value of n. For example, after the crystal oscillator oscillates 66,000 times, it is recognized that the value of the counter is equal to the value of the compare register, and the value of the compare register can be triggered to update.

[0105] Step 303: determine a first time according to the first current value of the counter and the current value of the comparison register.

[0106] As an exemplary description, step 303 specifically uses the following formula to determine the first time:

[0107] First time = (f-|tick-curCMP|)*1000 / f, where tick is the first current value of the counter and curCMP is the current value of the comparison register.

[0108] As an exemplary illustration, the first time can be determined according to the first current value of the counter and the current value of the comparison register. For example, when the first component receives a message, the value of the counter = 4294967295-79200, the value of the comparison register = 4294967295-1*66000, then

[0109] The first time = (66000-|4294967295-79200-4294967295+1*66000|)*1000 / 66000=200 microseconds.

[0110] As another exemplary explanation, if the value of the counter is expressed in a form of retaining the first part and the value of the counter is expressed in a form of retaining the second part, the values ​​of the first part and the second part can be directly obtained for calculation, for example

[0111] The first time = |first part-second part|*1000 / 66000.

[0112] For example, if the value of the counter is expressed as 4294967295-79200, and the value of the comparison register is expressed as 4294967295-2*66000, then the first time=(79200-2*66000)*1000 / 6000=200 microseconds.

[0113] Step 304: determine a current second time from the network layer.

[0114] Specifically, a current second time can be determined from the network layer of the time synchronization system. It should be noted that the second time has no sequence with step 303 and step 304, and can be executed simultaneously.

[0115] Step 305: Determine a target time for the first component to perform the first operation according to the first time and the second time.

[0116] Target time = first time + second time.

[0117] For example, the first time is 200 microseconds, and the second time is 15:10:10:09 milliseconds, then the target time is 15:10:10:09 milliseconds 200 microseconds.

[0118] After determining the target time, it can be determined whether the clock of the first component needs to be calibrated based on the target time. If it is determined that the difference between the first clock and the main clock exceeds a preset threshold, calibration is required and can be performed according to existing technology.

[0119] How to determine whether the difference between the first clock and the main clock exceeds a preset threshold value based on the time when the first component receives the first message belongs to the prior art and will not be described in detail here.

[0120] The following steps are specific examples of the second embodiment.

[0121] Step 306: If it is identified that a second component receives the first message sent by the first component, a second current value of the counter is obtained.

[0122] If it is identified that the second component receives the first message sent by the first component, the second current value of the counter is obtained to be 4294967295-79464, and the first current value is 4294967295-79200.

[0123] Step 307: Obtain a delay time according to the first current value and the second current value.

[0124] Delay time = |tick–tick1|*1000 / f, where tick is the first current value of the counter, tick1 is the value of the counter when the current second time is determined, and f is the frequency of the crystal oscillator.

[0125] For example, delay time=(4294967295-79200-4294967295+79464)*1000 / 66000=4 microseconds. The delay time is the time taken for the first component and the second component to transmit the message.

[0126] Step 308: Determine the time when the second component receives the first message according to the target time and the delay time.

[0127] After the delay time is determined, the delay time is added to the target time to obtain the time when the second component receives the first message, and the time is the timestamp when the second component records the receipt of the first message.

[0128] According to this embodiment, when a synchronization message is received, the first time is obtained by using the values ​​of the counter and the comparison register, so that the arrival time of the message can be made more accurate without modifying the hardware design.

[0129] Embodiment 4

[0130] This embodiment specifically supplements the method for determining the timestamp in the above embodiment. This embodiment is described by taking the first component sending a first message based on the PTP protocol to the master clock device as an example.

[0131] In this embodiment, the frequency f of the crystal oscillator in the first component is 66000 Hz, that is, it oscillates 66000 times in 1 ms. The initial default value of the counter is 4294967295, and the initial default value of the comparison register is 4294967295-n*66000, and the initial value of n is 1. Every time the crystal oscillator oscillates once, the value of the counter is reduced by 1. Whenever the value of the counter is equal to the value of the comparison register, the device for determining the timestamp triggers the value of the comparison register to be updated, that is, n+1 and the value after n+1 is assigned to n. If the value of the counter is 0, the value of the counter is reset to the default value, and accordingly, the value of the comparison register is also reset to the default value. If the value of the counter is equal to the value of the comparison register, the value of the comparison register is triggered to be updated. For example, if the value of the counter is 4294967295-66000 and the value of the comparison register is 4294967295-1*66000, the value of the comparison register is updated to 4294967295-2*66000. Next, when the counter value is updated to 4294967295-132000, the value of the comparison register is updated to 4294967295-3*66000.

[0132] In this embodiment, the device for determining the timestamp identifies that the first component needs to send a first message based on the PTP protocol, then the device for determining the timestamp identifies the time of sending the first message as the timestamp, which time includes two parts, namely the first time and the second time.

[0133] The first time is determined according to (f-|tick-curCMP|)*1000 / f. Assuming that when it is recognized that the first message needs to be sent, the first current value tick of the counter is 4294967295-356400, and the current value curCMP of the comparison register is 4294967295-5*66000, then the first time = 400 microseconds.

[0134] The second time is determined from the network of the target device, for example, 7 hours, 6 minutes, 3 seconds and 4 milliseconds.

[0135] Finally, the target time for the first component to send the first message is 7 hours, 6 minutes, 3 seconds, 4 milliseconds, and 400 microseconds.

[0136] Embodiment 5

[0137] This embodiment provides a device for determining a timestamp. The device may be located in a target device. The target device has a first component, a counter, a comparison register, and a crystal oscillator. The first component corresponds to the counter, the comparison register, and the crystal oscillator. The target device may be a relay protection device.

[0138] like Figure 4A , which is a schematic diagram of the structure of a device for determining a timestamp according to this embodiment. The device includes a first determining unit 401 and a second determining unit 402 .

[0139] The first determination unit 401 is used to determine a first time according to the first current value of the counter and the current value of the comparison register if it is identified that the first component performs a first operation on a first message. The first time is used to represent the time of the target time accuracy of the first component when performing the first operation. The target time accuracy is higher than the reference time accuracy. The reference time accuracy is the highest time accuracy that can be determined by the first component. The update period of the counter value is equal to the oscillation period of the crystal oscillator. After each reference time accuracy, the value of the counter is equal to the value of the comparison register, and the update period of the comparison register value is 1 reference time accuracy. The second determination unit 402 is used to determine the target time for the first component to perform the first operation according to the first time.

[0140] Optionally, the target time precision is microseconds and the base time precision is milliseconds.

[0141] Optionally, the first component performing a first operation on a first message includes: the first component receiving the first message or the first component sending the first message.

[0142] Alternatively, if Figure 4B As shown, the device for determining a timestamp in this embodiment further includes a synchronization unit 403, and the synchronization unit 403 is used to determine whether the clock of the first target component needs to be corrected according to the target time.

[0143] The working methods of each unit in this embodiment are the same as those in the previous embodiment and will not be described again here.

[0144] According to the present invention, the first time at the target time accuracy can be determined through the counter and comparison register in the first component. The target time accuracy is higher than the highest time accuracy that can be determined by the first component itself. Therefore, without changing the hardware design, the time accuracy of determining that the first component performs the first operation on the first message can be improved, thereby improving the accuracy of the timestamp.

[0145] Embodiment 6

[0146] This example further supplements the device for determining a timestamp in the fifth embodiment.

[0147] like Figure 5 As shown, the first determining unit 401 in the apparatus for determining a timestamp of this embodiment includes a first acquiring subunit 4011 , a second acquiring subunit 4012 and a first determining subunit 4013 .

[0148] Among them, the first acquisition sub-unit 4011 is used to obtain the first current value of the counter, and the first current value of the counter is generated according to a first part, and the first part corresponds to the number of oscillations of the crystal oscillator; the second acquisition sub-unit 4012 is used to obtain the current value of the comparison register, and the current value of the comparison register is generated according to a second part, and the second part is n*f, where f is the frequency value of the crystal oscillator and n is a positive integer; the first determination sub-unit 4013 is used to determine the first time according to the acquired first current value of the counter and the current value of the comparison register.

[0149] Optionally, the first determining subunit 4013 is specifically configured to:

[0150] First time = (f-|tick-curCMP|)*1000 / f, where tick is the first current value of the counter and curCMP is the current value of the comparison register.

[0151] Optionally, if it is determined that the current value of the counter is equal to the current value of the comparison register, the value of n is updated to n+1 as the updated value of n, and the value of the comparison register is triggered to be updated according to the updated value of n.

[0152] Optionally, the second determining unit 402 is specifically configured to:

[0153] If it is identified that the first component performs a first operation on a first message, determining a current second time from a network layer of the time synchronization system;

[0154] The target time is determined according to the following formula: target time = second time + first time.

[0155] Alternatively, if Figure 5 As shown, the device for determining the timestamp of this embodiment also includes an update unit 501, which is used to update the value of n to n+1 as the updated value of n if it is determined that the current value of the counter is equal to the current value of the comparison register, and trigger the value of the comparison register to be updated according to the updated value of n.

[0156] The working methods of each unit in this embodiment are the same as those in the previous embodiment and will not be described again here.

[0157] This embodiment determines the first time through the values ​​of the counter and the comparison register and the update rule, and can improve the time accuracy of determining that the first component performs the first operation on the first message without changing the hardware design, thereby improving the accuracy of the timestamp.

[0158] Embodiment 7

[0159] This embodiment further supplements the device for determining a timestamp in the previous embodiment.

[0160] like Figure 6 , which is a schematic diagram of the structure of the device for determining a timestamp according to this embodiment. The device further includes a first acquisition unit 601 , a second acquisition unit 602 and a third determination unit 603 .

[0161] Among them, the first acquisition unit 601 is used to obtain the second current value of the counter if it is identified that a second component has received the first message sent by the first component, and the second component corresponds to the counter, the comparison register and the crystal oscillator; the second acquisition unit 602 is used to obtain a delay time according to the first current value and the second current value, and the delay time = |tick-tick1|*1000 / f, wherein tick is the first current value of the counter, tick1 is the value of the counter when the counter is the second current value, and f is the frequency of the crystal oscillator; a third determination unit 603 is used to determine the time when the second component receives the first message according to the target time and the delay time.

[0162] The working methods of each unit in this embodiment are the same as those in the previous embodiment and will not be described again here.

[0163] According to this embodiment, by calculating the time delay between the first component and the second component when transmitting the first message, the precise time when the second component receives the first message is determined, which not only improves the time accuracy but also helps to improve the accuracy of time synchronization.

[0164] The present invention also provides a relay protection device, which includes the device for determining a timestamp described in any of the above embodiments.

[0165] The present invention also provides a device for determining a timestamp, comprising at least one memory and at least one processor, wherein the memory is used to store instructions, and the processor is used to execute the method for determining a timestamp described in any of the above embodiments according to the instructions stored in the memory.

[0166] An embodiment of the present invention further provides a readable storage medium in which machine-readable instructions are stored, and when the machine-readable instructions are executed by a machine, the machine executes the method for determining a timestamp described in any of the above embodiments.

[0167] The readable medium stores machine-readable instructions, which, when executed by the processor, cause the processor to execute any of the aforementioned methods. Specifically, a system or device equipped with a readable storage medium may be provided, on which a software program code implementing the functions of any of the above-mentioned embodiments is stored, and a computer or processor of the system or device reads and executes the machine-readable instructions stored in the readable storage medium.

[0168] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above-mentioned embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute a part of the present invention.

[0169] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.

[0170] Those skilled in the art should understand that the various embodiments disclosed above can be modified and altered in various ways without departing from the essence of the invention. Therefore, the protection scope of the present invention should be defined by the appended claims.

[0171] It should be noted that not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The device structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.

[0172] In the above embodiments, the hardware unit can be realized by mechanical means or electrical means. For example, a hardware unit or a processor can include permanent dedicated circuits or logic (such as special processors, FPGA or ASIC) to complete the corresponding operation. The hardware unit or the processor can also include programmable logic or circuits (such as general-purpose processors or other programmable processors), which can be temporarily set by software to complete the corresponding operation. Concrete implementation (mechanical means or dedicated permanent circuits or temporarily set circuits) can be determined based on cost and time considerations.

[0173] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for determining a timestamp, a first component corresponding to a counter, a comparison register and a crystal oscillator, the method comprising: If it is identified that the first component performs a first operation for a first message, a first time is determined according to the first current value of the counter and the current value of the comparison register, the first time is used to represent the time of the target time accuracy of the first component when performing the first operation, the target time accuracy is higher than the reference time accuracy, the reference time accuracy is the highest time accuracy that can be determined by the first component, the update period of the value of the counter is equal to the oscillation period of the crystal oscillator, the value of the counter is equal to the value of the comparison register every time a reference time accuracy passes, and the update period of the value of the comparison register is 1 reference time accuracy; A target time for the first component to perform the first operation is determined according to the first time.

2. The method according to claim 1, characterized in that Determining a first time according to the first current value of the counter and the current value of the comparison register comprises: Obtaining a first current value of the counter, wherein the first current value of the counter is generated according to a first portion, wherein the first portion corresponds to the number of oscillations of the crystal oscillator; Obtaining a current value of the comparison register, where the current value of the comparison register is generated according to a second part, where the second part is n*f, where f is a frequency value of the crystal oscillator, and n is a positive integer; The first time is determined according to the acquired first current value of the counter and the current value of the comparison register.

3. The method according to claim 2, characterized in that Determining the first time according to the acquired first current value of the counter and the current value of the comparison register includes: The first time=(f-|tick-curCMP|)*1000 / f, where tick is the first current value of the counter and curCMP is the current value of the comparison register.

4. The method according to claim 2, characterized in that: Also includes: If it is determined that the current value of the counter is equal to the current value of the comparison register, the value of n is updated to n+1 as the updated value of n, and the value of the comparison register is triggered to be updated according to the updated value of n.

5. The method according to claim 1, characterized in that The target time precision is microseconds, and the reference time precision is milliseconds; or The first component performing a first operation on a first message includes: the first component receiving the first message or the first component sending the first message.

6. The method according to claim 1, characterized in that Determining a target time for the first component to perform the first operation according to the first time includes: If it is identified that the first component performs a first operation on a first message, determining a current second time from a network layer of the time synchronization system; The target time is determined according to the following formula: the target time=the second time+the first time.

7. The method according to claim 6, characterized in that The method further comprises: If a second component is identified to have received the first message sent by the first component, a second current value of the counter is obtained, the second component corresponding to the counter, the comparison register and the crystal oscillator; Obtain a delay time according to the first current value and the second current value, wherein the delay time=|tick–tick1|*1000 / f, wherein tick is the first current value of the counter, tick1 is the value of the counter when the counter has the second current value, and f is the frequency of the crystal oscillator; The time when the second component receives the first message is determined according to the target time and the delay time.

8. The method according to any one of claims 1 to 7, characterized in that The first message is generated based on the PTP protocol; or After determining the target time for the first component to perform the first operation according to the first time, the method further includes: It is determined whether a clock of the first target component needs to be corrected according to the target time.

9. A device for determining a time stamp, a first component corresponding to a counter, a comparison register and a crystal oscillator, the device comprising: a first determination unit, configured to determine a first time according to a first current value of the counter and a current value of the comparison register if it is identified that the first component performs a first operation on a first message, wherein the first time is used to represent a time of a target time precision of the first component when performing the first operation, the target time precision is higher than a reference time precision, the reference time precision is a highest time precision that can be determined by the first component, an update period of the value of the counter is equal to an oscillation period of the crystal oscillator, the value of the counter is equal to the value of the comparison register every time a reference time precision passes, and an update period of the value of the comparison register is 1 reference time precision; A second determining unit is used to determine a target time for the first component to perform the first operation according to the first time.

10. The device according to claim 9, characterized in that The first determining unit includes: a first acquisition subunit, configured to acquire a first current value of the counter, wherein the first current value of the counter is generated according to a first portion, wherein the first portion corresponds to the number of oscillations of the crystal oscillator; a second acquisition subunit, configured to acquire a current value of the comparison register, wherein the current value of the comparison register is generated according to a second part, wherein the second part is n*f, where f is a frequency value of the crystal oscillator and n is a positive integer; A first determining subunit is used to determine the first time according to the acquired first current value of the counter and the current value of the comparison register.

11. The device according to claim 10, characterized in that The first determining subunit is specifically used for: First time=(f-|tick-curCMP|)*1000 / f, where tick is the first current value of the counter and curCMP is the current value of the comparison register; or The device also includes an update unit, which is used to update the value of n to n+1 as the updated value of n if it is determined that the current value of the counter is equal to the current value of the comparison register, and trigger the value of the comparison register to be updated according to the updated value of n.

12. The device according to claim 9, characterized in that The target time precision is microseconds, and the reference time precision is milliseconds; or The first component performing a first operation on a first message includes: the first component receiving the first message or the first component sending the first message; or The device also includes: A synchronization unit is used to determine whether the clock of the first target component needs to be corrected according to the target time.

13. The device according to claim 9, characterized in that The second determining unit is specifically configured to: If it is identified that the first component performs a first operation on a first message, determining a current second time from a network layer of the time synchronization system; The target time is determined according to the following formula: the target time=the second time+the first time.

14. The device according to claim 13, characterized in that Also includes: a first acquisition unit, configured to acquire a second current value of the counter if it is identified that a second component receives the first message sent by the first component, the second component corresponding to the counter, the comparison register and the crystal oscillator; a second acquisition unit, configured to acquire a delay time according to the first current value and the second current value, wherein the delay time=|tick–tick1|*1000 / f, wherein tick is the first current value of the counter, tick1 is the value of the counter when the counter has the second current value, and f is the frequency of the crystal oscillator; A third determining unit is used to determine the time when the second component receives the first message according to the target time and the delay time.

15. A relay protection device, comprising the device for determining a timestamp according to any one of claims 9 to 14.

16. An apparatus for determining a timestamp, characterized in that include: at least one memory for storing instructions; At least one processor, configured to execute the method for determining a timestamp according to any one of claims 1 to 8 according to the instructions stored in the memory.

17. A readable storage medium, characterized in that: The readable storage medium stores machine-readable instructions. When the machine-readable instructions are executed by a machine, the machine executes the method for determining a timestamp according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Highly precised time synchronization device, system and method for computer network

    CN101388741A

  • Clock device based on timestamp and counters and achieving method thereof

    CN105717979A