Method and system for time setting of an rtc device

By storing the production environment temperature and frequency tolerance, and combining this with the actual environment temperature, the technical problems of RTC equipment were solved, the clock accuracy of RTC equipment was improved, it can adapt to frequency changes at different time points, avoid the influence of parasitic capacitance, and ensure the time calibration accuracy of RTC equipment.

CN116719220BActive Publication Date: 2025-12-05HITACHI BUILDING TECH GUANGZHOU CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310714838.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-15
Publication Date
2025-12-05
Estimated Expiration
2043-06-15

AI Technical Summary

Technical Problem

The clock accuracy of existing RTC devices is affected by crystal oscillator manufacturing errors and temperature drift. Existing time calibration methods fail to effectively account for manufacturing errors, resulting in errors that do not match reality.

Method used

By storing the production environment temperature and the first frequency tolerance, and combining them with the actual environment temperature, the time calibration method of the RTC equipment is dynamically adjusted. By comparing a high-precision clock source and a counter, the influence of parasitic capacitance is reduced, and crystal oscillator aging is taken into account, so as to achieve accurate time calibration.

Benefits of technology

It improves the clock accuracy of RTC devices, avoids the effects of parasitic capacitance, adapts to frequency changes at different time points, and ensures accurate time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116719220B_ABST
    Figure CN116719220B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a RTC device time correction method and system, and relates to the technical field of real-time clock, which comprises the following steps: in response to a time correction request, calling the production environment temperature stored in the RTC device and the corresponding first frequency tolerance under the production environment temperature; obtaining the actual environment temperature at the time of the time correction request; determining the second frequency tolerance corresponding to the RTC device at present according to the actual environment temperature, the production environment temperature and the first frequency tolerance; and correcting the RTC device according to the second frequency tolerance. The embodiment of the present application corrects the RTC device in real time through the stored production environment temperature, the first frequency tolerance and the obtained current actual environment temperature, so as to improve the clock accuracy of the RTC device.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The embodiment of the present application relates to the technical field of real-time clock, in particular to an RTC device time correction method and system. BACKGROUND

[0002] Many existing electronic products have RTC (Real-time clock) function, and the electronic device with RTC function is referred to as RTC device. RTC is the basis of various functions of electronic products, and its accuracy is the key of electronic products. The accuracy of RTC often depends on the vibration frequency of the crystal oscillator itself. Due to the difference of the crystal oscillator, the accuracy of RTC often does not meet the actual application requirements.

[0003] The error of the clock crystal oscillator mainly occurs in the following aspects: one is the factory error, which is the deviation of the clock crystal oscillator at 25 DEG C ambient temperature when leaving factory, generally about ± 20PPM, and there is also ± 5PPM, but the price is also relatively high; two is temperature drift, the corresponding frequency change of the crystal oscillator with the change of working temperature.

[0004] The existing RTC device time correction is generally through the temperature compensation to correct the RTC device, and the factory error is rarely considered. Even if the factory error and the temperature drift are considered, the factory error is obtained by directly contacting the crystal oscillator pin of the RTC device to obtain the vibration frequency. In this process, the parasitic capacitance is introduced, so that the obtained factory error is inconsistent with the actual one. SUMMARY

[0005] In order to overcome the defects of the prior art, the purpose of the embodiment of the present application is to provide an RTC device time correction method and system, which can improve the clock accuracy of the RTC device.

[0006] To solve the above problems, the first aspect of the embodiment of the present application discloses an RTC device time correction method, comprising:

[0007] In response to the time correction request, the production environment temperature stored in the RTC device and the corresponding first frequency tolerance under the production environment temperature are called;

[0008] The actual environment temperature at the time of the time correction request is obtained;

[0009] The second frequency tolerance corresponding to the RTC device at present is determined according to the actual environment temperature, the production environment temperature and the first frequency tolerance;

[0010] The RTC device is time corrected according to the second frequency tolerance.

[0011] The second aspect of the embodiment of the present application discloses an RTC device time correction device, comprising:

[0012] a response unit, configured to, in response to a time correction request, call a production environment temperature stored in the RTC device and a first frequency tolerance corresponding to the production environment temperature;

[0013] an acquisition unit, configured to acquire an actual environment temperature at the time of the time correction request;

[0014] a determination unit, configured to determine a second frequency tolerance currently corresponding to the RTC device according to the actual environment temperature, the production environment temperature and the first frequency tolerance;

[0015] a time correction unit, configured to perform time correction on the RTC device according to the second frequency tolerance.

[0016] A third aspect of the embodiment of the present application discloses an electronic device, comprising a memory, a processor and a computer program stored in the memory and capable of running on the processor, and the processor implements the steps of the RTC device time correction method disclosed in the first aspect of the embodiment of the present application when executing the computer program.

[0017] A fourth aspect of the embodiment of the present application discloses a computer readable storage medium, which stores a computer program, wherein the computer program causes a computer to execute the steps of the RTC device time correction method disclosed in the first aspect of the embodiment of the present application.

[0018] A fifth aspect of the embodiment of the present application discloses a computer program product, which causes a computer to execute the steps of the RTC device time correction method disclosed in the first aspect of the embodiment of the present application when the computer program product runs on the computer.

