CN114201001A - Compensation method and device of real-time clock, terminal equipment and medium - Google Patents
Compensation method and device of real-time clock, terminal equipment and medium Download PDFInfo
- Publication number
- CN114201001A CN114201001A CN202111527040.8A CN202111527040A CN114201001A CN 114201001 A CN114201001 A CN 114201001A CN 202111527040 A CN202111527040 A CN 202111527040A CN 114201001 A CN114201001 A CN 114201001A
- Authority
- CN
- China
- Prior art keywords
- temperature
- real
- time clock
- frequency
- quartic
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 50
- 239000013078 crystal Substances 0.000 claims abstract description 109
- 230000010355 oscillation Effects 0.000 claims abstract description 83
- 238000004590 computer program Methods 0.000 claims description 19
- 238000004364 calculation method Methods 0.000 claims description 11
- 230000008859 change Effects 0.000 claims description 4
- 238000012937 correction Methods 0.000 description 10
- 238000012545 processing Methods 0.000 description 9
- 239000003990 capacitor Substances 0.000 description 8
- 230000008569 process Effects 0.000 description 7
- 238000009529 body temperature measurement Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 6
- 230000000694 effects Effects 0.000 description 6
- 230000004044 response Effects 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- VYPSYNLAJGMNEJ-UHFFFAOYSA-N silicon dioxide Inorganic materials O=[Si]=O VYPSYNLAJGMNEJ-UHFFFAOYSA-N 0.000 description 3
- 238000012360 testing method Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 1
- 230000008030 elimination Effects 0.000 description 1
- 238000003379 elimination reaction Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000003550 marker Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000010453 quartz Substances 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
- G06F1/14—Time supervision arrangements, e.g. real time clock
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03K—PULSE TECHNIQUE
- H03K3/00—Circuits for generating electric pulses; Monostable, bistable or multistable circuits
- H03K3/01—Details
- H03K3/011—Modifications of generator to compensate for variations in physical values, e.g. voltage, temperature
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Oscillators With Electromechanical Resonators (AREA)
Abstract
The embodiment of the application is applicable to the technical field of real-time clocks, and provides a compensation method, a compensation device, terminal equipment and a medium of a real-time clock, wherein the method comprises the following steps: acquiring second pulse frequency values of an oscillation crystal of a real-time clock under a plurality of preset temperature values; determining a quartic temperature compensation curve of the real-time clock according to the plurality of temperature values and the corresponding second pulse frequency values, wherein the quartic temperature compensation curve is used for representing a frequency error of the oscillation crystal caused by temperature; collecting temperature information of the oscillation crystal; calculating a frequency deviation value of the oscillation crystal according to the temperature information and the quartic temperature compensation curve; and compensating the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock. The method is adopted to compensate the real-time clock, and the timing precision of the real-time clock can be improved.
Description
Technical Field
The present application belongs to the field of real-time clock technology, and in particular, to a method and an apparatus for compensating a real-time clock, a terminal device, and a medium.
Background
A Real Time Clock (RTC) has been widely used in various electronic products as a system synchronization and Time marker, and provides accurate Real Time for people or provides an accurate Time reference for electronic systems. At present, a quartz crystal with higher precision is adopted as a clock source of a real-time clock. However, the output frequency of the crystal has a certain frequency deviation with the change of temperature due to the inherent temperature drift characteristic of the crystal frequency. Generally, the drift of the crystal frequency along with the temperature can still meet the timing requirements of people, but on the occasion with higher timing precision requirement, the timing precision of the real-time clock can be seriously influenced by the slight frequency temperature drift phenomenon, the working range of the real-time clock is greatly limited, and the real-time clock needs to be compensated through a compensation device so as to improve the timing precision.
The current real-time clock compensation device generally needs to adopt two compensation modes of analog compensation and digital compensation at the same time. When analog compensation is employed, it is generally necessary to use an array of tunable capacitors. On one hand, the adjustable capacitor array has a temperature coefficient, and the frequency value compensated to the crystal still has deviation; on the other hand, the design cost is also increased by the adjustable capacitor array; in addition, in the low-temperature section and the high-temperature section, the temperature drift characteristic curve of the crystal is very steep, and neither the fitted quadratic curve nor the fitted cubic curve can be completely consistent with the actual temperature-frequency curve of the crystal, so that the obtained frequency deviation value and the actual deviation value have difference and difference, and the compensation effect on the crystal frequency is influenced.
Disclosure of Invention
In view of this, embodiments of the present application provide a method and an apparatus for compensating a real-time clock, a terminal device, and a medium, so as to enhance a compensation effect on an oscillation crystal of the real-time clock, thereby improving timing accuracy of the real-time clock.
A first aspect of an embodiment of the present application provides a method for compensating a real-time clock, where the method is applied to a terminal device, and the method includes:
acquiring second pulse frequency values of an oscillation crystal of a real-time clock under a plurality of preset temperature values;
determining a quartic temperature compensation curve of the real-time clock according to the plurality of temperature values and the corresponding second pulse frequency values, wherein the quartic temperature compensation curve is used for representing a frequency error of the oscillation crystal caused by temperature;
collecting temperature information of the oscillation crystal;
calculating a frequency deviation value of the oscillation crystal according to the temperature information and the quartic temperature compensation curve;
and compensating the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
A second aspect of the embodiments of the present application provides a compensation apparatus for a real-time clock, where the apparatus is applied to a terminal device, and the apparatus includes:
the data acquisition module is used for acquiring second pulse frequency values of the oscillation crystal of the real-time clock under a plurality of preset temperature values;
the curve determining module is used for determining a quartic temperature compensation curve of the real-time clock according to the plurality of temperature values and the corresponding second pulse frequency values, and the quartic temperature compensation curve is used for representing a frequency error of the oscillation crystal caused by temperature;
the temperature acquisition module is used for acquiring temperature information of the oscillation crystal;
the deviation calculation module is used for calculating the frequency deviation value of the oscillation crystal according to the temperature information and the quartic temperature compensation curve;
and the error compensation module is used for compensating the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
A third aspect of the embodiments of the present application provides an electric energy meter, where the electric energy meter compensates an error of a real-time clock due to a temperature change by using the method for compensating a real-time clock according to the first aspect.
A fourth aspect of embodiments of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor, when executing the computer program, implements the method according to the first aspect.
A fifth aspect of embodiments of the present application provides a computer-readable storage medium, in which a computer program is stored, which, when executed by a processor, implements the method according to the first aspect.
A sixth aspect of embodiments of the present application provides a computer program product, which, when run on a terminal device, causes the terminal device to perform the method of the first aspect.
Compared with the prior art, the embodiment of the application has the following advantages:
in the embodiment of the application, the frequency compensation is carried out on the oscillation crystal by adopting the quartic temperature compensation curve of the oscillation crystal. The second pulse frequency values of the oscillation crystal in the terminal equipment under a plurality of preset temperature values can be collected in advance, and then the fourth-time temperature compensation curve of the oscillation crystal is obtained according to the collected data. The terminal equipment can acquire the temperature information of the oscillation crystal in real time in the operation process, so that the frequency deviation value of the oscillation crystal is calculated according to the temperature information and the quartic temperature compensation curve; and then compensating the real-time clock based on the frequency deviation value to obtain a time signal of the real-time clock. In the embodiment of the application, the quartic temperature compensation curve with better precision is adopted to carry out frequency compensation on the oscillation crystal of the real-time clock, so that the timing precision of the real-time clock is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the embodiments or the description of the prior art will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the application, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 is a temperature drift characteristic of an oscillation crystal according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating steps of a method for compensating a real-time clock according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a compensation apparatus for a real-time clock according to an embodiment of the present application;
FIG. 4 is a schematic structural diagram of another compensation apparatus for a real-time clock according to an embodiment of the present application;
fig. 5 is a schematic diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
The technical solution of the present application will be described below by way of specific examples.
Fig. 1 is a temperature drift characteristic of an oscillation crystal according to an embodiment of the present application. Generally, the drift of the crystal frequency along with the temperature can basically meet the timing requirements of people on the real-time clock, but in the occasion with high timing precision, the fine frequency temperature drift phenomenon seriously affects the timing precision of the real-time clock and also limits the working temperature range of the real-time clock. Therefore, the real-time clock needs to be temperature compensated, that is, the frequency error of the real-time clock caused by the temperature of the oscillation crystal needs to be corrected, so as to improve the timing precision of the real-time clock.
In order to improve the timing precision after real-time clock compensation, how to more accurately fit the temperature-frequency curve of the crystal and how to improve the precision after crystal compensation in a high-temperature section and a low-temperature section need to be solved.
In the prior art, the temperature compensation of the real-time clock is performed by using a quadratic curve or a cubic curve of the temperature compensation of the oscillation crystal. For example, in the prior art, there is a real-time clock temperature compensation device using a quadratic curve for temperature compensation, and the real-time clock temperature compensation device includes an oscillation crystal, an adjustable capacitor array, a register component, a data processing unit, a decoder, a capacitor adjusting unit, a frequency modulator, and a frequency divider. In the prior art, the register component includes a temperature measurement temperature register, a drift coefficient register, a vertex temperature register, and a vertex offset register. The data processing unit is connected with the register component and used for calculating a quadratic curve and a frequency deviation value; the decoder is connected with the data processing unit, decodes the calculated frequency deviation value and outputs a coarse adjustment step number and a fine adjustment step number. And the capacitance adjusting unit adjusts the adjustable capacitor array according to the fine adjustment stepping number obtained by the decoder, and further performs analog compensation on the output of the oscillation crystal. The frequency modulator is connected with the decoder and the oscillation crystal, and performs frequency adding or frequency reducing adjustment on the oscillation frequency of the crystal according to the coarse adjustment stepping number. The frequency divider is used for carrying out frequency division processing on the adjusted frequency and outputting a time signal. Compared with the real-time clock temperature compensation device using the quadratic curve, the real-time clock temperature compensation device using the cubic curve has more registers in a register component, including a temperature measurement temperature register, a quadratic coefficient register, a quadratic vertex temperature register, a vertex offset register, a cubic coefficient register and a cubic vertex temperature register
However, in the low-temperature section and the high-temperature section, the temperature drift characteristic curve of the crystal is very steep, and neither the fitted quadratic curve nor the fitted cubic curve can be completely consistent with the actual temperature-frequency curve of the crystal, so that the obtained frequency deviation value has difference with the actual deviation value. Therefore, in the present application, a higher order quartic term is introduced to fit the temperature drift characteristic curve of the oscillating crystal, i.e. the quartic temperature compensation curve. The frequency deviation value can be obtained according to the fitted quartic temperature compensation curve, and then more accurate compensation performance can be obtained through a digital compensation mode. The digital compensation means that in a computer data acquisition system, a signal acquired on site is compensated in a digital operation mode so as to achieve the purpose of linearization or elimination of the influence of certain factors.
In the application, the quartic curve is adopted to fit the temperature-frequency curve of the crystal, so that the actual working frequency of the oscillation crystal can be more accurately fitted in a high-temperature section and a low-temperature section; thereby enabling more accurate calculation of the frequency deviation value. And performing frequency addition or frequency reduction adjustment on the oscillation frequency of the crystal according to the calculated frequency deviation, so that the timing precision of the real-time clock can be improved.
Referring to fig. 2, a schematic flow chart illustrating steps of a method for compensating a real-time clock according to an embodiment of the present application is shown, which may specifically include the following steps:
s101, the terminal equipment collects second pulse frequency values of an oscillation crystal of the real-time clock under a plurality of preset temperature values.
Specifically, the execution subject of this embodiment is a terminal device, and the method in this embodiment may be specifically executed by a real-time clock compensation device in the terminal device.
The preset temperature values at least comprise five temperature values, and the temperature values can be respectively selected in a low-temperature section, a high-temperature section and a normal-temperature section. And then testing the oscillation crystal at each temperature value to obtain a corresponding second pulse frequency value. For example, two low temperature values, one normal temperature value and two high temperature values may be selected, and then the pulse per second frequency of the oscillation crystal may be determined at these 5 temperature values.
And S102, the terminal equipment determines a quartic temperature compensation curve of the real-time clock according to the plurality of temperature values and the corresponding second pulse frequency values, wherein the quartic temperature compensation curve is used for representing the frequency error of the oscillation crystal caused by the temperature.
In the embodiment, the quartic curve with higher precision is adopted to carry out error compensation calculation on the frequency of the oscillation crystal. Specifically, the quartic temperature compensation curve may be:
Δf=σ0+β(T-T0)2+γ(T-T0)3+ζ(T-T0)4
wherein σ0For the longitudinal deviation of the vertex of the quartic temperature compensation curve, T0The temperature value at the vertex of the quartic temperature compensation curve is beta, gamma and zeta. ζ is a quartic coefficient.
And a plurality of curve parameters in the four-time temperature compensation curve can be calculated by adopting a plurality of collected temperature values and corresponding pulse per second frequencies. The curve parameters may be stored in a register component of the terminal device.
The terminal device may include a real-time clock compensation device, and the real-time clock compensation device may include a register component.
Fig. 3 is a schematic structural diagram of a real-time clock compensation apparatus according to an embodiment of the present application. As shown in fig. 3, the real time clock compensation apparatus includes: the device comprises a real-time clock correction module, a register component, a frequency modulator, an oscillation crystal and a frequency divider. The real-time clock correction module is respectively connected with the register component and the frequency modulator, and the frequency modulator is also respectively connected with the oscillation crystal and the frequency divider.
Specifically, the register component is used for storing the measured temperature value of the oscillation crystal and the parameter value of a quartic temperature compensation curve of the oscillation crystal, wherein the quartic temperature compensation curve is a temperature drift characteristic curve of the oscillation crystal obtained by adopting quartic fitting. The parameter values may include individual constants and coefficients in the curve function. Each register in the register component may be a data register, and may be used to temporarily store data, and the data in the register may be read by the real-time clock correction module.
Specifically, the register component may include a plurality of registers, for example: the system comprises a temperature measuring temperature register, an initial frequency deviation register, a vertex temperature register, a quadratic coefficient register, a cubic coefficient register and a quartic coefficient register.
The temperature measuring temperature register, the initial frequency deviation register, the vertex temperature register, the quadratic coefficient register, the cubic coefficient register and the quartic coefficient register can be used for storing curve parameter values of the quartic temperature compensation curve. E.g. σ0Can be stored in an initial frequency deviation register; t is0Can be stored in the aboveA vertex temperature register; β may be stored in the quadratic term coefficient register; γ may be stored in the cubic term coefficient register; ζ may be stored in the four-term coefficient register described above.
In practical applications, the initial values in the register elements may be filled with zeros first. Then, testing five temperature points (such as two temperature points at low temperature, one temperature point at normal temperature and two temperature points at high temperature) respectively to obtain a temperature value and a real-time clock second pulse frequency value; and then, four times of curve fitting calculation is carried out by adopting the temperature values of the five temperature points and the real-time clock second pulse frequency value, so as to obtain five curve parameters, and the corresponding parameters are written into corresponding registers. Of course, more temperature points may be selected to fit the temperature compensation curve four times, and generally at least five temperature points are selected.
And S103, the terminal equipment acquires the temperature information of the oscillation crystal.
Specifically, the temperature value measured by using a high-precision digital-to-Analog converter (ADC) may be set at intervals of a predetermined time, where the precision of the temperature value is ± 1 ℃. In the application, the temperature is measured by adopting the high-precision ADC, so that the temperature measurement precision can be guaranteed to be +/-1 ℃ within the range of-25-70 ℃. The temperature of the oscillation crystal can be accurately measured, so that the frequency deviation value of the oscillation crystal caused by the temperature can be accurately calculated, the frequency of the oscillation crystal can be corrected more accurately, and the timing of the real-time clock is more accurate.
In order to ensure the accuracy of data when the temperature information is acquired, the actual temperature measurement value can be obtained after the ambient temperature is stable for a long time, and then the actual temperature measurement value is written into the temperature measurement temperature register.
And S104, the terminal equipment calculates the frequency deviation value of the oscillation crystal according to the temperature information and the quartic temperature compensation curve.
The terminal equipment can substitute the temperature information into the four-time temperature compensation curve to calculate the frequency deviation value of the oscillation crystal. Specifically, a plurality of curve parameter values of the four-time temperature compensation curve can be obtained from the register component; and then substituting the multiple curve parameter values and the temperature information into the four temperature compensation curves to calculate to obtain the frequency deviation value of the oscillation crystal.
Specifically, the real-time clock calibration module in the temperature compensation apparatus shown in fig. 3 may be configured to output a frequency deviation value corresponding to the curve parameter value and the temperature value. One side of the real-time clock correction module is connected with the register component and can read the numerical value in each register; therefore, the frequency deviation value of the oscillation crystal can be calculated according to the numerical value in the register component; the other side of the real-time clock correction module is connected with the frequency modulator, and the frequency deviation value obtained through calculation is sent to the frequency modulator in the form of a digital signal. The real-time clock correction module can be a microprocessor or an arithmetic unit and the like.
And S105, the terminal equipment compensates the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
Specifically, the terminal device may modify a count value of a frequency modulator corresponding to the oscillation crystal according to the frequency deviation value to obtain a compensated actual frequency value of the oscillation crystal; the time signal of the real-time clock is then calculated from the actual frequency value. The frequency modulator of fig. 3 may be used to adjust the frequency of the crystal according to the frequency deviation value. One side of the frequency modulator is connected with the output end of the oscillation crystal and can receive the frequency output by the oscillation crystal; the other side is connected with the real-time clock correction module and can receive the frequency deviation value. According to the frequency deviation value and the frequency value of the oscillation crystal, the frequency modulator can correct the frequency of the oscillation crystal, determine the actual frequency value of the oscillation crystal, and send the actual frequency value to the frequency divider in the form of a digital signal. The frequency modulator modifies the count value of the real-time clock frequency modulator according to the frequency deviation value output by the real-time clock correction module, and performs frequency adding or frequency reducing adjustment to complete digital compensation. The frequency adding means adding one or more clock cycles to the count value, and the frequency reducing means reducing one or more clock cycles to the count value; digital compensation of the oscillating crystal is accomplished by either adding or subtracting frequency.
The frequency divider in fig. 3 is used for performing frequency division processing on the adjusted frequency of the oscillation crystal and outputting a time signal after correction compensation. Equivalently, the frequency divider may receive the actual frequency value of the oscillation crystal output by the frequency modulator and then output a time signal of the oscillation crystal based on the actual frequency value of the oscillation crystal. The adjusted frequency output is output by frequency division by a frequency divider, and a pulse per second signal is output. The terminal equipment can determine the travel time error of the real-time clock according to the second pulse signal precision, so that the actual effect of the quartic temperature compensation curve compensation is verified. When the compensation effect is not expected, the steps of S101-S102 may be re-executed to correct the four temperature compensation curves.
In addition, the real-time clock compensation device in the application can automatically complete the temperature compensation operation of the real-time clock without the participation of a central processing unit. That is, according to the measured temperature, the real-time clock compensation device can automatically adjust the frequency of the oscillation crystal and then output the corrected time signal, and a central processing unit of the terminal equipment is not required to control the correction process of the real-time clock, so that the calculation resource of the central processing unit is saved.
In the prior art, temperature compensation of a real-time clock generally requires both analog compensation and digital compensation. Specifically, in the prior art, the frequency of the oscillation crystal needs to be adjusted through the capacitor array and the frequency modulator at the same time; in the application, however, only the real-time clock needs to be digitally compensated through the frequency modulator, and a capacitor array is not needed, so that the cost is reduced.
To sum up, the real-time clock compensation device of the scheme of the application can compensate the real-time clock with higher precision, improves the stability of the real-time clock time-travelling precision, has the advantages of wide specific compensation range, higher compensation precision and simple operation, and can effectively reduce the design and test cost of the chip.
Because the crystal temperature drift characteristic curve under the fitting low temperature and the high temperature is removed by adopting the higher quartic term, the fitted quartic temperature compensation curve is closer to the actual crystal curve at the high temperature and the low temperature, the obtained compensation effect is better, and the working temperature range of the real-time clock is widened. Therefore, the real-time clock compensation scheme has certain advantages for equipment with high-temperature and low-temperature application scenes. In addition, the real-time clock compensation scheme of the application has applicability to devices requiring higher real-time clock accuracy
This application introduces higher quartic item on traditional crystal fitting curve's basis, measures the more accurate crystal temperature frequency offset curve of fitting through five temperature points, has solved the not good stubborn of crystal compensation effect under low temperature and the high temperature environment, has realized the high accuracy that real-time clock went the time. Because the quartic temperature curve is steeper, the temperature frequency curves of the low-temperature section and the high-temperature section can be better fitted, and the result obtained by adopting the quartic temperature compensation curve is more accurate.
In the prior art, a quadratic curve or cubic curve fitting mode is adopted, and the error of a compensated time signal can be controlled within the range of +/-1 ppm; the method can reduce the error to be within +/-0.5 ppm. In order to improve the applicability and the convenience of the crystal compensation process, the frequency modulator is used for carrying out digital compensation on the oscillation frequency, and the crystal compensation circuit has the advantages of being simple in circuit implementation and convenient to operate.
The method realizes high-precision compensation of the crystal by using the integrated circuit, and the main protection point is a concrete realization method of the crystal quartic curve temperature compensation on the integrated circuit.
It should be noted that, the sequence numbers of the steps in the foregoing embodiments do not mean the execution sequence, and the execution sequence of each process should be determined by the function and the inherent logic of the process, and should not constitute any limitation on the implementation process of the embodiments of the present application.
Referring to fig. 4, a schematic diagram of a compensation apparatus for a real-time clock according to an embodiment of the present application is shown, and specifically may include a data acquisition module 41, a curve determination module 42, a temperature acquisition module 43, a deviation calculation module 44, and an error compensation module 45, where:
the data acquisition module 41 is configured to acquire second pulse frequency values of an oscillation crystal of the real-time clock at a plurality of preset temperature values;
a curve determining module 42, configured to determine a quartic temperature compensation curve of the real-time clock according to the plurality of temperature values and corresponding second pulse frequency values, where the quartic temperature compensation curve is used to characterize a frequency error of the oscillation crystal due to temperature;
a temperature acquisition module 43, configured to acquire temperature information of the oscillation crystal;
a deviation calculating module 44, configured to calculate a frequency deviation value of the oscillation crystal according to the temperature information and the quartic temperature compensation curve;
and an error compensation module 45, configured to compensate the real-time clock according to the frequency deviation value, so as to obtain a time signal of the real-time clock.
In one possible implementation, the curve determining module 42 includes:
the fitting submodule is used for performing quartic fitting by adopting the temperature value and the corresponding second pulse frequency value to obtain a quartic temperature compensation curve, and the quartic temperature compensation curve comprises a plurality of curve parameter values;
and the storage submodule is used for storing the curve parameter values into a register component of the terminal equipment.
In a possible implementation manner, the temperature acquisition module 43 includes:
and the acquisition submodule is used for acquiring the real-time temperature of the oscillation crystal by adopting a preset digital-to-analog converter at intervals of preset time.
In a possible implementation, the error compensation module 45 includes:
the modification submodule is used for modifying the count value of the frequency modulator corresponding to the oscillation crystal according to the frequency deviation value to obtain the actual frequency value of the compensated oscillation crystal;
and the determining submodule is used for determining the time signal of the real-time clock according to the actual frequency value.
In a possible implementation manner, the error compensation module 45 further includes:
the pulse per second signal output submodule is used for carrying out frequency division output on the actual frequency value and outputting a pulse per second signal;
and the travel time error determining submodule is used for determining the travel time error of the real-time clock according to the pulse per second signal.
The deviation calculation module 44 includes:
the reading sub-module is used for acquiring a plurality of curve parameter values of the quartic temperature compensation curve from the register component;
and the calculating submodule is used for substituting the plurality of curve parameter values and the temperature information into the quartic temperature compensation curve for calculation to obtain the frequency deviation value of the oscillation crystal.
For the apparatus embodiment, since it is substantially similar to the method embodiment, it is described relatively simply, and reference may be made to the description of the method embodiment section for relevant points.
Fig. 5 is a schematic structural diagram of a terminal device according to an embodiment of the present application. As shown in fig. 5, the terminal device 5 of this embodiment includes: at least one processor 50 (only one shown in fig. 5), a memory 51, and a computer program 52 stored in the memory 51 and executable on the at least one processor 50, the processor 50 implementing the steps in any of the various method embodiments described above when executing the computer program 52.
The terminal device 5 may be a desktop computer, a notebook, a palm computer, a cloud terminal device, or other computing devices. The terminal device may include, but is not limited to, a processor 50, a memory 51. Those skilled in the art will appreciate that fig. 5 is only an example of the terminal device 5, and does not constitute a limitation to the terminal device 5, and may include more or less components than those shown, or combine some components, or different components, such as an input-output device, a network access device, and the like.
The Processor 50 may be a Central Processing Unit (CPU), and the Processor 50 may be other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 51 may in some embodiments be an internal storage unit of the terminal device 5, such as a hard disk or a memory of the terminal device 5. The memory 51 may also be an external storage device of the terminal device 5 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 5. Further, the memory 51 may also include both an internal storage unit and an external storage device of the terminal device 5. The memory 51 is used for storing an operating system, an application program, a BootLoader (BootLoader), data, and other programs, such as program codes of the computer program. The memory 51 may also be used to temporarily store data that has been output or is to be output.
The embodiment of the application also provides an electric energy meter, and the electric energy meter adopts the compensation method of the real-time clock in the above method embodiments to compensate the error of the real-time clock caused by the temperature change.
The embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps in the above-mentioned method embodiments.
The embodiments of the present application provide a computer program product, which when running on a terminal device, enables the terminal device to implement the steps in the above method embodiments when executed.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing apparatus/terminal apparatus, a recording medium, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same. Although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.
Claims (10)
1. A method for compensating a real-time clock, the method being applied to a terminal device, the method comprising:
acquiring second pulse frequency values of an oscillation crystal of a real-time clock under a plurality of preset temperature values;
determining a quartic temperature compensation curve of the real-time clock according to the plurality of temperature values and the corresponding second pulse frequency values, wherein the quartic temperature compensation curve is used for representing a frequency error of the oscillation crystal caused by temperature;
collecting temperature information of the oscillation crystal;
calculating a frequency deviation value of the oscillation crystal according to the temperature information and the quartic temperature compensation curve;
and compensating the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
2. The method of claim 1, wherein said determining four temperature compensation curves for said real time clock based on said temperature values and corresponding second pulse frequency values comprises:
performing quartic fitting by using the temperature value and the corresponding second pulse frequency value to obtain a quartic temperature compensation curve, wherein the quartic temperature compensation curve comprises a plurality of curve parameter values;
storing the plurality of curve parameter values into a register component of the terminal device.
3. The method of any of claim 1, wherein the collecting temperature information of the oscillation crystal comprises:
and acquiring the real-time temperature of the oscillation crystal by adopting a preset digital-to-analog converter at intervals of preset time.
4. A method according to any of claims 1-3, wherein said compensating said real time clock according to said frequency deviation value comprises:
modifying the count value of a frequency modulator corresponding to the oscillation crystal according to the frequency deviation value to obtain the actual frequency value of the compensated oscillation crystal;
and determining the time signal of the real-time clock according to the actual frequency value.
5. The method of claim 4, wherein after said determining the time signal of the real-time clock from the actual frequency value, further comprising:
carrying out frequency division output on the actual frequency value and outputting a pulse per second signal;
and determining the travel time error of the real-time clock according to the pulse per second signal.
6. The method of claim 2, wherein calculating the frequency offset value for the oscillating crystal based on the temperature information and the quartic temperature compensation curve comprises:
obtaining a plurality of curve parameter values of the quartic temperature compensation curve from the register component;
and substituting the plurality of curve parameter values and the temperature information into the quartic temperature compensation curve for calculation to obtain a frequency deviation value of the oscillation crystal.
7. A compensation device for a real-time clock, the device being applied to a terminal device, the device comprising:
the data acquisition module is used for acquiring second pulse frequency values of the oscillation crystal of the real-time clock under a plurality of preset temperature values;
the curve determining module is used for determining a quartic temperature compensation curve of the real-time clock according to the plurality of temperature values and the corresponding second pulse frequency values, and the quartic temperature compensation curve is used for representing a frequency error of the oscillation crystal caused by temperature;
the temperature acquisition module is used for acquiring temperature information of the oscillation crystal;
the deviation calculation module is used for calculating the frequency deviation value of the oscillation crystal according to the temperature information and the quartic temperature compensation curve;
and the error compensation module is used for compensating the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
8. An electric energy meter, characterized in that the electric energy meter compensates for an error of a real time clock due to a temperature change by using the method for compensating a real time clock according to any one of claims 1 to 6.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-6 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111527040.8A CN114201001A (en) | 2021-12-14 | 2021-12-14 | Compensation method and device of real-time clock, terminal equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111527040.8A CN114201001A (en) | 2021-12-14 | 2021-12-14 | Compensation method and device of real-time clock, terminal equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114201001A true CN114201001A (en) | 2022-03-18 |
Family
ID=80653570
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111527040.8A Pending CN114201001A (en) | 2021-12-14 | 2021-12-14 | Compensation method and device of real-time clock, terminal equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114201001A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115002892A (en) * | 2022-04-18 | 2022-09-02 | 芯翼信息科技(上海)有限公司 | Method, terminal and medium for reducing influence of temperature drift of crystal oscillator of narrow-band system |
CN116865746A (en) * | 2023-07-31 | 2023-10-10 | 青岛鼎信通讯股份有限公司 | Clock circuit control method, device and medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103248358A (en) * | 2013-05-30 | 2013-08-14 | 上海贝岭股份有限公司 | Real-time clock compensating device and method |
CN103269219A (en) * | 2013-05-30 | 2013-08-28 | 上海贝岭股份有限公司 | Real-time clock compensation device and method |
CN108900161A (en) * | 2018-05-21 | 2018-11-27 | 阮晓萍 | A kind of crystal resonator clock-temperature-error compensation method |
CN109921785A (en) * | 2018-12-24 | 2019-06-21 | 钟祥博谦信息科技有限公司 | A kind of temperature-compensation circuit of crystal oscillator |
CN113644908A (en) * | 2021-10-13 | 2021-11-12 | 北京炬玄智能科技有限公司 | Temperature compensation method and system of crystal oscillator |
-
2021
- 2021-12-14 CN CN202111527040.8A patent/CN114201001A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103248358A (en) * | 2013-05-30 | 2013-08-14 | 上海贝岭股份有限公司 | Real-time clock compensating device and method |
CN103269219A (en) * | 2013-05-30 | 2013-08-28 | 上海贝岭股份有限公司 | Real-time clock compensation device and method |
CN108900161A (en) * | 2018-05-21 | 2018-11-27 | 阮晓萍 | A kind of crystal resonator clock-temperature-error compensation method |
CN109921785A (en) * | 2018-12-24 | 2019-06-21 | 钟祥博谦信息科技有限公司 | A kind of temperature-compensation circuit of crystal oscillator |
CN113644908A (en) * | 2021-10-13 | 2021-11-12 | 北京炬玄智能科技有限公司 | Temperature compensation method and system of crystal oscillator |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115002892A (en) * | 2022-04-18 | 2022-09-02 | 芯翼信息科技(上海)有限公司 | Method, terminal and medium for reducing influence of temperature drift of crystal oscillator of narrow-band system |
CN115002892B (en) * | 2022-04-18 | 2023-12-01 | 芯翼信息科技(上海)有限公司 | Method, terminal and medium for reducing influence of temperature drift of crystal oscillator of narrow-band system |
CN116865746A (en) * | 2023-07-31 | 2023-10-10 | 青岛鼎信通讯股份有限公司 | Clock circuit control method, device and medium |
CN116865746B (en) * | 2023-07-31 | 2024-03-29 | 青岛鼎信通讯股份有限公司 | Clock circuit control method, device and medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114201001A (en) | Compensation method and device of real-time clock, terminal equipment and medium | |
CN103176400B (en) | Intelligent ammeter clock calibration method | |
CN109581856B (en) | Time synchronization and time keeping method based on high-performance crystal oscillator frequency calibration | |
CN107465393B (en) | System and method for frequency compensation of real time clock system | |
CN107272821B (en) | Real-time clock calibration method and device, storage medium and electronic equipment | |
CN108037656A (en) | Real-time timepiece chip calibration method, device and terminal device | |
CN103699001B (en) | Utilize clocking method and system that constant-temperature crystal oscillator realizes | |
CN116980065B (en) | Clock calibration method, clock calibration device, terminal equipment and storage medium | |
CN104297716A (en) | Intelligent electric meter RTC calibrating method | |
KR101942719B1 (en) | Real Time Clock Apparatus | |
CN104375004A (en) | Method and system for measuring crystal oscillator frequency error | |
EP0901231A2 (en) | Method and apparatus for producing a temperature stable frequency at reduced cost | |
CN103248358A (en) | Real-time clock compensating device and method | |
CN113504401A (en) | Method, device and system for compensating time error of electric energy meter diary | |
CN104753528A (en) | Segmental automatic frequency control (AFC) calibration method and system | |
CN116185128B (en) | MCU chip internal clock calibration method and circuit | |
CN112083226A (en) | Frequency calibration method and device for electronic equipment, medium and electronic equipment | |
CN115616541A (en) | Calibration method for reference clock of sonobuoy | |
CN211180593U (en) | Time frequency detection equipment | |
Cetina et al. | Analysis and selection of appropriate components for power system metrology instruments | |
CN112737574A (en) | Timing calibration method of chip internal clock source and related device | |
CN110830033B (en) | Clock frequency compensation method and system for GNSS system, storage medium and terminal | |
CN112731790A (en) | Method for improving RTC (real time clock) calibration precision based on time domain segmented interpolation compensation | |
CN103269219A (en) | Real-time clock compensation device and method | |
CN111367157A (en) | Multipath phase comparison measuring system and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |