Clock adjustment method and device of electronic equipment, storage medium and electronic equipment

By establishing the temperature and frequency curve and calculating the compensation frequency, the problem of inaccurate timing of the crystal oscillator when the temperature changes is solved, and the accuracy of clock adjustment when the GPS signal is disconnected is achieved.

CN119225153APending Publication Date: 2024-12-31SHANGHAI DONGTU ZHIYUAN INTELLIGENT TECH DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411352062.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2024-12-31

Smart Images

  • Figure CN119225153A_ABST
    Figure CN119225153A_ABST
Patent Text Reader

Abstract

The invention relates to a clock adjustment method and device of electronic equipment, a storage medium and the electronic equipment. The method comprises the following steps: when a global positioning system signal is disconnected, recording the vibration times of a crystal oscillator of the electronic equipment and acquiring the current temperature of the crystal oscillator of the electronic equipment; when the current temperature changes, according to the current temperature before and after the change, the frequency before the change and the frequency after the change are determined in the temperature and frequency curve, and the compensation frequency is determined according to the frequency before the change and the frequency after the change, the temperature and frequency curve is obtained by calculating a plurality of temperatures and a plurality of frequencies of a crystal oscillator of the electronic equipment collected in each of the plurality of time periods; compensating the vibration times by using the compensation frequency to obtain compensated vibration times; and determining the time of the clock of the electronic equipment by using the compensated number of vibrations. The technical problem that timing is inaccurate due to the fact that the crystal oscillator is affected by temperature is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal clock adjustment, and in particular to a clock adjustment method, device, storage medium and electronic device for an electronic device. Background Art

[0002] In the prior art, a mobile terminal is equipped with a crystal oscillator, which generates clock information by vibrating at a certain frequency, and is used to time the mobile terminal. The mobile terminal can also receive a Global Positioning System (GPS) signal, thereby determining the current time according to the GPS signal and updating the time of the mobile terminal. In other words, in the prior art, the mobile terminal can obtain the accurate time by acquiring the GPS signal, thereby adjusting the system time of the mobile terminal, and can also obtain the system time by timing through the vibration of the crystal oscillator.

[0003] Since the GPS signal may be interrupted, after the GPS signal is interrupted, the only way to time the time is through the crystal oscillator. However, the frequency of the crystal oscillator may fluctuate due to the influence of temperature, resulting in inaccurate timing. Summary of the invention

[0004] The present application provides a clock adjustment method, device, storage medium and electronic device for an electronic device, so as to solve the technical problem that the timing of a crystal oscillator is inaccurate due to the influence of temperature.

[0005] In a first aspect, the present application provides a method for adjusting the clock of an electronic device, comprising: when a global positioning system signal is disconnected, recording the number of vibrations of a crystal oscillator of the electronic device and obtaining the current temperature of the crystal oscillator of the electronic device; when the current temperature changes, determining the frequency before and after the change in a temperature and frequency curve according to the current temperature before and after the change, and determining a compensation frequency according to the frequency before and after the change, wherein the temperature and frequency curve is calculated by using multiple temperatures and multiple frequencies of the crystal oscillator of the electronic device collected in each of multiple time periods; using the compensation frequency to compensate for the number of vibrations to obtain the compensated number of vibrations; and using the compensated number of vibrations to determine the time of the clock of the electronic device.

[0006] In a second aspect, the present application provides a clock adjustment device for an electronic device, comprising: a recording module, used to record the number of vibrations of the crystal oscillator of the electronic device and obtain the current temperature of the crystal oscillator of the electronic device when the global positioning system signal is disconnected; a first determination module, used to determine the frequency before and after the change in a temperature and frequency curve according to the current temperature before and after the change when the current temperature changes, and determine the compensation frequency according to the frequency before and after the change, wherein the temperature and frequency curve is calculated by using multiple temperatures and multiple frequencies of the crystal oscillator of the electronic device collected in each of multiple time periods; a compensation module, used to compensate for the number of vibrations using the compensation frequency to obtain the compensated number of vibrations; a second determination module, used to determine the time of the clock of the electronic device using the compensated number of vibrations.

[0007] As an optional example, the above-mentioned device also includes: an acquisition module, which is used to acquire the temperature and frequency of the crystal oscillator of the electronic device multiple times in each of multiple predetermined time periods after adjusting the frequency of the crystal oscillator of the electronic device using a global positioning system signal before acquiring the current temperature of the crystal oscillator of the electronic device; perform weighted summation on the multiple temperatures and multiple frequencies collected in each predetermined time period to obtain the average temperature and average frequency in each predetermined time period; and use the above average temperature and the above average frequency to determine the above temperature and frequency curve.

