A method, device, electronic device and storage medium for determining time
By counting the pulse signal of the GPS module, the time length is determined, and the error problem caused by the external environment is solved by the crystal oscillation frequency, and a higher accuracy time length measurement is achieved.
Patent Information
- Application Number
- CN202210237041.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-10
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2042-03-10
AI Technical Summary
In the prior art, when determining the time length by the crystal oscillation frequency, changes in the external environment lead to large errors, especially when the temperature changes, the time length determined by the timer is inaccurate.
The pulse signal of a known time length from the GPS module is used to count, determine the first count value, and calculate the time length required for each unit value to increase the pulse value according to the time length and count value of the pulse signal, and then determine the The length of time to be determined.
The accuracy of the time length is improved, and the accuracy is higher than the time length determined by the crystal oscillation frequency, reducing errors caused by environmental changes.
Smart Images

Figure CN114609891B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to a method, device, electronic device and storage medium for determining time. Background Art
[0002] At present, in the process of using hardware devices to determine the length of time within a certain period of time, the length of time within a certain period of time is usually determined based on the frequency of the crystal oscillation in the hardware device. However, since changes in the external environment (such as temperature changes) will have a certain impact on the oscillation frequency of the crystal oscillator, the length of time within a certain period of time determined in this way will have a large error. Summary of the invention
[0003] The embodiments of the present application provide a method, device, electronic device and storage medium for determining time, which can solve the problem of improving the accuracy of determining time.
[0004] In a first aspect, an embodiment of the present application provides a method for determining time, the method comprising: S1: counting during the duration of a first target pulse signal of a known time length from a GPS module to determine a first count value; S2: determining the length of time required for any count value to increase by one unit value based on the time length of the first target pulse signal and the first count value.
[0005] In a possible implementation of the first aspect, counting is performed during the duration of a first target pulse signal of a known time length from a GPS module to determine a first count value, including: counting between a first moment and a second moment during the duration of the first target pulse signal to determine the first count value, the first moment and the second moment are moments when the first target pulse signal changes, and the second moment is after the first moment.
[0006] In a possible implementation of the first aspect, the first moment is the moment corresponding to when the rising edge of the first target pulse signal is detected, or the moment corresponding to when the falling edge of the first target pulse signal is detected, and the second moment is the moment corresponding to when the rising edge of the first target pulse signal is detected, or the moment corresponding to when the falling edge of the first target pulse signal is detected.
[0007] In a possible implementation of the first aspect, counting is performed during the duration of a first target pulse signal of a known time length from a GPS module to determine a first count value, including: if no interruption occurs during the counting process during the duration of the first target pulse signal, the count value counted during the duration of the first target pulse signal is determined as the first count value; or, if an interruption occurs during the counting process during the duration of the first target pulse signal, the first count value is determined based on a preset count value, a second count value, and the number of interruptions during the counting process, the second count value being the count value counted after the last interruption in the counting process occurs, wherein, during the counting process during the duration of the first target pulse signal, an interruption occurs when the count value is equal to the preset count value.
[0008] In a possible implementation of the first aspect, before determining the first count value, the method also includes: after receiving indication information from the GPS module, determining the starting time of the first target pulse according to a pulse signal output by the GPS module after sending the indication information, the indication information indicating that the positioning of the GPS module is valid.
[0009] In a possible implementation of the first aspect, the method also includes: obtaining a time parameter of a third moment according to a preset protocol of the GPS module; determining a time parameter of a fourth moment according to the time parameter of the third moment, the length of time required for each unit value of any count value to increase, and the third count value, wherein the third count value is a count value counted from the third moment to the fourth moment.
[0010] In a possible implementation manner of the first aspect, after determining the time length required for any one of the count values to increase by one unit value, the method further includes: after each interval of a preset time length, looping through S1 to S2.
[0011] The present application determines a first count value by counting during the duration of a first target pulse signal of a known time length from a GPS module, and determines the time length required for any count value to increase by one unit value based on the length of the first target pulse signal and the first count value. It can be seen that after obtaining the time length required for any count value to increase by one unit value, the time length to be determined can be determined based on the time length required for any count value to increase by one unit value and the count value statistically obtained during the time length to be determined.
[0012] It should be understood that since the first target pulse signal of known time length in the present application comes from the GPS module, the known time length is very close to the time length of the first target pulse signal determined based on the International Standard Time (Greenwich Mean Time), that is, the known time length corresponding to the first target pulse signal has a high accuracy, and counting is performed during the duration of the first target pulse to obtain a first count value. According to the known time length and the first count value, the time length required for each unit value increase of any count value determined is of high accuracy. Compared with the technical solution of the prior art that determines the time length required for each unit value increase of any count value by the crystal oscillation frequency, the time length required for each unit value increase of any count value determined in the present application is of high accuracy. Therefore, according to the time length required for each unit value increase of any count value, the time length corresponding to the increase of several count values is also determined with high accuracy.
[0013] In a second aspect, an embodiment of the present application provides a device for determining time, the device being used to execute the method in the first aspect or any possible implementation of the first aspect. Specifically, the device may include a module for determining time in the first aspect or any possible implementation of the first aspect.
[0014] In a third aspect, an embodiment of the present application provides a time determination device, comprising: a memory, a communication interface, a processor, and a computer program stored in the memory and executable on the processor, characterized in that when the processor executes the computer program, it implements the above-mentioned first aspect or any one of the methods in the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and wherein when the computer program is executed by a processor, the method described in the first aspect or any one of the first aspects is implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a device, enables the device to implement the above-mentioned first aspect or any one of the methods in the first aspect.
[0017] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 is a schematic diagram of a system 100 for determining time provided in an embodiment of the present application;
[0020] Figure 2 is a schematic diagram of a second pulse output by a GPS module provided in an embodiment of the present application;
[0021] Figure 3 is a flowchart of a method 300 for determining time provided in an embodiment of the present application;
[0022] Figure 4 Figure (a) is a schematic diagram of a first target pulse signal provided in an embodiment of the present application;
[0023] Figure 4 Figure (b) is a schematic diagram of another first target pulse signal provided in an embodiment of the present application;
[0024] Figure 4 Figure (c) is a schematic diagram of another first target pulse signal provided in an embodiment of the present application;
[0025] Figure 4 Figure (d) is a schematic diagram of another first target pulse signal provided in an embodiment of the present application;
[0026] Figure 4 Figure (e) is a schematic diagram of another first target pulse signal provided in an embodiment of the present application;
[0027] Figure 5 is a structural diagram of a time determination device 500 provided in an embodiment of the present application;
[0028] Figure 6 It is a structural diagram of a device 600 for determining time provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0030] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0031] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0032] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0033] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0034] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0035] When it is necessary to determine an accurate length of time, for example, when using a sampler with a high sampling frequency to collect signals for analysis, in order to obtain a certain amount of sampled data, it is necessary to determine a high-precision time length that matches it. For another example, when it is necessary to obtain accurate time parameters, it is also necessary to determine the accurate timing value to determine the required time parameters.
[0036] At present, in the process of determining the length of a certain period of time, the count value determined by the timer is usually converted into the corresponding time length, so as to determine the corresponding time. It should be understood that in the process of counting by the timer, the count value is determined according to the frequency of the crystal oscillator, however, the crystal frequency is easily affected by the external environment and changes. For example, when the temperature changes significantly, the crystal frequency will also change accordingly. This situation will result in different corresponding time lengths at different temperatures for each increase in count value. For example, when the temperature is 25°, the time length corresponding to one count value determined by the timer is 10 microseconds, but when the temperature rises to 35°, one count value determined by the timer no longer corresponds to a time length of 10 microseconds. In this case, the time determined by the count value obtained by the timer will have a large error, and the longer the timing time, the greater the error. Based on the above findings, an embodiment of the present application provides a method for determining time, based on a first target pulse signal of known time length from a GPS module, and counting within the first target pulse signal to determine a first count value, based on the time length of the first target pulse signal and the first count value, since the time length determined based on the pulse signal emitted by the GPS module is very close to the time length determined based on the International Standard Time (Greenwich Mean Time), the time length of the first target pulse signal is accurate, and therefore, the precise time length corresponding to a count value can be determined based on the count value counted within the time length of the first target pulse signal, so as to solve the problem of errors in determining the time length within a certain period of time in the prior art.
[0037] Figure 1 The figure shows a time determination system 100 provided in an embodiment of the present application. The system 100 includes: a GPS module 101 and a timer module 102 .
[0038] In some embodiments, a communication connection is established between the timer module 102 and the GPS module 101, and the timer module 102 can directly obtain a first target pulse signal of a known time length from the GPS module.
[0039] In some embodiments, the timer module 102 has an interface that can capture pulse mutations, and the interface establishes a communication connection with the GPS module 101 .
[0040] In some embodiments, the timer module 102 may be a timer in a single-chip microcomputer, and the interface of the timer module 102 is a pin on the timer in the single-chip microcomputer, and the pin may capture a certain moment of the pulse signal.
[0041] For example, a pin on the timer can capture the moment when the pulse signal jumps, and the moment when the pulse signal jumps can be the moment corresponding to the rising edge or the falling edge of the pulse signal.
[0042] In some embodiments of the present application, the GPS module 101 may output: Figure 2 As shown in the second pulse signal, when the GPS module 101 outputs the second pulse signal and the second pulse signal changes suddenly, the pin of the timer can timely capture the moment when the signal changes suddenly, and start counting from the moment when the signal changes suddenly, so as to determine the precise count value corresponding to the pulse signal length.
[0043] Exemplarily, the embodiments of the present application are only described using the GPS module 101 as an example. In actual application, the GPS module 101 may also be other modules that can output a pulse signal of a known time length, wherein the known time length has a small error with the time length of the pulse signal determined by the world's international standards.
[0044] Figure 3 The method 300 for determining time provided in an embodiment of the present application is shown, and is applied to the above Figure 1 The system for determining time shown in the figure may be implemented by software and / or hardware of the timer module 102. Figure 3 As shown, the method includes steps S301 to S302. The specific implementation principle of each step is as follows:
[0045] S301 , counting is performed during the duration of a first target pulse signal of a known time length from a GPS module to determine a first count value, wherein the first target pulse signal is a pulse signal output by the GPS module.
[0046] Exemplarily, the first target pulse signal is a pulse signal output by the GPS module. The first target pulse can be a pulse signal of one of the cycles in the pulse signal emitted by the GPS module, or it can be a pulse signal of a known time length in the pulse signal emitted by the GPS module, that is, the time length of the first target pulse signal is known.
[0047] Exemplarily, counting is performed during the duration of the first target pulse signal, and the determined first count value is a count value corresponding to the time length of the first target pulse signal.
[0048] Exemplarily, when counting is performed during the duration of the first target pulse signal, counting can start from a count value of 0, and the count value obtained after the counting ends is the first count value. Counting can also be continued from any count value, and the count value increased during the duration of the first target pulse signal is determined as the first count value.
[0049] S302, determining the time length required for any count value to increase by one unit value according to the time length of the first target pulse signal and the first count value.
[0050] In some embodiments, since the first count value is the count value corresponding to the time length of the first target pulse signal, the time length required for any count value to increase by one unit value can be determined based on the time length of the first target pulse signal and the first count value.
[0051] Exemplarily, the time length of the first target pulse signal is 1 second, and the first count value determined during the duration of the first target pulse signal is 9990, which means that the count value increased within 1 second is 9990. Based on the time length of the first target pulse signal and the first count value, it can be determined that the time length required for any count value to increase by one unit value is 100.1001 microseconds.
[0052] It should be understood that, for example, when the count value is set to increase by 10000 within 1 second, it means that the count value increases from zero to 10000, and the corresponding time length is 1 second. However, according to the method proposed in the embodiment of the present application, the count value obtained by counting and statistics within 1 second is 9990. In this case, it can be seen that the count value of the timer is 10 count values smaller than the set count value within 1 second due to the slow crystal oscillator frequency. That is, according to the setting of counting within 1 second, the count value is 10000, and the time length required for any count value to increase by one unit value is 100 microseconds. In fact, when counting is performed within 1 second, the count value is 9990, and the time length required for any count value to increase by one unit value should be 100.1001 microseconds.
[0053] For example, when determining the time length required for any count value to increase by one unit value based on the time length of the first pulse signal and the first count value, it is also possible to directly determine the time length required for any count value to increase by a specified number of unit values, for example, determining the time length required for any count value to increase by two unit values, or determining the time length required for any count value to increase by ten unit values.
[0054] In some embodiments, when the time length corresponding to a count value is used to determine the time length based on the count value, if the count value increases from 0 to 10000, the time length corresponding to 1 count value set according to the crystal oscillator frequency of the timer is 100 microseconds, and the obtained time length is 1000000 microseconds. In fact, the time length corresponding to 1 count value obtained above is 100.1001 microseconds, so the actual time length should be 1001001 microseconds.
[0055] It can be seen that the time length obtained according to the set value has a relatively large error value. However, the present application can obtain the precise time length and the count value corresponding to the time length according to the first target pulse signal, and then obtain the time length required for any count value to increase by one unit value, so the precise time can be determined according to the count value obtained by statistics.
[0056] It should be understood that this embodiment only takes the count value increasing from 0 to 10000 as an example for explanation. In actual application, when the count value starts to increase from the count value corresponding to the first moment of the first moment, and the counting ends at the second moment to obtain the count value corresponding to the second moment, the time length corresponding to the first moment to the second moment can be determined based on the count value increased between the first moment and the second moment.
[0057] In the above Figure 3 Based on the embodiment of determining time shown in the figure, counting is performed during the duration of the first target pulse signal in step S302, and the step of determining the first count value can be specifically implemented in the following manner:
[0058] Counting is performed between a first moment and a second moment during the duration of the first target pulse signal to determine a first count value, wherein the first moment and the second moment are moments when the first target pulse signal jumps, and the second moment is located after the first moment.
[0059] It should be understood that when the amplitude of a pulse signal changes suddenly, it can be considered that the pulse signal has jumped. For example, if the amplitude of a pulse signal remains unchanged at 5V for a period of time, and the pulse signal suddenly increases to 7V, or the amplitude of the pulse signal suddenly decreases to 2V, it is considered that the pulse signal has jumped. For another example, if the amplitude of a pulse signal decreases by 1V per second according to a certain rule, and the amplitude of the pulse signal suddenly increases, it is considered that the pulse signal has jumped.
[0060] In some embodiments, the first moment may be the moment corresponding to the detection of the rising edge of the first target pulse signal, or the moment corresponding to the detection of the falling edge of the first target pulse signal, and the second moment may be the moment corresponding to the detection of the rising edge of the first target pulse signal, or the moment corresponding to the detection of the falling edge of the first target pulse signal, and the second moment is after the first moment.
[0061] Exemplarily, when the first moment is the moment corresponding to the detection of the rising edge of the first target pulse signal, and the second moment is the moment corresponding to the detection of the falling edge of the first target pulse signal, the first target pulse signal obtained is as follows: Figure 4 As shown in Figure (a), since the pulse signal output by the GPS module is a second pulse signal, the time length of the pulse signal in one cycle is 1 second. The duty cycle of the second pulse signal is half, that is, in one cycle of the pulse signal, the duration of the pulse signal during the high level period is 0.5 seconds, and the duration of the pulse signal during the low level period is 0.5 seconds. It can be seen that Figure 4 The pulse signal shown in (a) is a pulse signal in a pulse signal within a cycle, and a pulse signal during the high level duration is counted during the duration of the first target pulse signal to determine the first count value. The determined first count value is the count value counted within the time length t1 of 0.5 seconds.
[0062] Exemplarily, when the first moment is the moment corresponding to the falling edge and rising edge of the first target pulse signal, and the second moment is the moment corresponding to the rising edge of the first target pulse signal, the obtained first target pulse signal can be as follows: Figure 4 As shown in Figure (b), since the pulse signal output by the GPS module is a second pulse signal, the time length of the pulse signal in one cycle is 1 second. The duty cycle of the second pulse signal is half, that is, in one cycle of the pulse signal, the duration of the pulse signal during the high level period is 0.5 seconds, and the duration of the pulse signal during the low level period is 0.5 seconds. It can be seen that Figure 4 The pulse signal shown in (b) is a pulse signal during the low level duration in a pulse signal within a cycle, and the first count value can be determined by counting during the duration of the first target pulse signal. The determined first count value is the count value counted within the time length t2 of 0.5 seconds.
[0063] Exemplarily, when the first moment and the second moment are the moments corresponding to the detection of the rising edge of the first target pulse signal, the obtained first target pulse signal may be as follows: Figure 4 As shown in Figure (c), the pulse signal output by the GPS module is a second pulse signal. Figure 4 The pulse signal shown in (c) is a pulse signal within one cycle, and then the first count value can be determined by counting during the duration of the first target pulse signal. The determined first count value is the count value counted within the time length t3 of 1 second.
[0064] Exemplarily, in the case where the first moment and the second moment are the moments corresponding to the detection of the falling edge of the first target pulse signal, the obtained first target pulse signal may be as follows: Figure 4 As shown in the pulse signal in Figure (d), it should be understood that the pulse signal output by the GPS module is a second pulse signal. Figure 4 The pulse signal shown in (d) is a pulse signal within one cycle, and counting is performed during the duration of the first target pulse signal, and a first count value can be determined. The determined first count value is a count value counted within a time length t4 of 1 second.
[0065] Exemplarily, the first moment may be the moment corresponding to the rising edge of the first target pulse signal detected for the i-th time, and the second moment may be the moment corresponding to the rising edge of the first target pulse signal detected for the (i+2)th time. In this case, the obtained first target pulse signal may be as follows: Figure 4 As shown in Figure (e), it should be understood that since the pulse signal output by the GPS module is a second pulse signal, the time length of the pulse signal in one cycle is 1 second. Figure 4 The pulse signal shown in Figure (e) is a pulse signal within two cycles, and counting is performed during the duration of the first target pulse signal. The determined first count value is the count value counted within a time length t5 of 2 seconds.
[0066] In some embodiments, when counting is performed during the duration of the first target pulse signal to determine the first count value, the first count value may be determined in the following manner:
[0067] It should be understood that after setting the timer, a preset count value can be obtained. According to the setting of the timer, when the count value increases from 0 to the preset count value, the timer considers that the time length during this period is 1 second. Therefore, when the count value increases to the preset count value, an interrupt will be generated. The timer considers that the time length has increased by 1 second based on the generated interrupt signal. When the timer is interrupted, the count value starts counting again from 0.
[0068] For example, the preset count value is 10000. When the count value increases to 10000, an interruption occurs. If the count value continues to increase, it is considered that the current count value is in an overflow state. In this case, the count value starts to increase again from 0. After the overflow occurs, the actual count value needs to be determined based on the preset count value, the number of interruptions, and the count value after the interruption.
[0069] Therefore, when counting the duration of the first target pulse signal, the count value obtained may be a count value obtained after overflow, or a count value obtained without overflow. That is, when no interruption occurs during the counting of the duration of the first target pulse signal, the count value obtained by statistics can be directly determined as the first count value when counting the duration of the first target pulse signal.
[0070] Exemplarily, during the counting process during the duration of the first target pulse signal, when the count value increases to a preset count value, an interruption occurs, and counting starts again from 0, and the count value counted after the last interruption is determined as the second count value. In this case, the first count value can be determined based on the preset count value, the second count value, and the number of interruptions during the counting process.
[0071] For example, if the preset count value is 10000, when the count value reaches 10000, an interruption will occur and the counting will start again from 0. If only one interruption occurs during the counting process, the second count value after the first interruption is 10, and the count value 10010 obtained by adding the second count value to the preset count value is determined as the first count value.
[0072] For another example, when the preset count value is 10000 and the first count value is 9990, the first count value does not exceed the preset count value, so no interruption occurs. If no interruption occurs during the counting process, the first count value 9990 can be directly determined as the first count value.
[0073] In some embodiments, before step S301, the embodiment of the present application further includes the following steps:
[0074] After receiving the indication information from the GPS module, the starting time of the first target pulse signal is determined according to the pulse signal output by the GPS module after sending the indication information.
[0075] It should be understood that, since the GPS module is in an unlocked state within a short period of time after the GPS module is powered on, that is, the positioning of the GPS module is not valid, the GPS module will not output a pulse signal, or the output pulse signal is an irregular pulse signal. When the GPS module is successfully positioned, it will output an indication message indicating that the GPS module positioning is valid at the current moment, indicating that the pulse signal output by the current GPS module is a standard second pulse signal, and what is required by the present application is a standard second pulse signal output by the GPS. Therefore, after receiving the indication message from the GPS module, the starting time of the first target pulse signal can be determined according to the pulse signal output by the GPS module after outputting the indication message.
[0076] Optionally, when the GPS module positioning is valid, an indication message indicating that the GPS module positioning at the current moment is valid is output; when the GPS module positioning is invalid, an indication message indicating that the GPS module positioning at the current moment is invalid is output.
[0077] For example, when the information output by the GPS module is A, it is considered that the GPS module has output an indication information indicating that the GPS module positioning at the current moment is valid. When the information output by the GPS module is V, it indicates that the GPS module positioning at the current moment is invalid. Therefore, it is considered that the GPS module has not output an indication information indicating that the GPS module positioning at the current moment is valid.
[0078] In some embodiments, the present application may further include the following steps:
[0079] Exemplarily, the time parameters of the third moment can be obtained according to the preset protocol of the GPS module, and then the time parameters of the third moment can be determined based on the time parameters of the third moment, the length of time required for each unit value increase of any count value determined in step S302, and the third count value, wherein the third count value is the count value counted during the counting process from the third moment to the fourth moment.
[0080] Optionally, the third moment may be a real-time time parameter obtained according to a preset protocol of the GPS module.
[0081] Optionally, the preset protocol of the GPS module may be the National Marine Electronics Association (NMEA) protocol.
[0082] For example, the time length required for any count value determined in step S302 to increase by one unit value is 80 microseconds. According to the preset protocol of the GPS module, the real-time time parameter obtained is 17:10:10 on January 1, 2021. 17:10:10 on January 1, 2021 is taken as the third moment, and counting starts from the third moment, and stops at the fourth moment. The count values counted from the third moment to the fourth moment are counted, and the count value is 9123. It can be obtained that the time length corresponding to the third moment to the fourth moment is 729840 microseconds. The time parameter of the fourth moment is 17:10:10 on January 1, 2021 (729 milliseconds, 840 microseconds).
[0083] In some embodiments, after determining the length of time required for any count value to increase by one unit value, the embodiment of the present application further includes the following steps:
[0084] After each preset time period, step S101 to step S102 are executed in a loop.
[0085] It should be understood that since the external environment may change at any time, after determining the length of time required for any count value to increase by one count unit, due to the influence of the external environment, such as temperature changes causing the crystal oscillator frequency in the timer to change, resulting in changes in the length of time required for the count value to increase by one count unit, it is necessary to perform steps S101 to S102 again to re-determine the length of time required for the count value to increase by one count unit, thereby preventing errors caused by environmental changes in the process of determining time. This further improves the accuracy of the time determined by the timer at any time during its operation.
[0086] For example, the preset time length is 5 minutes. At 13:00, steps S101 to S102 are executed to obtain a time length of 90 microseconds for each increase in a count unit of a count value. Then, during the period from 13:00 to 13:05, the time can be determined based on the time length of 90 microseconds for each increase in a count unit of a count value. At 13:05, steps S101 to S102 are executed again to obtain a time length of 85 microseconds for each increase in a count unit of a count value. Then, during the period from 13:05 to 13:10, the time can be determined based on the time length of 85 microseconds for each increase in a count unit of a count value. Thereafter, every 5 minutes (for example, 13:15, 13:20, etc.), steps S101 to S102 are executed once, and the time is determined based on the time length required for each increase in a count unit of a newly determined count value.
[0087] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0088] Corresponding to the above Figure 3 The method of determining time shown, Figure 5 The present invention shows a time determination device 500 provided in an embodiment of the present application, including:
[0089] The counting module 501 is used to count during the duration of a first target pulse signal of a known time length from the GPS module to determine a first count value.
[0090] The determination module 502 is used to determine the time length required for any count value to increase by one unit value according to the time length of the first target pulse signal and the first count value.
[0091] Optionally, the counting module 501 is also used to count between a first moment and a second moment during the duration of the first target pulse signal to determine the first count value, the first moment is the moment when the first target pulse signal jumps, the second moment is the moment when the first target pulse signal jumps, and the second moment is after the first moment.
[0092] Optionally, the counting module 501 is also used to determine the first count value as the first count value when no interruption occurs during the counting period during the duration of the first target pulse signal, and the first count value is the count value counted when no interruption occurs during the counting process; or, when an interruption occurs during the counting period during the duration of the first target pulse signal, determine the first count value based on the preset count value, the second count value, and the number of interruptions in the counting process, and the second count value is the count value counted after the last interruption in the counting process, wherein, when counting is performed during the duration of the first target pulse signal, an interruption occurs when the count value is equal to the preset count value.
[0093] Optionally, the first moment is the moment corresponding to when the rising edge of the first target pulse signal is detected, or the moment corresponding to when the falling edge of the first target pulse signal is detected, and the second moment is the moment corresponding to when the rising edge of the first target pulse signal is detected, or the moment corresponding to when the falling edge of the first target pulse signal is detected.
[0094] Optionally, before determining the first count value, the determination module 502 is also used to determine the initial moment of the first target pulse according to the pulse signal output by the GPS module after receiving indication information from the GPS module, and the indication information indicates that the positioning of the GPS module is valid.
[0095] Optionally, the device 500 further includes an acquisition module 503, and the acquisition module 503 is used to acquire the time parameter of the third moment according to a preset protocol of the GPS module.
[0096] Optionally, the determination module 502 is also used to determine the time parameter of the fourth moment based on the time parameter of the third moment, the time length required for any one of the count values to increase by one unit value, and the third count value, where the third count value is the count value counted from the third moment to the fourth moment.
[0097] Optionally, the method further includes a loop module for looping through S1 to S2 after determining the time length required for any one of the count values to increase by one unit value and after each interval of a preset time length.
[0098] It can be understood that the various implementation modes and implementation combinations in the above embodiments and their beneficial effects are also applicable to this embodiment and will not be described in detail here.
[0099] Figure 6 This is a schematic diagram of a time determination device provided in an embodiment of the present application. Figure 6 As shown, the device 600 includes a processor 601, a memory 602, a communication interface 603 and a bus 604. The processor 601, the memory 602 and the communication interface 603 communicate via the bus 604, or other means such as wireless transmission. The memory 602 is used to store instructions, and the processor 601 is used to execute the instructions stored in the memory 602. The memory 602 stores program code 6021, and the processor 601 can call the program code 6021 stored in the memory 602 to execute Figure 3 The method of determining time is shown.
[0100] It should be understood that in the embodiment of the present application, the processor 601 may be a CPU, and the processor 601 may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0101] The memory 602 may include a read-only memory and a random access memory, and provide instructions and data to the processor 601. The memory 602 may also include a non-volatile random access memory. The memory 502 may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0102] In addition to the data bus, the bus 604 may also include a power bus, a control bus, and a status signal bus. Figure 6 Various buses are labeled as bus 604.
[0103] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0104] An embodiment of the present application provides a computer program product. When the computer program product runs on a device, the device can implement the steps in the above-mentioned method embodiments when the computer program product is executed.
[0105] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0106] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0107] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0108] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0109] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0110] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the above modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0111] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0112] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for determining time, characterized in that include: S1: Counting during the duration of a first target pulse signal of a known time length from a GPS module to determine a first count value; the first count value is a count value corresponding to the time length; S2: determining the time length required for any count value to increase by one unit value according to the time length of the first target pulse signal and the first count value; Counting during the duration of the first target pulse signal to determine a first count value includes: If no interruption occurs in the process of counting during the duration of the first target pulse signal, the count value counted during the duration of the first target pulse signal is determined as the first count value; or, If an interruption occurs during the counting process during the duration of the first target pulse signal, the first count value is determined according to a preset count value, a second count value, and the number of interruptions during the counting process, wherein the second count value is a count value calculated after the last interruption during the counting process occurs, wherein during the counting process during the duration of the first target pulse signal, when the count value is equal to the preset count value, an interruption occurs; Counting is performed between a first moment and a second moment during which the first target pulse signal lasts to determine the first count value, wherein the first moment and the second moment are moments when the first target pulse signal jumps, and the second moment is located after the first moment; Before determining the first count value, the method further includes: After receiving the indication information from the GPS module, determining the starting time of the first target pulse according to the pulse signal output by the GPS module after sending the indication information, wherein the indication information indicates that the positioning of the GPS module is valid; The method further comprises: According to the preset protocol of the GPS module, obtaining the time parameter of the third moment; The time parameter of the fourth moment is determined according to the time parameter of the third moment, the time length required for each unit value increase of any count value, and the third count value, and the third count value is the count value counted during the period from the third moment to the fourth moment.
2. The method according to claim 1, characterized in that The first moment is the moment corresponding to when the rising edge of the first target pulse signal is detected, or the moment corresponding to when the falling edge of the first target pulse signal is detected, and the second moment is the moment corresponding to when the rising edge of the first target pulse signal is detected, or the moment corresponding to when the falling edge of the first target pulse signal is detected.
3. The method according to any one of claims 1 to 2, characterized in that After determining the time length required for each unit value of the arbitrary count value to increase, the method further includes: After each preset time interval, steps S1 to S2 are executed in a loop.
4. A device for determining time, characterized in that include: A counting module, used for counting during the duration of a first target pulse signal of a known time length from the GPS module to determine a first counting value; The first count value is a count value corresponding to the time length; A determination module, configured to determine, according to the time length of the first target pulse signal and the first count value, the time length required for any count value to increase by one unit value; The counting module is also used for determining the first count value as the first count value when no interruption occurs during the counting period during which the first target pulse signal is continued, and the first count value is the count value counted when no interruption occurs during the counting process; or, when an interruption occurs during the counting period during which the first target pulse signal is continued, determining the first count value according to a preset count value, a second count value, and the number of interruptions during the counting process, and the second count value is the count value counted after the last interruption in the counting process, wherein, when counting is performed during the duration of the first target pulse signal, an interruption occurs when the count value is equal to the preset count value; counting is performed between a first moment and a second moment during the duration of the first target pulse signal to determine the first count value, the first moment and the second moment are the moments when the first target pulse signal jumps, and the second moment is located after the first moment; Before determining the first count value, the determination module is further used to determine the initial time of the first target pulse according to the pulse signal output by the GPS module after receiving indication information from the GPS module, wherein the indication information indicates that the positioning of the GPS module is valid; The device also includes an acquisition module, which is used to acquire a time parameter of a third moment according to a preset protocol of the GPS module; The determination module is also used to determine the time parameter of the fourth moment based on the time parameter of the third moment, the time length required for each unit value of any count value to increase, and the third count value, and the third count value is the count value counted from the third moment to the fourth moment.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