[0019] A sixth aspect of the embodiment of the present application discloses an application publishing platform, which is used for publishing a computer program product, wherein the computer program product causes a computer to execute the steps of the RTC device time correction method disclosed in the first aspect of the embodiment of the present application when the computer program product runs on the computer.

[0020] A seventh aspect of the embodiment of the present application discloses an RTC device time correction system, comprising an RTC device, a production device and a processing device.

[0021] A clock output port of the RTC device is connected with a clock input port of the production device, the RTC device further communicates with the production device through a serial port, and the processing device communicates with the production device; and a high-precision clock source of the production device is in an environment maintained at a constant temperature.

[0022] The production device sends a check signal to the RTC device to make the RTC device open a timer of the RTC device and output a square wave signal according to the RTC crystal oscillator; a clock input port of the production device receives the square wave signal and opens a counter, and a timer of the high-precision clock source is also opened; when the counter reaches a preset value, a deviation value between the preset value and a value of the timer of the high-precision clock source is compared, and a first frequency tolerance of the RTC device during production is determined according to the deviation value; the production device further acquires a time stamp through the processing device, and sends an end instruction, the first frequency tolerance, factory information and the time stamp to the RTC device through a serial port; after receiving the end instruction, the RTC device stops checking and stores the first frequency tolerance, the factory information and the time stamp;

[0023] The RTC device further acquires and saves a production environment temperature during the checking process, or the production device acquires the production environment temperature during the checking process and sends the production environment temperature to the RTC device to make the RTC device save the production environment temperature;

[0024] When a time correction request is triggered, the RTC device calls the first frequency tolerance, the production environment temperature and an actual environment temperature when the time correction request is acquired, and corrects time according to the first frequency tolerance, the production environment temperature and the actual environment temperature.

[0025] Compared with the prior art, the embodiment of the present application has the following beneficial effects:

[0026] 1. The embodiment of the present application stores the production environment temperature, the first frequency tolerance and the current actual environment temperature to correct time of the RTC device in real time, thereby improving the clock accuracy of the RTC device;

[0027] 2. The embodiment of the present application determines the production error based on the comparison between the clock signal quantity of the RTC device and the timing time of the production device, thereby avoiding the influence of the parasitic capacitance and further improving the clock accuracy of the RTC device;

[0028] 3. The embodiment of the present application introduces the first frequency tolerance adjustment amount, considers the change of the vibration frequency of the RTC crystal oscillator during the aging process, thereby correcting time of the RTC device by using different first frequency tolerances at different time nodes, and further improves the clock accuracy of the RTC device;

[0029] 4. The embodiment of the present application can also correct time of the RTC device when the RTC device does not have a temperature detection function. BRIEF DESCRIPTION OF DRAWINGS

[0030] Figure 1is a schematic diagram of a parabolic coefficient curve of a quartz crystal of the prior art;

[0031] Figure 2 is a schematic diagram of a flow of an RTC device time correction method provided by an embodiment of the present application;

[0032] Figure 3 is a schematic diagram of a flow of another RTC device time correction method provided by an embodiment of the present application;

[0033] Figure 4 is a schematic diagram of a structure of an RTC device time correction system disclosed by an embodiment of the present application;

[0034] Figure 5 is a schematic diagram of a structure of an RTC device disclosed by an embodiment of the present application;

[0035] Figure 6 is a schematic diagram of a structure of a production device disclosed by an embodiment of the present application;

[0036] Figure 7 is a schematic diagram of a processing flow of an RTC device end in an RTC device verification process disclosed by an embodiment of the present application;

[0037] Figure 8 is a schematic diagram of a processing flow of a production device end in an RTC device verification process disclosed by an embodiment of the present application;

[0038] Figure 9 is a schematic diagram of a whole flow of a working process of an RTC device time correction system disclosed by an embodiment of the present application;

[0039] Figure 10 is a schematic diagram of a structure of an RTC device time correction device disclosed by an embodiment of the present application;

[0040] Figure 11 is a schematic diagram of a structure of an electronic device disclosed by an embodiment of the present application. DETAILED DESCRIPTION

[0041] The present detailed description is merely an explanation of the embodiments of the present application, and is not a limitation of the embodiments of the present application. Those skilled in the art can make modifications to the embodiments of the present application without creative contribution after reading the present description, and the modifications are protected by the patent law as long as they are within the scope of the claims of the embodiments of the present application.

[0042] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some but not all of the embodiments of the present application. Based on the embodiments in the embodiments of the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0043] The term "comprising" and any variation thereof when used in the specification and claims of the present application is intended to cover a non-exclusive inclusion, for example, a process, method, system, product or apparatus that includes a list of steps or units not necessarily limited to those explicitly listed, but can include other steps or units not explicitly listed or inherent to such processes, methods, products or apparatus.

[0044] In the embodiments of the present application, the word "exemplary" or "for example" is used to mean serving as an example, instance, or illustration. Any embodiment or design presented as "exemplary" or "for example" in the embodiments of the present application is not necessarily to be construed as preferred or advantageous over other embodiments or design solutions. Rather, use of the word "exemplary" or "for example" is intended to present concepts in a concrete manner.

[0045] The embodiments of the present application disclose an RTC device time correction method and system, a processing module with a processing function is a main body of the RTC device, the RTC device refers to an electronic device with an RTC function, in addition to the processing module and an RTC chip, the RTC device also has a storage module with a certain storage function, used for storing a production environment temperature and a first frequency tolerance. The storage module can also store factory information of the RTC device, a timestamp obtained when a clock of the RTC device is verified, and average temperature of a use area of the RTC device, for example, annual average temperature, quarterly average temperature or monthly average temperature. In addition, the RTC device also has a communication interface, for example, a serial port, for communicating with a production device, and a battery or a power supply interface for supplying power to the RTC device.

[0046] As an optional module, the RTC device can also have a temperature acquisition module with a temperature detection function, for example, a temperature sensor, used for acquiring an actual environment temperature of an environment where the RTC device is located, so that the RTC device is corrected based on the production environment temperature, the first frequency tolerance and the actual environment temperature.

[0047] RTC crystal oscillator, its error mainly appears in the following aspects: one is factory error, when factory, clock crystal oscillator in 25 DEG C ambient temperature deviation; two is temperature drift, the corresponding frequency change of crystal oscillator with working temperature change, temperature drift caused RTC crystal oscillator change can be characterized by the following formula:

[0048] f(t) = f0*[1-k*(t-t0)]

[0049] Wherein, f0 is the nominal frequency (RTC crystal oscillator frequency is generally 32.768 KHz), t0 is the standard temperature of 25 DEG C; K is the parabolic coefficient of quartz crystal (such as shown in Figure 1 , its typical value is 0.04 PPM / DEG C2), t is the ambient temperature.

[0050] In the prior art, the acquisition method of factory error is roughly divided into two kinds, one is that the production equipment directly contacts the RTC device crystal oscillator pin to obtain the vibration frequency, in this process, the parasitic capacitance is introduced, thereby causing the obtained factory error inconsistent with the actual value; The second is to determine the factory error of RTC device based on the above formula, this method has higher dependence on the nominal frequency f0, if the accuracy of nominal frequency f0 does not meet the expectation, then the obtained factory error will also be inconsistent with the actual value.

[0051] In the preferred embodiment of the present application, the crystal oscillator vibration frequency offset is used to calibrate the RTC device, thereby reducing the dependence on the nominal frequency f0, thereby ensuring the accuracy of the factory error.

[0052] Specifically, the present application first determines the difference between the RTC device and the standard RTC crystal oscillator in the production environment, determines the first frequency tolerance under the production environment temperature, so that the third frequency tolerance under the standard temperature can be determined according to the first frequency deviation:

[0053] ft0 = ft c +k*(t c -t0)

[0054] Wherein, ft0 is the third frequency tolerance, ft c is the first frequency tolerance, t c is the production environment temperature, t0 is the standard temperature.

[0055] Then determine the vibration frequency offset of the current RTC crystal oscillator based on the actual environment temperature in the calibration process, recorded as the second frequency tolerance:

[0056] ft n =ft0-k*(t n -t0)=ft c +k*(t c -tn )

[0057] wherein ft n is a second frequency tolerance, t n is an actual ambient temperature, t c is a production ambient temperature.

[0058] In the time of school, as long as the RTC device timer interrupt reaches a certain number, the RTC device timer interrupt number is compensated by the second frequency tolerance, the time of the RTC device can be completed, so as to get rid of the parasitic capacitance or the nominal frequency f0 accuracy does not meet the requirements of the factory error and the actual problem does not conform, the following will be described in detail in combination with the drawings.

[0059] Embodiment one

[0060] Please refer to Figure 2 , Figure 2 is a flowchart of an RTC device time setting method disclosed by an embodiment of the application. As Figure 2 shown, the RTC device time setting method comprises:

[0061] S110, in response to the time setting request, call the production ambient temperature stored in the RTC device, and the corresponding first frequency tolerance under the production ambient temperature.

[0062] The implementation mode of the time setting request is various, exemplarily, the automatic time setting function can be started at any time period in idle time (0:00-4:00) every day, or the time setting function can be started by manual mode, for example, the time setting is started by touch button or mechanical button.

[0063] The production ambient temperature stored in the RTC device and the corresponding first frequency tolerance under the production ambient temperature are determined when the RTC device is produced, the first frequency tolerance can be determined by the production device under the production environment, and the production ambient temperature can be determined by the temperature detection module of the production device or the RTC device itself or the independent temperature detection module independent of the production device or the RTC device.

[0064] Specifically, the process of determining the first frequency tolerance comprises the following steps:

[0065] The production device sends a check start instruction to the RTC device through a serial port. When the RTC device receives the check start instruction, a timer (referred to as a first timer) inside the RTC device is opened and set to N frequency division (for example, N = 4 or 5, etc.), and the RTC crystal oscillator is used as an input source to trigger the timing function of the first timer. When the first timer is triggered to perform the timing function, the output level of the clock output pin of the RTC device is reversed (initially, the output level of the clock output pin of the RTC device is high), so that the clock signal output by the clock output pin is a square wave signal. The clock input pin of the production device is electrically connected to the clock output pin of the RTC device. When the clock input pin of the production device obtains a low level, a counter is opened to count, and a timer (referred to as a second timer) derived from a high-precision crystal oscillator is also opened. When the count of the counter reaches a certain number, for example, when the first timer is set to 5 frequency division, the count of the counter can be an integer multiple of 1024, so that the count result of the counter and the time of the second timer are compared, and based on the comparison result, the first frequency tolerance is determined. The first frequency tolerance is based on the timing time of the second timer to determine whether the count result of the counter is consistent with the value corresponding to the timing time in theory.

[0066] For example, assuming that the first timer is set to 5 frequency division, and the standard vibration frequency of the RTC crystal oscillator is 32.768KHz, then it should theoretically generate 1024 interrupts per second. If the count of the counter is 1024, then the timing time of the second timer should be 1s. If there is a difference between the two, that is, when the count of the counter is 1024, but the timing time of the second timer is not 1s, then the first frequency tolerance is determined according to the difference.

[0067] In other embodiments, the timing time of the second timer can also be the end point, and the count value of the counter is counted to determine the first frequency tolerance.

[0068] In a preferred embodiment of the present application, the high-precision crystal oscillator of the production device is placed in an environment maintained at a constant temperature, which is a standard temperature, thereby ensuring the accuracy of the timing of the production device.

[0069] The above production device receives the clock signal of the RTC device, compares the clock information of the production device with the clock information of the RTC device, and determines the factory error, thereby avoiding the introduction of parasitic capacitance caused by the direct contact of the production device with the crystal oscillator of the RTC device, which does not conform to the actual factory error. It can also avoid excessive dependence on the standard vibration frequency of the RTC crystal oscillator. On the contrary, the first frequency tolerance obtained by the embodiment of the present application in the verification stage is the factory error determined by comprehensively considering the temperature drift and the low accuracy of the standard vibration frequency of the RTC crystal oscillator.

[0070] S120, the actual environment temperature when the time correction request is obtained.

[0071] The actual environment temperature where the RTC device is located when the time correction request is made can be determined by a temperature detection module carried by the RTC device itself, and in other embodiments, the local temperature determined when the RTC device is connected to the network can be used as the actual environment temperature.

[0072] S130, determining a second frequency tolerance corresponding to the RTC device according to the actual environment temperature, the production environment temperature, and the first frequency tolerance.

[0073] Through the above analysis, it can be known that the second frequency tolerance can be determined based on the actual environment temperature, the production environment temperature, and the first frequency tolerance, and the calculation formula is as follows:

[0074] ft n =ft c +k*(t c -t n )

[0075] Wherein, ft n is the second frequency tolerance, ft c is the first frequency tolerance, t n is the actual environment temperature, t c is the production environment temperature, and k is the parabolic coefficient of the quartz crystal.

[0076] S140, correcting the RTC device according to the second frequency tolerance.

[0077] Determine the current time time corresponding to the time correction request, and start a first count value and a second count value in the timer of the RTC device, wherein the initial values of the first count value and the second count value are 0; the first count value and the second count value are both incremented by 1 when the RTC device generates a timer interrupt, wherein the first count value is used to verify the second count value, and the second count value is used to increase the current time, that is, when the second count value is greater than or equal to the maximum value of the second count value, the number of seconds of the current time time is incremented by 1, and when the first count value reaches the maximum value of the first count value, the second count value is adjusted according to the second frequency tolerance.

[0078] Specifically, when the first count value reaches the maximum value of the first count value, the second count value is adjusted, and the first count value is reset to the initial value:

[0079]

[0080] Wherein, i' is the adjusted second count value, i is the actual value of the second count value when the first count value reaches the maximum value of the first count value, N is the maximum value of the first count value, is a set value, int() is a down rounding, and ftn is a second frequency tolerance.

[0081] The size of N is set as required, for example, N can be equal to 1000000, that is, when the first count value reaches 100000, the second count value is adjusted to obtain the adjusted i' = i-int(ft n ). Then the second count value is incremented by one according to the timer interrupt according to the adjusted i', it can be seen that the adjusted i' can be negative, and it can also be greater than the maximum value of the second count value, when i' is negative, it is incremented by one according to the timer interrupt, when the second count value is greater than the maximum value set for it, the seconds of the current time time are incremented by one, and the second count value is reset to the initial value.

[0082] The maximum value of the second count value is equal to the number of timer interrupts generated by the RTC device per second, assuming that the frequency division timer of the RTC crystal oscillator is set to 5 divisions, then when the RTC crystal oscillator (32768Hz, that is, 2 15 Hz) is unbiased, 1024 (2 15 / 2 5 ) timer interrupts are generated per second.

[0083] The significance of the above operation is that every N timer interrupts, the current time is automatically corrected once according to the current actual environment temperature, the production environment temperature and the second frequency tolerance, to compensate for the timing error caused by the second frequency tolerance. In actual use, the number of timer interrupts and the division number can be set as required.

[0084] Example two

[0085] Please refer to Figure 3 , Figure 3 is a flowchart of another RTC device time correction method disclosed by an embodiment of the present application. As shown in the figure, the RTC device time correction method comprises: Figure 3

[0086] S210, in response to a time correction request, calling the production environment temperature, the first frequency tolerance and the production time stored in the RTC device when the RTC is verified.

[0087] In the verification process of the RTC device, the time when the verification is recorded as the production time, or the factory date of the RTC device is taken as the production time. The production environment and the first frequency tolerance are obtained in the same way as in example one, which will not be repeated here.

[0088] ​The production time is determined mainly because the RTC crystal will age during the use of the RTC device, and the oscillation frequency of the aged RTC crystal will also attenuate. Therefore, in the preferred embodiment of the application, the attenuation curve of the oscillation frequency of the RTC crystal can be obtained through the aging test, and then the RTC crystal is supplemented.

[0089] Specifically, the first frequency tolerance adjustment curve can be obtained by obtaining the first frequency tolerance value at different time points through the accelerated aging test, and then the first frequency tolerance adjustment function is obtained through fitting:

[0090]

[0091] ft c ′(x) is the first frequency tolerance adjustment amount, ft c is the first frequency tolerance, a is the time difference coefficient, which can be determined through a fitting algorithm (for example, least squares fitting) during fitting, x is the time difference, that is, the difference between the actual time of the time correction and the production time, according to the needs, the time difference can be in units of months, quarters or years, j is the fitting number, and n is the maximum value of the fitting number, for example, n can be set to 5, and the larger the n is, the more accurate the fitting result is.

[0092] S220, obtaining the actual environment temperature at the time of the time correction request.

[0093] The actual environment temperature of the RTC device at the time of the time correction request can be determined by the temperature detection module carried by the RTC device itself, and in other embodiments, the local temperature determined when the RTC device is connected to the network can be used as the actual environment temperature.

[0094] S230, determining the second frequency tolerance corresponding to the RTC device at present according to the actual environment temperature, the production environment temperature and the first frequency tolerance adjustment amount.

[0095] Similar to the embodiment one, the second frequency tolerance corresponding to the RTC device at present can be determined based on the actual environment temperature, the production environment temperature and the first frequency tolerance adjustment amount, and the calculation formula is as follows:

[0096] ft n = ft c ′(x) + k * (t c -t n )

[0097] Wherein, ft n is the second frequency tolerance, ft c is the first frequency tolerance, t n is the actual environment temperature, and t cT is the production environment temperature, k is the parabolic coefficient of the quartz crystal.

[0098] S240, calibrating the RTC device according to the second frequency tolerance.

[0099] The crystal oscillator of the RTC device is calibrated and compensated according to the second frequency tolerance by using the similar method of embodiment one.

[0100] In other embodiments, the method can also be applied to the RTC device without a temperature detection module, and all the above-mentioned temperature values (including the actual environment temperature and the production environment temperature) can be set as 25℃, or the actual environment temperature is set as 25℃, and the production environment temperature is determined by the temperature detection module of the production device or an independent temperature detection module. In this RTC device, the clock accuracy of the electronic device can also be greatly improved.

[0101] In other embodiments, a temperature detection device can also be added to the production device or an independent temperature detection module is used to determine the production environment temperature. In the production factory information, a fixed value is written according to the annual average temperature of the use area (or the sales area) of the RTC device, and the fixed value is used to replace the actual environment temperature in the subsequent product calculation, or the above-mentioned fixed value can also be the average temperature of each quarter or each month. According to the real-time clock, the adjustment is performed according to the quarter or the month, so that the clock accuracy of the electronic device can be further improved.

[0102] Embodiment three

[0103] Please refer to Figure 4 , Figure 4 is a structure diagram of an RTC device calibration system disclosed by the embodiment of the present application. The RTC device calibration system, i.e. the system for calibrating the RTC device, is mainly used for obtaining the first frequency tolerance and other information, and writing the information into the storage module of the RTC device.

[0104] As shown in Figure 4 , the RTC device calibration system mainly includes an RTC device 310, a production device 320 and a processing device 330. The clock output port of the RTC device is connected with the clock input port of the production device, and the RTC device also communicates with the production device through a serial port. The processing device communicates with the production device.

[0105] The RTC device is connected with the production device by two groups of signals, namely, clock signal and communication signal. The clock signal is generated by the RTC device and received by the production device, and the communication signal can be a serial port, wireless (Bluetooth, etc.) signal, etc., which is used for direct information interaction between the portable product and the production device, and the production device writes the factory information and time information to the product. The factory information is generated by the processing device 330, and the time information is generated by the server. The processing device 330 can be constructed by using a production PC, etc.

[0106] Please refer to Figure 5 The RTC device 310 mainly includes a processing module 311, an RTC crystal oscillator 312, a temperature acquisition module 313, a communication module 314, a battery 315, and other functional modules 316. The other functional modules 316 can include a storage module and functional modules related to the functions of the RTC device, such as a GPS module for positioning function, etc.

[0107] The processing module 311 sends the clock signal to the production device according to the RTC crystal oscillator 312 in the verification process, and receives the first frequency tolerance information after the verification is completed, and saves these information in the storage module. The calculation and processing in the subsequent time setting process of the RTC device are completed by the processing module. The RTC crystal oscillator 312 is mainly used to provide an oscillation frequency. The temperature acquisition module 313 is mainly used to acquire the environmental temperature of the space where the product is located, i.e., the production environment temperature. The communication module 314 is used for communication with the production device. The communication module provides an interface connected with the production device, such as a serial port, etc. The interface of the corresponding communication module 324 of the production device is connected. In other embodiments, the RTC device can also communicate with the production device through a wireless manner. The battery 315 is used to maintain the normal operation of the crystal oscillator and the counter. Of course, it can also power the power-consuming modules such as the processing module, etc.

[0108] Please refer to Figure 6 The production device 320 can include a processor module 321, a high-precision clock source 322 and a matched constant-temperature maintaining device 323, a communication module 324, etc. The processor module 321 is used to run the main logic and calculation of the RTC device. The high-precision clock source 322 is installed in the matched constant-temperature maintaining device 323, and is used to provide an accurate clock standard. The communication module 324 is used for communication with the RTC device 310 and the processing device 330.

[0109] Please refer to Figures 7-9 The production device performs verification on the RTC device and acquires the first frequency tolerance, and the process includes the following steps:

[0110] The production device sends a verification signal to the RTC device, so that the RTC device opens the timer of the RTC device and outputs a square wave signal according to the RTC crystal oscillator.

[0111] When the RTC device receives the start instruction, the RTC device opens the timer through the processing module, sets the frequency division number as needed, for example, 5 frequency division, the input source is the RTC crystal oscillator, when the timer generates an interrupt, the timing is triggered, the processing module reverses the level of the clock output pin, when the clock output pin is initially set to high level, then the reversed clock output pin outputs low level, the timer generates an interrupt again, and the timing is triggered again, the processing module reverses the level of the clock output pin again, and outputs high level. Therefore, with the triggering of timing, the clock output pin outputs a square wave signal.

[0112] When the clock input pin of the production device receives the low level signal sent by the clock output pin, the processor module of the production device opens the counter, the input source is the clock input pin, and the timer derived from the high-precision crystal oscillator is also opened synchronously. When the count of the counter reaches the preset value, for example, 1024, the timing is stopped, the deviation value is calculated according to the timing time and the count value of the counter, and at the same time, the production device sends a time acquisition instruction to the processing device, the processing device acquires the time, and converts the current time stamp by operation and sends it to the production device. The production device also acquires the factory information of the RTC device from the processing device.

[0113] The processor module of the production device outputs an end instruction to the RTC device through the communication module, and sends the factory information, time stamp and first frequency tolerance and other information (for example, in some scenarios, the production environment temperature is collected by the production device and sent to the RTC device) to the RTC device. After receiving the end instruction, the RTC device stops sending the square wave signal to the production device, and acquires and stores the factory information, time stamp, first frequency tolerance, production environment temperature and other information in the storage module.

[0114] In some other embodiments, the RTC device can also calculate the frequency tolerance at 25℃ according to the production environment temperature and the first frequency tolerance, that is, the third frequency tolerance mentioned above.

[0115] When the time correction request is triggered, the RTC device calls the first frequency tolerance, the production environment temperature and the actual environment temperature when the time correction request is acquired, and corrects the time according to the first frequency tolerance, the production environment temperature and the actual environment temperature. For specific processes, please refer to embodiment one and embodiment two.

[0116] Embodiment four

[0117] Please refer to Figure 10 , Figure 10 is a structural schematic diagram of an RTC device time correction device disclosed by the embodiments of the present application. As shown in Figure 10 , the RTC device time correction device comprises:

[0118] The response unit 410 is configured to, in response to the time correction request, retrieve the production environment temperature stored in the RTC device and the first frequency tolerance corresponding to the production environment temperature;

[0119] The acquisition unit 420 is configured to acquire an actual environment temperature at the time of the time correction request.

[0120] The determination unit 430 is configured to determine a second frequency tolerance currently corresponding to the RTC device according to the actual environment temperature, the production environment temperature, and the first frequency tolerance.

[0121] The time correction unit 440 is configured to correct the RTC device according to the second frequency tolerance as an optional solution. The determination unit 430 can include:

[0122] The second frequency tolerance currently corresponding to the RTC device is calculated by using a formula:

[0123] ft n = ft c + k * (t c - t n )

[0124] wherein ft n is the second frequency tolerance, ft c is the first frequency tolerance, t n is the actual environment temperature, t c is the production environment temperature, and k is a parabolic coefficient of the quartz crystal.

[0125] As an optional solution, the production environment temperature and the first frequency tolerance can be determined by:

[0126] According to the RTC crystal oscillator output clock signal to the production device, so that the high-precision clock source is maintained at 25°C in the production device based on the clock signal to start timing, and the first frequency tolerance is determined according to the timing time and the number of clock signals.

[0127] The temperature when the RTC device sends the clock signal is recorded as the production environment temperature.

[0128] As an optional solution, in response to the time correction request, the production time stored in the RTC device can also be retrieved.

[0129] The determination unit 430 can also be implemented by:

[0130] Determine the current time corresponding to the time correction request, and determine the time difference according to the current time and the production time.

[0131] Determine the first frequency tolerance adjustment amount according to the time difference:

[0132]