[0008] As an optional example, the above-mentioned acquisition module includes: a determination unit, which is used to determine the size of the weight according to the time length from the time point generated by the frequency of acquisition in each predetermined time period to the end time point of each predetermined time period, wherein the larger the above-mentioned time length is, the smaller the above-mentioned weight is.

[0009] As an optional example, the acquisition module includes: a calculation unit, used to use the average temperature and the average frequency calculated in multiple predetermined time periods as independent variables and values ​​in the target curve, and calculate the value of the constant in the target curve; and determine the obtained target curve as the temperature and frequency curve.

[0010] As an optional example, the calculation unit includes: a determination subunit, configured to determine, according to the type of the crystal oscillator, a curve matching the type from a second-order curve and a third-order curve as the target curve.

[0011] As an optional example, the first determination module includes: an input module, used to input the current temperature before the change as an independent variable into the temperature and frequency curve, and determine the corresponding value as the frequency before the change; input the current temperature after the change as an independent variable into the temperature and frequency curve, and determine the corresponding value as the frequency after the change; and determine the difference between the frequency before the change and the frequency after the change as the compensation frequency.

[0012] As an optional example, the above-mentioned device also includes: a storage module, used to store the above-mentioned temperature and frequency curve in the cache of the above-mentioned electronic device; when the above-mentioned electronic device is restarted, obtaining the above-mentioned temperature and frequency curve from the above-mentioned cache; and determining the time of the clock of the above-mentioned electronic device through the obtained above-mentioned temperature and frequency curve.

[0013] In a third aspect, the present application provides an electronic device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the memory stores a computer program, and the processor is configured to implement any one of the above-mentioned clock adjustment methods for the electronic device when executing the computer program.

[0014] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the clock adjustment method of any of the above electronic devices of the present application.

[0015] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the solution provided by the embodiment of the present application records the vibration number of the crystal oscillator of the electronic device and obtains the current temperature of the crystal oscillator of the electronic device when the global positioning system signal is disconnected; when the above current temperature changes, the frequency before the change and the frequency after the change are determined in the temperature and frequency curve according to the above current temperature before and after the change, and the compensation frequency is determined according to the frequency before the change and the frequency after the change, wherein the temperature and frequency curve is calculated by multiple temperatures and multiple frequencies of the crystal oscillator of the electronic device collected in each time period of multiple time periods; the above vibration number is compensated using the compensation frequency to obtain the compensated vibration number; the time of the clock of the electronic device is determined using the compensated vibration number, so that when the GPS signal is disconnected, even if the temperature changes, the vibration number of the crystal oscillator can be compensated through the temperature and frequency curve, and the terminal clock is adjusted using the compensated vibration number of the crystal oscillator, thereby improving the timing accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0019] Figure 1 A flowchart of a clock adjustment method for an electronic device provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of a clock adjustment system for an electronic device provided in an embodiment of the present application;

[0021] Figure 3 A temperature and frequency curve of a clock adjustment method for an electronic device provided in an embodiment of the present application;

[0022] Figure 4 A schematic diagram of the structure of a clock adjustment device for an electronic device provided in an embodiment of the present application;

[0023] Figure 5 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0025] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0026] In order to solve the technical problem in the prior art that the crystal oscillator is affected by temperature and the timing is inaccurate, the present application provides a clock adjustment method for an electronic device, which can achieve the effect of improving the timing accuracy of the terminal.

[0027] Figure 1 The present invention provides a flowchart of a clock adjustment method for an electronic device. Figure 1 As shown, the clock adjustment method of the electronic device includes:

[0028] S102, when the global positioning system signal is disconnected, recording the vibration times of the crystal oscillator of the electronic device and obtaining the current temperature of the crystal oscillator of the electronic device;

[0029] S104, when the current temperature changes, determining the frequency before the change and the frequency after the change in a temperature-frequency curve according to the current temperature before and after the change, and determining a compensation frequency according to the frequency before the change and the frequency after the change, wherein the temperature-frequency curve is calculated by calculating multiple temperatures and multiple frequencies of a crystal oscillator of the electronic device collected in each of multiple time periods;

[0030] S106, using the compensation frequency to compensate for the vibration times, to obtain the compensated vibration times;

[0031] S108, using the compensated vibration times to determine the time of the clock of the electronic device.

[0032] This embodiment can be applied in the scenario of adjusting the time of an electronic device, and the electronic device can be a terminal, such as a mobile terminal, a host, etc. The Global Positioning System (GPS) signal can provide accurate time information for the terminal. If the GPS signal is disconnected or weak, the time of the terminal needs to be adjusted according to the frequency of the crystal oscillator of the terminal.

[0033] For example, the terminal can determine the terminal clock according to the number of vibrations of the crystal oscillator, such as the terminal clock moves back one second for every 30,000 vibrations of the crystal oscillator. The terminal can receive GPS signals within a period of time. When the GPS signal can be received, if the number of vibrations of the crystal oscillator of the terminal is affected by the temperature and the vibration speed fluctuates, then the time of the terminal clock determined according to the frequency of 30,000 vibrations of the crystal oscillator equal to one second is inaccurate. At this time, the terminal time can be adjusted according to the accurate clock of the GPS signal. If there is no GPS signal, the number of vibrations of the crystal oscillator is affected by the temperature and the speed fluctuates. The time of the terminal clock determined according to the number of vibrations of the crystal oscillator is inaccurate. The compensation frequency can be determined through the temperature and frequency curve, and the current number of vibrations of the crystal oscillator of the terminal is compensated by the compensation frequency. The time of the terminal clock is determined according to the compensated number of vibrations.

[0034] The above-mentioned crystal oscillator is an original component that vibrates at a frequency within a certain range within a certain period of time. For example, if it vibrates 30,000 times per second (the value is for illustration only and may differ from the actual situation), the system can calculate the time based on the vibration frequency of the crystal oscillator, and consider that one second has passed for every 30,000 vibrations. In actual use, the frequency of the crystal oscillator will fluctuate with the temperature, and will not stabilize at a frequency of 30,000 per second, but will fluctuate within a certain range. For example, it fluctuates within the range of 28,000-32,000 times / second.

[0035] The temperature and frequency curve may be a curve of the vibration frequency of the crystal oscillator at different temperatures, which records the stable vibration frequency of the crystal oscillator at different temperatures. The compensation frequency may be determined based on the curve.

[0036] The above-mentioned compensation frequency is the frequency used to compensate for the vibration times of the crystal oscillator. The vibration times after compensation can be used to determine the clock of the terminal.

[0037] For example, let's use an example. If the frequency of the crystal oscillator is 30,000 times per second, and it is affected by temperature and drops to 28,000 times per second, then after losing the GPS signal, you can determine that one second has passed based on the crystal oscillator vibrating 30,000 times. Now the time required for the crystal oscillator to vibrate 30,000 times is greater than 1 second, which will cause the terminal clock to be inaccurate. At this time, if the current frequency is compensated according to the compensation frequency, the terminal vibrates 28,000 times (the actual time reaches one second, but because it has not reached 30,000 times, the system believes that it has not reached one second). If the compensation frequency is 2,000 times per second, the number of crystal oscillators after compensation is 30,000 times. The system will believe that the crystal oscillator has vibrated 30,000 times, reaching one second, so the recorded time goes back one second to match the actual time.

[0038] The solution provided in the embodiment of the present application records the number of vibrations of the crystal oscillator of the electronic device and obtains the current temperature of the crystal oscillator of the electronic device when the global positioning system signal is disconnected; when the current temperature changes, the frequency before and after the change is determined in the temperature and frequency curve according to the current temperature before and after the change, and the compensation frequency is determined according to the frequency before and after the change, wherein the temperature and frequency curve is calculated by multiple temperatures and multiple frequencies of the crystal oscillator of the electronic device collected in each time period of multiple time periods; the number of vibrations is compensated using the compensation frequency to obtain the compensated number of vibrations; the time of the clock of the electronic device is determined using the compensated number of vibrations, so that when the GPS signal is disconnected, even if the temperature changes, the number of vibrations of the crystal oscillator can be compensated through the temperature and frequency curve, and the terminal clock is adjusted using the compensated number of vibrations of the crystal oscillator, thereby improving the timing accuracy.

[0039] As an optional example, before obtaining the current temperature of the crystal oscillator of the electronic device, the above method also includes: after adjusting the frequency of the crystal oscillator of the electronic device using the global positioning system signal, multiple times in each of multiple predetermined time periods, collecting the temperature and frequency of the crystal oscillator of the electronic device; performing weighted summation on the multiple temperatures and multiple frequencies collected in each predetermined time period to obtain the average temperature and average frequency in each predetermined time period; and using the average temperature and average frequency to determine the temperature and frequency curve.

