A real-time clock compensation method, device, terminal equipment and medium
By using the four-time temperature compensation curve to fit the temperature-frequency curve of the oscillating crystal, and compute and compensate the frequency deviation value of the real-time clock, the problem of inaccurate fitting of low-temperature and high-temperature segments in the prior art is solved, and higher accuracy is achieved. Timer and wider operating temperature range.
Patent Information
- Application Number
- CN202111527040.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2041-12-14
AI Technical Summary
The existing real-time clock compensation device has inaccurate fitting of the temperature drift characteristic curves in the low-temperature and high-temperature sections, resulting in errors in the calculation of frequency deviation values and affecting the timing accuracy.
The temperature-frequency curve of the oscillating crystal is used to fit the temperature-frequency curve of the oscillating crystal. By collecting the second pulse frequency values at multiple temperature values, the four-speed temperature compensation curve is determined, the frequency deviation value is calculated, and digital compensation is performed.
The timing accuracy of the real-time clock is improved, the time signal error is reduced within ±0.5ppm, and the operating temperature range of the real-time clock is widened.
Smart Images

Figure CN114201001B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of real-time clocks, and in particular, relates to a compensation method, device, terminal equipment and medium for a real-time clock. Background Art
[0002] Real-time clock (RTC) has been widely used in various electronic products as a system synchronization and time mark. It provides people with accurate real-time time or provides an accurate time reference for electronic systems. At present, real-time clocks use high-precision quartz crystals as clock sources. However, due to the inherent temperature drift characteristics of the crystal frequency, the output frequency of the crystal will produce a certain frequency deviation with the change of temperature. In general, the drift of the crystal frequency with temperature can still meet people's timing requirements, but in situations where the timing accuracy is required to be high, these subtle frequency temperature drift phenomena will seriously affect the timing accuracy of the real-time clock, greatly limiting the working range of the real-time clock. It is necessary to compensate the real-time clock through a compensation device to improve the timing accuracy.
[0003] The current real-time clock compensation device generally needs to use both analog compensation and digital compensation. When using analog compensation, an adjustable capacitor array is generally required. On the one hand, the adjustable capacitor array has a temperature coefficient, which will still cause deviations in the frequency value compensated to the crystal; on the other hand, the adjustable capacitor array also increases the design cost; in addition, in the low and high temperature ranges, the temperature drift characteristic curve of the crystal is very steep, and the fitted quadratic and cubic curves cannot be completely consistent with the actual temperature-frequency curve of the crystal, resulting in the obtained frequency deviation value being different from the actual deviation value, affecting the compensation effect of the crystal frequency. Summary of the invention
[0004] In view of this, an embodiment of the present application provides a real-time clock compensation method, apparatus, terminal device and medium to enhance the compensation effect of the oscillation crystal of the real-time clock, thereby improving the timing accuracy of the real-time clock.
[0005] A first aspect of an embodiment of the present application provides a real-time clock compensation method, the method being applied to a terminal device, the method comprising:
[0006] Collect the pulse-per-second frequency values of the oscillating crystal of the real-time clock at multiple preset temperature values;
[0007] Determine a fourth temperature compensation curve of the real-time clock according to the multiple temperature values and the corresponding second pulse frequency values, wherein the fourth temperature compensation curve is used to characterize the frequency error of the oscillating crystal caused by the temperature;
[0008] Collecting temperature information of the oscillating crystal;
[0009] Calculating the frequency deviation value of the oscillation crystal according to the temperature information and the fourth temperature compensation curve;
[0010] The real-time clock is compensated according to the frequency deviation value to obtain a time signal of the real-time clock.
[0011] A second aspect of an embodiment of the present application provides a real-time clock compensation device, the device being applied to a terminal device, the device comprising:
[0012] A data acquisition module, used for acquiring the pulse-per-second frequency value of the oscillating crystal of the real-time clock at a plurality of preset temperature values;
[0013] A curve determination module, used to determine a fourth temperature compensation curve of the real-time clock according to the multiple temperature values and the corresponding second pulse frequency values, wherein the fourth temperature compensation curve is used to characterize the frequency error of the oscillating crystal caused by the temperature;
[0014] A temperature acquisition module, used to acquire temperature information of the oscillating crystal;
[0015] A deviation calculation module, used for calculating the frequency deviation value of the oscillation crystal according to the temperature information and the fourth temperature compensation curve;
[0016] The error compensation module is used to compensate the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
[0017] A third aspect of an embodiment of the present application provides an electric energy meter, which uses the real-time clock compensation method described in the first aspect to compensate for the error of the real-time clock caused by temperature change.
[0018] A fourth aspect of an embodiment 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, wherein the processor implements the method described in the first aspect when executing the computer program.
[0019] A fifth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect above is implemented.
[0020] A sixth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the method described in the first aspect.
[0021] Compared with the prior art, the embodiments of the present application have the following advantages:
[0022] In the embodiment of the present application, the fourth temperature compensation curve of the oscillating crystal is used to perform frequency compensation on the oscillating crystal. The second pulse frequency values of the oscillating crystal in the terminal device at multiple preset temperature values can be collected in advance, and then the fourth temperature compensation curve of the oscillating crystal is obtained based on the collected data. During the operation of the terminal device, the temperature information of the oscillating crystal can be collected in real time, so as to calculate the frequency deviation value of the oscillating crystal based on the temperature information and the fourth temperature compensation curve; then the real-time clock is compensated based on the frequency deviation value to obtain the time signal of the real-time clock. In the embodiment of the present application, a fourth temperature compensation curve with better accuracy is used to perform frequency compensation on the oscillating crystal of the real-time clock, thereby improving the timing accuracy of the real-time clock. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 is a temperature drift characteristic curve of an oscillating crystal provided by an embodiment of the present application;
[0025] Figure 2 This is a schematic flow chart of the steps of a real-time clock compensation method provided by an embodiment of the present application;
[0026] Figure 3 It is a structural schematic diagram of a real-time clock compensation device provided by an embodiment of the present application;
[0027] Figure 4 It is a structural schematic diagram of another real-time clock compensation device provided by an embodiment of the present application;
[0028] Figure 5 This is a schematic diagram of a terminal device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0029] In the following description, specific details such as specific system structures, technologies, etc. are proposed for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from hindering the description of the present application.
[0030] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0031] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0032] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0033] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0034] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0035] The technical solution of the present application is described below through specific embodiments.
[0036] Figure 1This is a temperature drift characteristic curve of an oscillating crystal of an embodiment of the present application. In general, the drift of the crystal frequency with temperature can basically meet people's timing requirements for real-time clocks, but in situations where high timing accuracy is required, these subtle frequency temperature drift phenomena seriously affect the timing accuracy of the real-time clock and also limit the operating temperature range of the real-time clock. Therefore, it is necessary to perform temperature compensation on the real-time clock, that is, it is necessary to correct the frequency error of the real-time clock caused by the temperature of the oscillating crystal, so as to improve the timing accuracy of the real-time clock.
[0037] In order to improve the timing accuracy of the real-time clock after compensation, it is necessary to solve how to fit the temperature-frequency curve of the crystal more accurately and how to improve the accuracy of the crystal after compensation in the high and low temperature ranges.
[0038] In the prior art, the temperature compensation of the real-time clock is performed using a quadratic curve or a cubic curve of the temperature compensation of the oscillating crystal. For example, there is a real-time clock temperature compensation device that uses a quadratic curve for temperature compensation in the prior art, and the real-time clock compensation device includes an oscillating crystal, an adjustable capacitor array, a register component, a data processing unit, a decoder, a capacitor adjustment unit, a frequency modulator, and a frequency divider. Among them, 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 to the register component, and the data processing unit is used to calculate the quadratic curve and the frequency deviation value; the decoder is connected to the data processing unit, decodes the calculated frequency deviation value, and outputs the coarse adjustment step number and the fine adjustment step number. The capacitor adjustment unit adjusts the adjustable capacitor array according to the fine adjustment step number obtained by the decoder, and then performs analog compensation on the output of the oscillating crystal. The frequency modulator is connected to the decoder and the oscillating crystal, and the oscillation frequency of the crystal is adjusted by adding or subtracting the frequency according to the coarse adjustment step number. The frequency divider is used to divide the adjusted frequency and output a time signal. The prior art also includes a real-time clock temperature compensation device that uses a cubic curve for temperature compensation. Compared with a real-time clock temperature compensation device that uses a quadratic curve, a register component of a real-time clock temperature compensation device that uses a cubic curve has more registers, including a temperature measurement temperature register, a quadratic term coefficient register, a quadratic term vertex temperature register, a vertex offset register, a cubic term coefficient register, and a cubic term vertex temperature register.
[0039] However, in the low temperature section and the high temperature section, the temperature drift characteristic curve of the crystal is very steep, and the fitted quadratic curve and cubic curve cannot be completely consistent with the actual temperature-frequency curve of the crystal, resulting in the obtained frequency deviation value being different from the actual deviation value. Therefore, in this application, a higher-order quartic term is introduced to fit the temperature drift characteristic curve of the oscillating crystal, and the temperature drift characteristic curve is also a quartic temperature compensation curve. The frequency deviation value can be obtained according to the fitted quartic temperature compensation curve, and then a more accurate compensation performance can be obtained by digital compensation. Digital compensation refers to compensating the signals collected on site in a digital calculation method in a computer data acquisition system to achieve the purpose of linearization or eliminating the influence of certain factors.
[0040] In this application, a quartic curve is used to fit the temperature-frequency curve of the crystal, which can more accurately fit the actual operating frequency of the oscillating crystal in the high temperature section and the low temperature section; thus, the frequency deviation value can be calculated more accurately. The oscillation frequency of the crystal is adjusted by increasing or decreasing the frequency according to the calculated frequency deviation, which can improve the timing accuracy of the real-time clock.
[0041] Reference Figure 2 , shows a schematic flow chart of a method for compensating a real-time clock according to an embodiment of the present application, which may specifically include the following steps:
[0042] S101, the terminal device collects the pulse-per-second frequency values of the oscillation crystal of the real-time clock at multiple preset temperature values.
[0043] Specifically, the execution subject of this embodiment is a terminal device, and the method in this embodiment can be executed by a real-time clock compensation device in the terminal device.
[0044] The above-mentioned preset multiple temperature values include at least five temperature values, and the temperature values can select multiple temperature values in the low temperature section, the high temperature section and the normal temperature section respectively. Then the oscillating crystal is tested at each temperature value to obtain the corresponding second pulse frequency value. For example, two low temperature values, one normal temperature value and two high temperature values can be selected, and then the second pulse frequency of the oscillating crystal can be determined at these five temperature values.
[0045] S102, the terminal device determines a fourth temperature compensation curve of the real-time clock according to the multiple temperature values and the corresponding second pulse frequency values, wherein the fourth temperature compensation curve is used to characterize the frequency error of the oscillation crystal caused by temperature.
[0046] In this embodiment, a more accurate quartic curve is used to perform error compensation calculation of the oscillation crystal frequency. Specifically, the quartic temperature compensation curve can be:
[0047] Δf=σ0+β(T-T0) 2 +γ(T-T0)3 +ζ(T-T0) 4
[0048] Among them, σ0 is the longitudinal deviation value of the vertex of the fourth temperature compensation curve, T0 is the temperature value of the vertex of the fourth temperature compensation curve, β is the coefficient of the quadratic term, γ is the coefficient of the cubic term, and ζ is the coefficient of the quartic term. ζ is the coefficient of the quartic term.
[0049] Using the collected multiple temperature values and the corresponding pulse per second frequency, multiple curve parameters in the four-time temperature compensation curve can be calculated. The curve parameters can be stored in the register component of the terminal device.
[0050] The terminal device may include a real-time clock compensation device, and the real-time clock compensation device may include a register component.
[0051] Figure 3 FIG. 1 is a schematic diagram showing the structure of a real-time clock compensation device according to an embodiment of the present application. Figure 3 As shown, the real-time clock compensation device includes: a real-time clock correction module, a register component, a frequency modulator, an oscillating crystal and a frequency divider. The real-time clock correction module is connected to the register component and the frequency modulator respectively, and the frequency modulator is also connected to the oscillating crystal and the frequency divider respectively.
[0052] Specifically, the register component is used to store the measured temperature value of the oscillating crystal and the parameter value of the fourth temperature compensation curve of the oscillating crystal, and the fourth temperature compensation curve is the temperature drift characteristic curve of the oscillating crystal obtained by fitting the fourth term. The parameter value may include various constants and coefficients in the curve function. Each register in the register component may be a data register, which can be used to temporarily store data, and the data in the register can be read by the real-time clock correction module.
[0053] Specifically, the register component may include a plurality of registers, for example, a temperature measurement register, an initial frequency deviation register, a vertex temperature register, a quadratic term coefficient register, a cubic term coefficient register, and a quartic term coefficient register.
[0054] Among them, the temperature measurement temperature register, the initial frequency deviation register, the vertex temperature register, the quadratic term coefficient register, the cubic term coefficient register and the quartic term coefficient register can be used to store the curve parameter values of the quartic temperature compensation curve. For example, σ0 can be stored in the initial frequency deviation register; T0 can be stored in the vertex temperature register; β can be stored in the quadratic term coefficient register; γ can be stored in the cubic term coefficient register; ζ can be stored in the quartic term coefficient register.
[0055] In practical applications, the initial value in the register component can be filled with zero first. Then, five temperature points (e.g., two temperature points at low temperature, one temperature point at normal temperature, and two temperature points at high temperature) are tested respectively to obtain the temperature value and the real-time clock pulse frequency value; then, the temperature values of the five temperature points and the real-time clock pulse frequency value are used to perform a fourth-order curve fitting calculation, and then five curve parameters are obtained, and the corresponding parameters are written into the corresponding register. Of course, more temperature measurement points can also be selected to perform a fourth-order fitting on the temperature compensation curve. Generally, at least five temperature measurement points need to be selected.
[0056] S103, the terminal device collects temperature information of the oscillation crystal.
[0057] Specifically, a temperature value can be measured by a high-precision analog-to-digital converter (ADC) at preset intervals, and the temperature value has an accuracy of ±1°C. In the present application, since a high-precision ADC is used to measure the temperature, the temperature measurement accuracy can be guaranteed to be ±1°C within the range of -25°C to 70°C. Since the temperature of the oscillating crystal can be accurately measured, the frequency deviation value of the oscillating crystal due to the temperature can be accurately calculated, and the frequency of the oscillating crystal can be more accurately corrected, making the timing of the real-time clock more accurate.
[0058] To ensure the accuracy of the data when collecting temperature information, the actual temperature value can be obtained after the ambient temperature has been stable for a long enough time, and then written into the temperature measurement register.
[0059] S104, the terminal device calculates the frequency deviation value of the oscillation crystal according to the temperature information and the fourth temperature compensation curve.
[0060] The terminal device can substitute the temperature information into the fourth temperature compensation curve to calculate the frequency deviation value of the oscillating crystal. Specifically, multiple curve parameter values of the fourth temperature compensation curve can be obtained from the register component; then the multiple curve parameter values and the temperature information are substituted into the fourth temperature compensation curve for calculation to obtain the frequency deviation value of the oscillating crystal.
[0061] Specifically, Figure 3 The real-time clock correction module in the temperature compensation device shown can be used 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 to the register component, and the values in each register can be read; thus, the frequency deviation value of the oscillation crystal can be calculated according to the values in the register component; the other side of the real-time clock correction module is connected to the frequency modulator, and the calculated frequency deviation value can be 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, etc.
[0062] S105, the terminal device compensates the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
[0063] Specifically, the terminal device can modify 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 oscillation crystal after compensation; and then calculate the time signal of the real-time clock according to the actual frequency value. Figure 3 The frequency modulator in the device can be used to adjust the frequency of the oscillating crystal according to the frequency deviation value. One side of the frequency modulator is connected to the output end of the oscillating crystal to receive the frequency output by the oscillating crystal; the other side is connected to the real-time clock correction module to receive the frequency deviation value. According to the frequency deviation value and the frequency value of the oscillating crystal, the frequency modulator can correct the frequency of the oscillating crystal, determine the actual frequency value of the oscillating crystal, and send the actual frequency value to the frequency divider in the form of a digital signal. The frequency modulator modulates 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 increase or frequency decrease adjustment to complete digital compensation. Frequency increase refers to adding one or more clock cycles to the count value, and frequency decrease refers to reducing one or more clock cycles to the count value; digital compensation of the oscillating crystal is completed by frequency increase or frequency decrease.
[0064] Figure 3 The frequency divider in is used to divide the frequency of the adjusted oscillating crystal and output the corrected and compensated time signal. In other words, the frequency divider can receive the actual frequency value of the oscillating crystal output by the frequency modulator, and then output the time signal of the oscillating crystal according to the actual frequency value of the oscillating crystal. In addition, the frequency divider is used to divide the adjusted frequency output and output a second pulse signal. The terminal device can determine the travel time error of the real-time clock according to the accuracy of the second pulse signal, thereby verifying the actual effect of the compensation of the fourth temperature compensation curve. When the compensation effect does not meet expectations, the steps S101-S102 can be re-executed to correct the fourth temperature compensation curve.
[0065] 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 involvement of the central processor. That is, according to the measured temperature, the real-time clock compensation device can automatically adjust the frequency of the oscillating crystal and then output the corrected time signal, without the need for the central processor of the terminal device to control the correction process of the real-time clock, thereby saving the computing resources of the central processor.
[0066] 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 oscillating crystal needs to be adjusted by both a capacitor array and a frequency modulator; however, in the present application, only the frequency modulator is needed to digitally compensate the real-time clock, and no capacitor array is needed, thereby reducing costs.
[0067] To sum up, the real-time clock compensation device of the present application scheme can compensate the real-time clock with higher precision and improve the stability of the real-time clock's timing accuracy. It has the advantages of a wide compensation range, higher compensation accuracy, and simple operation, and can effectively reduce the design and testing costs of the chip.
[0068] Because the present application uses a higher-order quartic term to fit the crystal temperature drift characteristic curve at low and high temperatures, the fitted quartic temperature compensation curve is closer to the actual crystal curve at high and low temperatures, and the compensation effect is better, which broadens the operating temperature range of the real-time clock. Therefore, for devices with high and low temperature application scenarios, the real-time clock compensation scheme of the present application has certain advantages. In addition, for devices that require higher real-time clock accuracy, the real-time clock compensation scheme of the present application is also applicable.
[0069] This application introduces a higher-order quartic term on the basis of the traditional crystal fitting curve, and fits a more accurate crystal temperature frequency deviation curve by measuring five temperature points, which solves the problem of poor crystal compensation effect in low and high temperature environments and achieves high precision of real-time clock timing. Since the quartic temperature curve is steeper, it can better fit the temperature frequency curve of the low and high temperature sections, so the result obtained by using the quartic temperature compensation curve is more accurate.
[0070] In the prior art, the error of the compensated time signal can be controlled within the range of ±1ppm by using a quadratic curve or a cubic curve fitting method; the method in this application can reduce the error to within ±0.5ppm. In order to improve the applicability and convenience of the crystal compensation process, this application uses a frequency modulator to digitally compensate the oscillation frequency, which has the advantages of simple circuit implementation and convenient operation.
[0071] The applicant uses an integrated circuit to achieve high-precision compensation of the crystal, and the main protection point is the specific implementation method of the crystal quartic curve temperature compensation on the integrated circuit.
[0072] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0073] Reference Figure 4 , shows a schematic diagram of a real-time clock compensation device according to an embodiment of the present application, which may specifically 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, wherein:
[0074] The data acquisition module 41 is used to collect the pulse-per-second frequency values of the oscillating crystal of the real-time clock at a plurality of preset temperature values;
[0075] A curve determination module 42, for determining a fourth temperature compensation curve of the real-time clock according to the plurality of temperature values and corresponding second pulse frequency values, wherein the fourth temperature compensation curve is used to characterize a frequency error of the oscillating crystal caused by temperature;
[0076] A temperature acquisition module 43 is used to acquire temperature information of the oscillating crystal;
[0077] A deviation calculation module 44, used for calculating the frequency deviation value of the oscillation crystal according to the temperature information and the fourth temperature compensation curve;
[0078] The error compensation module 45 is used to compensate the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock.
[0079] In a possible implementation, the curve determination module 42 includes:
[0080] A fitting submodule, configured to perform four-time fitting using the temperature value and the corresponding pulse-per-second frequency value to obtain the four-time temperature compensation curve, wherein the four-time temperature compensation curve includes a plurality of curve parameter values;
[0081] The storage submodule is used to store the multiple curve parameter values in the register component of the terminal device.
[0082] In a possible implementation, the temperature acquisition module 43 includes:
[0083] The acquisition submodule is used to acquire the real-time temperature of the oscillation crystal by using a preset digital-to-analog converter at preset time intervals.
[0084] In a possible implementation, the error compensation module 45 includes:
[0085] A modification submodule, used to modify the count value of the frequency modulator corresponding to the oscillating crystal according to the frequency deviation value, so as to obtain the actual frequency value of the oscillating crystal after compensation;
[0086] A determination submodule is used to determine the time signal of the real-time clock according to the actual frequency value.
[0087] In a possible implementation, the error compensation module 45 further includes:
[0088] A pulse-per-second signal output submodule, used to divide the actual frequency value and output a pulse-per-second signal;
[0089] The timing error determination submodule is used to determine the timing error of the real-time clock according to the second pulse signal.
[0090] Deviation calculation module 44 Deviation calculation module 44 includes:
[0091] A reading submodule, used for acquiring a plurality of curve parameter values of the quartic temperature compensation curve from the register component;
[0092] The calculation submodule is used to substitute the multiple curve parameter values and the temperature information into the fourth temperature compensation curve for calculation to obtain the frequency deviation value of the oscillation crystal.
[0093] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment part.
[0094] Figure 5 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Figure 5 As shown, the terminal device 5 of this embodiment includes: at least one processor 50 ( Figure 5 Only one is shown in the figure) a processor, a memory 51, and a computer program 52 stored in the memory 51 and executable on the at least one processor 50, and when the processor 50 executes the computer program 52, the steps in any of the above-mentioned method embodiments are implemented.
[0095] The terminal device 5 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud terminal device. The terminal device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that Figure 5 It is only an example of the terminal device 5 and does not constitute a limitation on the terminal device 5. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0096] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0097] In some embodiments, the memory 51 may be an internal storage unit of the terminal device 5, such as a hard disk or memory of the terminal device 5. In other embodiments, the memory 51 may also be an external storage device of the terminal device 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped 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 to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program. The memory 51 may also be used to temporarily store data that has been output or is to be output.
[0098] The embodiment of the present application further provides an electric energy meter, which uses the real-time clock compensation method described in the above-mentioned various method embodiments to compensate for the error of the real-time clock caused by temperature change.
[0099] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0100] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0101] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0102] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0103] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0104] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0105] 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 units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0106] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application is described in detail with reference to the above-mentioned embodiments, a person skilled in the art should understand that the technical solutions described in the above-mentioned embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A real-time clock compensation method, characterized in that: The method is applied to a terminal device, and the method comprises: Collect the pulse-per-second frequency values of the oscillating crystal of the real-time clock at multiple preset temperature values; According to the multiple temperature values and the corresponding second pulse frequency values, a fourth temperature compensation curve of the real-time clock is determined, and the fourth temperature compensation curve is used to characterize the frequency error of the oscillation crystal caused by temperature, and the fourth temperature compensation curve is: Δf=σ0+β(T-T0) 2 +γ(T-T0) 3 +ζ(T-T0) 4 Among them, σ0 is the longitudinal deviation value of the vertex of the fourth temperature compensation curve, T0 is the temperature value of the vertex of the fourth temperature compensation curve, β is the coefficient of the quadratic term, γ is the coefficient of the cubic term, and ζ is the coefficient of the quartic term; Collecting temperature information of the oscillating crystal; Calculating the frequency deviation value of the oscillation crystal according to the temperature information and the fourth temperature compensation curve; Compensating the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock; Wherein, compensating the real-time clock according to the frequency deviation value includes: Modify the count value of the frequency modulator corresponding to the oscillating crystal according to the frequency deviation value to obtain the actual frequency value of the oscillating crystal after compensation; A time signal of the real-time clock is determined according to the actual frequency value.
2. The method according to claim 1, characterized in that Determining the fourth temperature compensation curve of the real-time clock according to the temperature value and the corresponding second pulse frequency value includes: Performing a fourth fitting using the temperature value and the corresponding second pulse frequency value to obtain the fourth temperature compensation curve, wherein the fourth temperature compensation curve includes a plurality of curve parameter values; The plurality of curve parameter values are stored in a register component of the terminal device.
3. The method according to any one of claims 1, characterized in that The collecting the temperature information of the oscillating crystal includes: At preset time intervals, a preset digital-to-analog converter is used to obtain the real-time temperature of the oscillating crystal.
4. The method according to any one of claims 1 to 3, characterized in that: After determining the time signal of the real-time clock according to the actual frequency value, the method further includes: Perform frequency division on the actual frequency value and output a second pulse signal; The time error of the real-time clock is determined according to the second pulse signal.
5. The method according to claim 2, characterized in that The calculating the frequency deviation value of the oscillating crystal according to the temperature information and the fourth temperature compensation curve comprises: Acquire multiple curve parameter values of the quartic temperature compensation curve from the register component; Substituting the multiple curve parameter values and the temperature information into the fourth temperature compensation curve for calculation, the frequency deviation value of the oscillation crystal is obtained.
6. A real-time clock compensation device, characterized in that: The device is applied to a terminal device, and the device includes: A data acquisition module, used for acquiring the pulse-per-second frequency value of the oscillating crystal of the real-time clock at a plurality of preset temperature values; The curve determination module is used to determine the fourth temperature compensation curve of the real-time clock according to the multiple temperature values and the corresponding second pulse frequency values. The fourth temperature compensation curve is used to characterize the frequency error of the oscillation crystal caused by temperature. The fourth temperature compensation curve is: Δf=σ0+β(T-T0) 2 +γ(T-T0) 3 +ζ(T-T0) 4 Among them, σ0 is the longitudinal deviation value of the vertex of the fourth temperature compensation curve, T0 is the temperature value of the vertex of the fourth temperature compensation curve, β is the coefficient of the quadratic term, γ is the coefficient of the cubic term, and ζ is the coefficient of the quartic term; A temperature acquisition module, used to acquire temperature information of the oscillating crystal; A deviation calculation module, used for calculating the frequency deviation value of the oscillation crystal according to the temperature information and the fourth temperature compensation curve; An error compensation module, used for compensating the real-time clock according to the frequency deviation value to obtain a time signal of the real-time clock; Wherein, the error compensation module comprises: A modification submodule, used to modify the count value of the frequency modulator corresponding to the oscillating crystal according to the frequency deviation value, so as to obtain the actual frequency value of the oscillating crystal after compensation; A determination submodule is used to determine the time signal of the real-time clock according to the actual frequency value.
7. An electric energy meter, characterized in that: The electric energy meter uses the real-time clock compensation method as described in any one of claims 1 to 5 to compensate for the error of the real-time clock caused by temperature change.
8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Real-time clock compensating device and method
CN103248358A
Temperature compensation method of crystal oscillator and system
CN113644908A