[0133] wherein ft c is the first frequency tolerance adjustment, ft c is the first frequency tolerance, a is the time difference coefficient, x is the time difference, j is the fitting number, and n is the maximum value of the fitting number;

[0134] determining a second frequency tolerance currently corresponding to the RTC device according to the actual environment temperature, the production environment temperature, and the first frequency tolerance adjustment;

[0135] ft n = ft c ′(x) + k * (t c -t n )

[0136] wherein ft n is the second frequency tolerance, t n is the actual environment temperature, and t c is the production environment temperature.

[0137] As an optional solution, the time correction unit 440 can include:

[0138] determining a current time corresponding to the time correction request, starting a first count value and a second count value in a timer inside the RTC device, wherein initial values of the first count value and the second count value are 0; the first count value and the second count value are both increased by 1 when a timer interrupt is generated in the RTC device;

[0139] when the first count value reaches a maximum value of the first count value, adjusting the second count value and resetting the first count value to the initial value:

[0140]

[0141] wherein i′ is the adjusted second count value, i is an actual value of the second count value when the first count value reaches the maximum value of the first count value, N is the maximum value of the first count value, is a set value, int() is a floor function, ft n is the second frequency tolerance;

[0142] when the second count value is greater than or equal to a maximum value of the second count value, then the current time is increased by 1 and the first count value is reset to the initial value, and the maximum value of the second count value is equal to a number of timer interrupts generated per second by the RTC device.

[0143] As an optional solution, when the RTC device does not have a temperature detection function, a first fixed value is assigned to the actual environment temperature, or the first fixed value is assigned to both the actual environment temperature and the production environment temperature; or, a target area used by the RTC device is determined, and an average temperature of the target area is recorded in the RTC device as the actual environment temperature.

[0144] Embodiment Four

[0145] Please refer to Figure 11 , Figure 11 A structural diagram of an RTC device that can be used to implement embodiments of the present application is shown. As shown in Figure 11 the RTC device includes at least one processor 510, and a memory, such as a ROM (Read-Only Memory) 520, a RAM (Random Access Memory) 530, etc., which is communicatively connected to the at least one processor 510, wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 510 can perform various appropriate actions and processes according to the computer program stored in the ROM 520 or the computer program loaded from the storage unit 580 to the RAM 530. In the RAM 530, various programs and data required for operation of the RTC device can also be stored. The processor 510, the ROM 520, and the RAM 530 are connected to each other through a bus 540. An I / O (Input / Output) interface 550 is also connected to the bus 540.

[0146] A plurality of components in the RTC device are connected to the I / O interface 550, including: an input unit 560, such as a keyboard, a mouse, etc.; an output unit 570, such as various types of displays, speakers, etc.; a storage unit 580, such as a magnetic disk, an optical disk, etc.; and a communication unit 590, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 590 allows the RTC device to exchange information / data with other devices through a computer network, such as the Internet, or / and various telecommunications networks.

[0147] The processor 510 can be various general-purpose or / and special-purpose processing components with processing and computing capabilities. Some examples of the processor 510 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 510 performs one or more steps of the RTC device time correction method described in Embodiment One above.

[0148] In some embodiments, an RTC device time-setting method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 580. In some embodiments, parts or all of the computer program can be loaded onto or / and installed in the RTC device via, e.g., ROM 520 or / and communication unit 590. When the computer program is loaded onto RAM 530 and executed by processor 510, one or more steps of an RTC device time-setting method described above in Embodiment One can be performed. Alternatively, in other embodiments, processor 510 can be configured to perform an RTC device time-setting method by other any suitable means, e.g., by means of firmware.

[0149] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, specially designed application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0150] Computer programs used to implement embodiments of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor of the machine, implements the functions / acts specified in the flowcharts or / and block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.

[0151] In the context of embodiments of the application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0152] To provide for interaction with a user, the systems and techniques described here can be implemented on a RTC device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the RTC device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0153] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0154] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.

[0155] The RTC device time correction method and system disclosed in the present application are described in detail above, and the principles and implementation modes of the present application are described by applying specific examples. The above example is only used to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed, and the above description should not be understood as a limitation of the present application.

Claims

1. A method for time setting of an RTC device, characterized in that, The method comprises the following steps: In response to a time correction request, the production environment temperature stored in the RTC device is called, and a clock signal is output to a production device according to the RTC crystal oscillator, so that the production device with a high-precision clock source maintained at a constant temperature of 25 DEG C starts timing based on the clock signal, and a first frequency tolerance is determined according to the timing time and the number of clock signals; An actual environment temperature at the time of the time correction request is obtained; A second frequency tolerance corresponding to the RTC device at present is determined according to the actual environment temperature, the production environment temperature and the first frequency tolerance: ft n = ft c +k*(t c -t n ) where ft n is the second frequency tolerance, ft c is the first frequency tolerance, t n is the actual ambient temperature, t c is the production ambient temperature, k is the parabolic coefficient of the quartz crystal; The RTC device is time-corrected according to the second frequency tolerance.

2. The RTC device time-aligning method according to claim 1, wherein, The production environment temperature stored in the RTC device and the first frequency tolerance corresponding to the production environment temperature are determined when the RTC device is produced; The production environment temperature is determined, comprising: Receiving the temperature when the RTC device sends a clock signal, which is recorded as the production environment temperature.