[0040] In this embodiment, before determining the compensation frequency, the temperature and frequency curve must be determined. The temperature and frequency curve is calculated based on historical data. First, data is collected. When collecting data, the frequency and temperature of the crystal oscillator are collected multiple times in each predetermined time period in units of a predetermined time period. The frequency collected here is the frequency obtained after adjusting the crystal oscillator frequency of the terminal using the GPS positioning signal, and the purpose is to ensure the accuracy of the determined temperature and frequency curve. The collected frequency and temperature are weighted and summed to calculate the average temperature and average frequency, and the average temperature and average frequency represent the average value of the temperature and the average value of the frequency in the predetermined time period. For example, the collection action is performed multiple times within a certain 5 seconds, and the temperature and frequency of the crystal oscillator are collected each time. After collecting multiple times, multiple temperatures and frequencies are obtained. The multiple temperatures within the 5 seconds are weighted and summed to obtain the average temperature, and the multiple frequencies within the 5 seconds are weighted and summed to obtain the average frequency. The average temperature and average frequency are used as the temperature and frequency representing the 5 seconds. The temperature and frequency are collected in different 5 seconds respectively, and different temperatures and frequencies within 5 seconds are obtained, so that the temperature and frequency curve can be drawn.

[0041] In this embodiment, when temperature and frequency are collected within different 5-second intervals, 5 seconds are not necessarily adjacent to each other. For example, 5 to 10 seconds in a minute is not necessarily a 5-second interval, and 10 to 15 seconds is not necessarily a 5-second interval. It is possible that the data is collected multiple times within 5 seconds of a minute, and multiple times within 5 seconds of another minute.

[0042] In this embodiment, although the acquisition time may be discontinuous, the average temperature and average frequency acquired must cover a wide range of average temperature, for example, covering a common range of crystal oscillator temperature or all ranges of crystal oscillator temperature. After acquisition, the temperature and frequency are generated as a temperature and frequency curve.

[0043] As an optional example, weighted summation is performed on multiple temperatures and multiple frequencies collected within each predetermined time period to obtain the average temperature and average frequency within each predetermined time period, including: determining the size of the weight according to the length of time from the time point when the frequency collected within each predetermined time period is generated to the end time point of each predetermined time period, wherein the longer the time length, the smaller the weight.

[0044] In this embodiment, when calculating the average temperature and the average frequency, the weights used may be the same or different. The weights may be set manually, or may be determined based on the length of time from the generated time point to the end time point of the predetermined time period of the collection. For example, within a predetermined time period, the temperature and frequency are collected 3 times, and the time points of the 3 temperature and frequency collections are different and distributed within the predetermined time period. The later the time points of the 3 collections are, the greater the weight. In this embodiment, the weight may be within a range, such as 0.8-1.2, and the time length of the predetermined time period is regarded as the denominator, and the time length from the start time point of the predetermined time period to the collection time point is regarded as the numerator, and a ratio is determined, which will be between 0 and 1, with 0.5 as the boundary, 0.5 between 0 and 1 corresponds to 1 in the above 0.8-1.2, 0 between 0 and 1 corresponds to 0.8 in the above 0.8-1.2, and 1 between 0 and 1 corresponds to 1.2 in the above 0.8-1.2, then the value between 0-1 is converted to between 0.8-1.2. The weight is determined based on the length of time from the start time of the scheduled time period to the collection time point, and the weight falls between 0.8 and 1.2. After determining the weight of each collected temperature and target frequency, a weighted sum operation is performed to obtain the average temperature and average frequency.

[0045] For example, if the temperature and frequency are collected once at 2 seconds within 4 seconds, then 2 / 4 = 0.5, which is exactly in the middle of the 4-second time length, and the corresponding value in 0.8-1.2 is 1, then the weight of the temperature and frequency collected this time is 1. The closer the collection time point is to the end of the predetermined time period, the greater the weight.

[0046] As an optional example, using the average temperature and average frequency to determine the temperature and frequency curve includes: using the average temperature and average frequency calculated in multiple predetermined time periods as independent variables and values ​​in the target curve, calculating the value of the constant in the target curve; and determining the obtained target curve as the temperature and frequency curve.

[0047] In this embodiment, after collecting data in multiple predetermined time periods and obtaining multiple average temperatures and average frequencies, the average temperature and average frequency can be used to calculate the temperature and frequency curve. It should be noted that the range of the average temperature and average frequency collected should be as comprehensive as possible. For example, after collecting data in multiple predetermined time periods, an average temperature of 0-44 degrees Celsius is collected, and the average temperature basically covers all possible temperatures of the crystal oscillator, and it can be considered that the collected data is sufficient. If only an average temperature of 20-44 degrees Celsius is collected during the collection process, and all possible temperatures of the crystal oscillator are not covered, the collection can be continued at this time. If data of 0-20 degrees Celsius cannot be collected for a long time during the collection process, the average temperature of 20-44 degrees Celsius can be used to determine the temperature and frequency curve.