3. The RTC device time-aligning method of claim 1, wherein, In response to the time correction request, the production time stored in the RTC device is also called; The second frequency tolerance corresponding to the RTC device at present is determined according to the actual environment temperature, the production environment temperature and the first frequency tolerance, comprising: A time difference is determined according to the current time corresponding to the time correction request and the production time; A first frequency tolerance adjustment amount is determined according to the time difference: wherein ft c ft c is the first frequency tolerance, a is the time difference coefficient, x is the time difference, j is the fitting number, and n is the maximum value of the fitting number. The second frequency tolerance corresponding to the RTC device at present is determined according to the actual environment temperature, the production environment temperature and the first frequency tolerance adjustment amount: ft n = ft c '(x) + k*(t c - t n ) where ft n is the second frequency tolerance, t n is the actual ambient temperature, t c is the production ambient temperature.

4. The RTC device time-aligning method according to any one of claims 1-3, wherein, The RTC device is time-corrected according to the second frequency tolerance, comprising: A current time corresponding to the time correction request is determined, and a first count value and a second count value are started in the timer of the RTC device, wherein the initial values of the first count value and the second count value are 0; the first count value and the second count value are both increased by 1 when the timer interrupt of the RTC device is generated; When the first count value reaches the maximum value of the first count value, the second count value is adjusted, and the first count value is reset to the initial value: where i' is the adjusted second count value, i is the actual value of the second count value when the first count value reaches the maximum value of the first count value, N is the maximum value of the first count value, is a set value, int() is a down-rounding function, and ft n is a second frequency tolerance; When the second count value is greater than or equal to the maximum value of the second count value, which is equal to the number of timer interrupts generated per second by the RTC device, the current time is increased by 1, and the second count value is reset to the initial value.

5. The RTC device time-aligning method according to any one of claims 1-3, wherein, When the RTC device does not have a temperature detection function, a first fixed value is assigned to the actual environment temperature, or the first fixed value is assigned to the actual environment temperature and the production environment temperature at the same time; Or, a target area used by the RTC device is determined, and the average temperature of the target area is recorded in the RTC device as the actual environment temperature.

6. An RTC device time setting apparatus, characterized by, The method comprises the following steps: A response unit is configured to, in response to a time correction request, call the production environment temperature stored in the RTC device, and output a clock signal to a production device according to the RTC crystal oscillator, so that the production device with a high-precision clock source maintained at a constant temperature of 25 DEG C starts timing based on the clock signal, and a first frequency tolerance is determined according to the timing time and the number of clock signals; An acquisition unit is configured to obtain an actual environment temperature at the time of the time correction request; The determining unit is configured to determine a second frequency tolerance currently corresponding to the RTC device according to the actual environment temperature, the production environment temperature, and the first frequency tolerance: ft n = ft c +k*(t c -t n ) where ft n is the second frequency tolerance, ft c is the first frequency tolerance, t n is the actual ambient temperature, t c is the production ambient temperature, k is the parabolic coefficient of the quartz crystal; The time correcting unit is configured to correct the RTC device according to the second frequency tolerance.

7. An RTC device, characterized by The computer program product comprises a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the steps of the RTC device time correcting method according to any one of claims 1-5 when executing the computer program.

8. A computer-readable storage medium, characterized in that, The computer program product comprises a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the steps of the RTC device time correcting method according to any one of claims 1-5 when executing the computer program.

9. An RTC device timekeeping system, characterized by, The computer program product comprises a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the steps of the RTC device time correcting method according to any one of claims 1-5 when executing the computer program. The RTC device, the production device, and the processing device; The clock output port of the RTC device is connected to the clock input port of the production device, the RTC device further communicates with the production device through a serial port, and the processing device communicates with the production device; the high-precision clock source of the production device is in a constant-temperature-maintained environment; The production device sends a verification signal to the RTC device, so that the RTC device opens a timer of the RTC device and outputs a square wave signal according to the RTC crystal oscillator; the clock input port of the production device receives the square wave signal and opens a counter, and simultaneously opens a timer of the high-precision clock source; when the counter reaches a preset value, a deviation value between the preset value and a timer value of the high-precision clock source is compared, and the first frequency tolerance of the RTC device during production is determined according to the deviation value; the production device further acquires a time stamp through the processing device, and sends an end instruction, the first frequency tolerance, factory information, and the time stamp to the RTC device through the serial port; after receiving the end instruction, the RTC device stops verification and stores the first frequency tolerance, the factory information, and the time stamp; The RTC device further acquires and saves the production environment temperature during the verification process, or the production device acquires the production environment temperature during the verification process and sends the production environment temperature to the RTC device, so that the RTC device saves the production environment temperature; When a time correcting request is triggered, the RTC device calls the first frequency tolerance, the production environment temperature, and an actual environment temperature when the time correcting request is acquired, and corrects the time according to the first frequency tolerance, the production environment temperature, and the actual environment temperature.

Citation Information

Patent Citations

  • Wide range temperature error compensating method of real-time clock and system thereof

    CN102163041A

  • Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit)

    CN102176112A