[0048] As an optional example, the average temperature and average frequency calculated in multiple predetermined time periods are used as independent variables and values ​​in the target curve, and the value of the constant in the target curve is calculated, including: according to the type of the above-mentioned crystal oscillator, from the second-order curve and the third-order curve, determining a curve matching the above-mentioned type as the above-mentioned target curve.

[0049] In this embodiment, different temperature and frequency curves can be determined according to the type of crystal oscillator. For example, different materials, manufacturers, etc. of the crystal oscillator correspond to different temperature and frequency curves. The temperature and frequency curve can be a second-order curve or a third-order curve. The different orders represent that the power of the independent variable in the curve equation of the temperature and frequency curve is different. For example, the second-order curve can be 2 for the highest power of the independent variable in the curve equation, and the third-order curve represents that the highest power of the independent variable in the curve equation is 3. The average temperature and average frequency obtained can be used as the independent variable and value in the curve, so as to determine the value of the constant in the curve. When the value of the constant is determined, a second-order or third-order curve is obtained.

[0050] In one embodiment, under different average temperatures and average frequencies, the value of one of the constants is determined, and then it is checked whether the values ​​of other constants can be determined. After multiple transformations, when the value of the determined constant is unique, the temperature and frequency curve is obtained.

[0051] As an optional example, when the current temperature changes, the frequency before and after the change are determined in the temperature and frequency curve according to the current temperature before and after the change, and the compensation frequency is determined according to the frequency before and after the change, including: inputting the current temperature before the change as an independent variable into the temperature and frequency curve, and determining the corresponding value as the frequency before the change; inputting the current temperature after the change as an independent variable into the temperature and frequency curve, and determining the corresponding value as the frequency after the change; and determining the difference between the frequency before and after the change as the compensation frequency.

[0052] In this embodiment, after obtaining the temperature and frequency curve, when the GPS signal cannot be received, the compensation frequency is determined according to the curve. At this time, the frequency at the temperature before the change can be used as the frequency before the change, and the temperature before the change can be the current temperature when the GPS signal cannot be received. The frequency at the temperature after the change is used as the frequency after the change, and the temperature after the change may increase or decrease. If the temperature remains unchanged, no compensation is required. The frequency before the change and the frequency after the change are the frequencies obtained after the temperature is input into the temperature and frequency curve. The difference obtained by subtracting the frequency before the change from the frequency after the change is the compensation frequency. The compensation frequency can be positive or negative.

[0053] As an optional example, the method further includes: storing the temperature and frequency curve in a cache of the terminal; when the electronic device is restarted, obtaining the temperature and frequency curve from the cache; and determining the clock time of the electronic device through the obtained temperature and frequency curve.

[0054] In this embodiment, after the compensation frequency is calculated, the currently recorded crystal oscillator times can be compensated. When compensating, the times in the compensation frequency are obtained and added to the crystal oscillator times. For example, if the crystal oscillator vibration times are 20,000 times and the compensation frequency is 2,000 times / second, then 20,000+2,000=22,000 times. When the vibration times continue to be recorded, the recording starts from 22,000 times. If the compensation frequency is -2,000 times / second, the vibration times continue to be recorded from 18,000 times.

[0055] The temperature and frequency curve in this embodiment can be stored in the cache. After being stored in the cache, even if the terminal is restarted, the temperature and frequency curve can be retrieved from the cache to adjust the time of the terminal.

[0056] Figure 2The system diagram of this embodiment is shown in FIG. The crystal oscillator (such as a temperature compensated crystal oscillator TCXO) provides a high-precision clock to the central processing unit (CPU). A high-precision clock can be integrated inside the CPU. The GPS module provides a synchronization pulse signal PPS to the CPU. The high-precision temperature sensor is fixed near the crystal oscillator and has good thermal contact. It communicates with the CPU through the bus and transmits the temperature of the crystal oscillator to the CPU. The CPU adjusts the terminal time according to the clock provided by the crystal oscillator and the temperature of the crystal oscillator.

[0057] The processing flow of this embodiment is as follows:

[0058] 1. When the external GPS is used for time synchronization, the CPU internal clock is calibrated (divided into frequency and deviation adjustment).

[0059] 2. After the frequency adjustment is stable, within a period of time T0 (the time should not be too long, such as 5 seconds), obtain the current clock frequency and crystal oscillator temperature [t1,f1], [t2,f2], [t3,f3], [t4,f4], [t5,f5] multiple times, where t represents temperature and f represents frequency.

[0060] 3. By performing weighted and smoothing algorithm processing on the temperature and frequency arrays, the closer the time sampling distance to the end of T0, the higher the weight. The mean filtering algorithm is used to finally obtain [Ts, Fs], that is, the average temperature and average frequency within 5 seconds. This can minimize the impact of sampling errors on the compensation curve equation.

[0061] 4. Establish the initial compensation curve. The compensation curves of different types of crystal oscillators may be different. For general linear curves, the corresponding linear equation training is used. For general curves such as nonlinear curves, third-order or high-order equations are used for segmented training and fitting.

[0062] Linear curve takes the second-order equation as an example f(x) = ax 2 +bx+c, through a large amount of [Ts, Fs] to train and continuously update the a, b, c parameters to finally get the compensation curve.

[0063] The nonlinear curve is based on the third-order equation f(x) = ax 3 +bx 2 +cx+d, training is performed in different temperature intervals (such as 0-5, 5-10, etc.) to obtain a, b, c, d in different intervals, so as to obtain multiple segmented compensation curves.

[0064] 5. When the GPS signal is disconnected and the system enters the timekeeping mode, the frequency at temperature t1 is used as the reference f1. When the temperature changes to t2, f2 is predicted through the compensation curve, and f2-f1 is calculated for frequency compensation. The temperature is obtained in real time, and the frequency difference is calculated and compensated.

[0065] During compensation, for example, after the GPS signal is disconnected, the vibration frequency of the crystal oscillator is recorded. If it has vibrated 20,000 times, the value in the compensation frequency is compensated to 20,000 times. If the compensation frequency is 2,000 times per second, the vibration frequency after compensation is 22,000 times per second. When the vibration frequency of the crystal oscillator reaches 30,000 times, it is determined that the time has moved back one second, and the time of the terminal clock is adjusted.

[0066] 6. The system uses the network port to provide external time synchronization using the Network Time Protocol (NTP) / Precision Time Protocol (PTP).

[0067] 7. The curve parameters are recorded in real time into the flash memory. When a restart occurs, the last recorded compensation curve is used as the benchmark and the above process is repeated. In this way, the compensation curve can still be used in subsequent situations.

[0068] In another example, for example, when the crystal oscillator temperature increases from 20 degrees to 40 degrees, the temperature rises at a uniform speed. Therefore, when the number of vibrations of the crystal oscillator is recorded, the vibration frequency of the crystal oscillator actually rises at a uniform speed from the frequency of 20 degrees to the frequency of 40 degrees. If the compensation frequency is obtained by simply subtracting the vibration frequency of 20 degrees from the vibration frequency of 40 degrees, the compensation frequency will be slightly larger. In order to make the compensation frequency more accurate. After determining the compensation frequency by the above method, the compensation frequency can be adjusted according to the change rate of the temperature of the crystal oscillator. If the temperature is rising, the compensation frequency is reduced. If the temperature is falling, the compensation frequency is increased. The faster the temperature changes, the smaller the adjustment amplitude is, and the slower the temperature changes, the larger the adjustment amplitude is. This can reduce the influence of the temperature change rate on the compensation frequency.

[0069] In the specific experiment, the GPS was locked for 2 hours (during which the temperature changed from 20 degrees Celsius to 40 degrees Celsius, and when the antenna was disconnected, the temperature changed from 40 degrees Celsius to 20 degrees Celsius. Figure 3 The PTP is used to measure and obtain the real-time deviation from the synchronization to the punctuality process.

[0070] It can be seen from the curve that under the influence of temperature changes, the timing error can be significantly reduced after compensation. Due to individual differences between crystals, when the temperature change range is large enough and the observation time is long enough, the closer the fitted compensation curve is to the actual change curve, the better the fitting effect. For the same type of crystal oscillator, the training curves will be different due to different environments and the influence of errors, so the prediction deviation may be different under the same circumstances. For general nonlinear curves, the influence of temperature on the crystal oscillator does not meet the general rules, so the error range cannot be determined, resulting in a large error between the final predicted frequency and the actual frequency, and the compensation effect is not ideal, so try to choose a crystal that meets the general linear law.

[0071] Figure 4 This is a schematic diagram of the structure of a clock adjustment device for an electronic device provided in an embodiment of the present application. Figure 4 As shown, the clock adjustment device of the electronic device comprises:

[0072] The recording module 402 is used to record the vibration times of the crystal oscillator of the electronic device and obtain the current temperature of the crystal oscillator of the electronic device when the global positioning system signal is disconnected;

[0073] A first determination module 404 is used to determine the frequency before and after the change in the temperature-frequency curve when the current temperature changes, according to the current temperature before and after the change, and determine the compensation frequency according to the frequency before and after the change, wherein the temperature-frequency curve is calculated by multiple temperatures and multiple frequencies of the crystal oscillator of the electronic device collected in each time period of multiple time periods;

[0074] A compensation module 406 is used to compensate the vibration frequency using the compensation frequency to obtain the compensated vibration frequency;

[0075] The second determining module 408 is configured to determine the time of the clock of the electronic device using the compensated vibration times.

[0076] This embodiment can be applied in the scenario of adjusting the time of an electronic device, and the electronic device can be a terminal, such as a mobile terminal, a host, etc. The Global Positioning System (GPS) signal can provide accurate time information for the terminal. If the GPS signal is disconnected or weak, the time of the terminal needs to be adjusted according to the frequency of the crystal oscillator of the terminal.

[0077] For example, the terminal can determine the terminal clock according to the number of vibrations of the crystal oscillator, such as the terminal clock goes back one second for every 30,000 vibrations of the crystal oscillator. The terminal can receive GPS signals within a period of time. When the GPS signal can be received, if the number of vibrations of the crystal oscillator of the terminal is affected by the temperature and the vibration speed fluctuates, then even if the time of the terminal clock determined according to the frequency of 30,000 vibrations of the crystal oscillator equal to one second is inaccurate, the terminal time can be adjusted according to the accurate clock of the GPS signal. If there is no GPS signal, the number of vibrations of the crystal oscillator is affected by the temperature and the speed fluctuates, and the time of the terminal clock determined according to the number of vibrations of the crystal oscillator is inaccurate, the compensation frequency can be determined through the temperature and frequency curve, and the current number of vibrations of the crystal oscillator of the terminal is compensated by the compensation frequency, and the time of the terminal clock is determined according to the compensated number of vibrations.

[0078] The above-mentioned crystal oscillator is an original component that vibrates at a frequency within a certain range within a certain period of time. For example, if it vibrates 30,000 times per second (the value is for illustration only and may differ from the actual situation), the system can calculate the time based on the vibration frequency of the crystal oscillator, and consider that one second has passed for every 30,000 vibrations. In actual use, the frequency of the crystal oscillator will fluctuate with the temperature, and will not stabilize at a frequency of 30,000 per second, but will fluctuate within a certain range. For example, it fluctuates within the range of 28,000-32,000 times / second.

[0079] The temperature and frequency curve may be a curve of the vibration frequency of the crystal oscillator at different temperatures, which records the stable vibration frequency of the crystal oscillator at different temperatures. The compensation frequency may be determined based on the curve.

[0080] The above-mentioned compensation frequency is the frequency used to compensate for the vibration times of the crystal oscillator. The vibration times after compensation can be used to determine the clock of the terminal.

[0081] For example, let's use an example. If the frequency of the crystal oscillator is 30,000 times per second, and it is affected by temperature and drops to 28,000 times per second, then after losing the GPS signal, you can determine that one second has passed based on the crystal oscillator vibrating 30,000 times. Now the time required for the crystal oscillator to vibrate 30,000 times is greater than 1 second, which will cause the terminal clock to be inaccurate. At this time, if the current frequency is compensated according to the compensation frequency, the terminal vibrates 28,000 times (the actual time reaches one second, but because it has not reached 30,000 times, the system believes that it has not reached one second). If the compensation frequency is 2,000 times per second, the number of crystal oscillators after compensation is 30,000 times. The system will believe that the crystal oscillator has vibrated 30,000 times, reaching one second, so the recorded time goes back one second to match the actual time.

[0082] The solution provided in the embodiment of the present application records the number of vibrations of the crystal oscillator of the electronic device and obtains the current temperature of the crystal oscillator of the electronic device when the global positioning system signal is disconnected; when the current temperature changes, the frequency before and after the change is determined in the temperature and frequency curve according to the current temperature before and after the change, and the compensation frequency is determined according to the frequency before and after the change, wherein the temperature and frequency curve is calculated by multiple temperatures and multiple frequencies of the crystal oscillator of the electronic device collected in each time period of multiple time periods; the number of vibrations is compensated using the compensation frequency to obtain the compensated number of vibrations; the time of the clock of the electronic device is determined using the compensated number of vibrations, so that when the GPS signal is disconnected, even if the temperature changes, the number of vibrations of the crystal oscillator can be compensated through the temperature and frequency curve, and the terminal clock is adjusted using the compensated number of vibrations of the crystal oscillator, thereby improving the timing accuracy.

[0083] For other examples of this embodiment, please refer to the above examples and will not be described in detail here.

[0084] like Figure 5 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0085] A memory 113, for storing computer programs;

[0086] In one embodiment of the present application, the processor 111 is used to implement the clock adjustment method of the electronic device provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113.

[0087] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, a clock adjustment method for an electronic device as provided in any of the aforementioned method embodiments is implemented.

[0088] The device embodiments described above are merely illustrative, wherein the units described 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0089] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0090] It should be understood that the terms used in the text are only for the purpose of describing specific example embodiments, and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used in the text may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0091] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A clock adjustment method for an electronic device, characterized in that: include: When the global positioning system signal is disconnected, recording the vibration times of the crystal oscillator of the electronic device and obtaining the current temperature of the crystal oscillator of the electronic device; When the current temperature changes, the frequency before and after the change is determined in a temperature and frequency curve according to the current temperature before and after the change, and the compensation frequency is determined according to the frequency before and after the change, wherein the temperature and frequency curve is calculated by multiple temperatures and multiple frequencies of the crystal oscillator of the electronic device collected in each time period of multiple time periods; Using the compensation frequency to compensate the vibration frequency, to obtain the compensated vibration frequency; The time of the clock of the electronic device is determined using the compensated number of vibrations.

2. The method according to claim 1, characterized in that Before obtaining the current temperature of the crystal oscillator of the electronic device, the method further includes: After adjusting the frequency of the crystal oscillator of the electronic device using the global positioning system signal, collecting the temperature and frequency of the crystal oscillator of the electronic device multiple times in each of multiple predetermined time periods; Performing weighted summation on multiple temperatures and multiple frequencies collected in each predetermined time period to obtain an average temperature and an average frequency in each predetermined time period; The temperature and frequency curve is determined using the average temperature and the average frequency.

3. The method according to claim 2, characterized in that The weighted summing of the multiple temperatures and the multiple frequencies collected in each predetermined time period to obtain the average temperature and the average frequency in each predetermined time period includes: The weight is determined according to the time length from the time point at which the frequency collected in each predetermined time period is generated to the end time point of each predetermined time period, wherein the larger the time length, the smaller the weight.

4. The method according to claim 2, characterized in that: The determining the temperature and frequency curve using the average temperature and the average frequency comprises: Using the average temperature and the average frequency calculated in a plurality of predetermined time periods as independent variables and values ​​in a target curve, and calculating the value of a constant in the target curve; The obtained target curve is determined as the temperature and frequency curve.

5. The method according to claim 4, characterized in that The step of using the average temperature and the average frequency calculated in a plurality of predetermined time periods as independent variables and values ​​in a target curve and calculating the value of a constant in the target curve comprises: According to the type of the crystal oscillator, a curve matching the type is determined from the second-order curve and the third-order curve as the target curve.

6. The method according to claim 1, characterized in that When the current temperature changes, determining the frequency before the change and the frequency after the change in the temperature-frequency curve according to the current temperature before and after the change, and determining the compensation frequency according to the frequency before the change and the frequency after the change includes: Input the current temperature before the change as an independent variable into the temperature and frequency curve, and determine the corresponding value as the frequency before the change; Inputting the changed current temperature as an independent variable into the temperature and frequency curve, and determining the corresponding value as the changed frequency; The difference between the frequency before the change and the frequency after the change is determined as the compensation frequency.

7. The method according to claim 1, characterized in that The method further comprises: storing the temperature and frequency curve in a cache of the electronic device; When the electronic device is restarted, acquiring the temperature and frequency curve from the cache; The time of the clock of the electronic device is determined by the obtained temperature and frequency curve.

8. A clock adjustment device for an electronic device, characterized in that: include: A recording module, used to record the vibration times of the crystal oscillator of the electronic device and obtain the current temperature of the crystal oscillator of the electronic device when the global positioning system signal is disconnected; A first determination module is used to determine, when the current temperature changes, a frequency before the change and a frequency after the change in a temperature-frequency curve according to the current temperature before and after the change, and determine a compensation frequency according to the frequency before the change and the frequency after the change, wherein the temperature-frequency curve is calculated by using multiple temperatures and multiple frequencies of a crystal oscillator of the electronic device collected in each of multiple time periods; A compensation module, used to compensate the vibration frequency using the compensation frequency to obtain the compensated vibration frequency; The second determination module is used to determine the time of the clock of the electronic device using the compensated vibration number.

9. An electronic device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein a computer program is stored in the memory, and when the processor executes the computer program, the clock adjustment method of the electronic device described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the clock adjustment method of an electronic device as described in any one of claims 1 to 7 of the present application.