CN102176112A - Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit) - Google Patents
Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit) Download PDFInfo
- Publication number
- CN102176112A CN102176112A CN 201110044232 CN201110044232A CN102176112A CN 102176112 A CN102176112 A CN 102176112A CN 201110044232 CN201110044232 CN 201110044232 CN 201110044232 A CN201110044232 A CN 201110044232A CN 102176112 A CN102176112 A CN 102176112A
- Authority
- CN
- China
- Prior art keywords
- temperature
- value
- rtc
- frequency
- register
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Abstract
The invention discloses a method for achieving accurate clock timing by arranging an RTC (real time clock) in an MCU (micro control unit). The method comprises the following steps: (1) adjustment of a prescaler: setting the default value of the prescaler as (k-1) when a kHZ crystal oscillator is utilized, and generating one second pulse interruption when the counting of the prescaler is k; (2) adjustment of a clock calibration register: utilizing a temperature sensor to collect the external temperature in a fixed time window, looking for the value of frequency offset according to the temperature, calculating the number of the actual frequency offset PPM (percent per million), and calculating the value of the calibration register; (3) utilizing the temperature sensor to sample the temperature, measuring the frequency output at the corresponding temperature, calculating the frequency offset acc according to a reference frequency, fitting the k value of a function of the temperature and the frequency offset based on the large amount of data so as to a temperature-frequency offset table, and looking for the table to obtain the accurate frequency offset PPM value through software; and (4) writing the corresponding value to the prescaler register and calibration register of the RTC during the service program interruption of the RTC.
Description
Technical field
The present invention relates to the method that the built-in RTC of various single-phase, three-phases and multifunctional electric energy meter realizes the accurate timing of clock.
Background technology
At present traditional clock of power meter adopts the RTC mode of free band temperature compensation usually, uses this mode, needs other wiring topology, takies the MUC resource, and investment is big.And the built-in RTC of MUC has bigger advantage in performance and price, but produces frequency deviation because of it uses the easy temperature influence of external crystal, causes the error of the error of the built-in RTC of MCU much larger than the RTC of free band temperature compensation, thereby causes clock of power meter inaccurate.Therefore, how according to crystal oscillation characteristic and temperature relation, the pre-divider register of the built-in RTC of MCU and clock alignment register adjusted to reach clock output accurately seem particularly important.
Summary of the invention
The objective of the invention is: overcome the shortcoming of prior art, when the software school of a kind of RTC is provided, utilize external crystal-controlled oscillation and external temperature sensor, utilize certain algorithm to make the reliable and stable work of inner RTC.
For achieving the above object, the technical solution used in the present invention is: the built-in RTC of MCU realizes the method for the accurate timing of clock, may further comprise the steps:
(1) adjustment of pre-divider: under the situation of using the kHZ crystal oscillator, the pre-divider default value is k-1, and pre-divider count down to the k value and produces 1 pulse per second (PPS) interruption.Therefore, for pre-frequency counter, one of every adjustment " bit ", the corresponding error of adjusting is: 1/k*1000,000 ppm, this adjustment can be adjusted in 1 second and be come into force by software control.
(2) adjustment of clock alignment register: under the window, temperature sensor is gathered outside temperature at a fixed time, and the numerical evaluation of utilizing temperature to check in frequency deviation goes out actual frequency deviations PPM number, thereby calculates the value of calibration register.
(3) by the temperature sensor sampling temperature, and the frequency of measuring under relevant temperature is exported, calculate frequency deviation acc with reference frequency, k value by the function of these mass data match temperature and frequency deviation, thereby produce the table of a temperature and frequency deviation, software can obtain frequency deviation PPM value accurately by tabling look-up, and this function is as follows:
(4) in the middle of the RTC interrupt service routine, write corresponding value to pre-frequency division register of RTC and calibration register.
The invention has the beneficial effects as follows: obtain frequency deviation PPM accurately by external temperature sensor, can budget obtain the actual value that writes calibration register, accurately calibrate clock by this PPM.
Description of drawings
Below in conjunction with the drawings and specific embodiments the present invention is described in further detail.
Fig. 1 is the graph of a relation of crystal frequency deviation value of the present invention and temperature.
Embodiment
As shown in Figure 1, the present invention, the built-in RTC of MCU realize the method for the accurate timing of clock, may further comprise the steps:
(1) adjustment of pre-divider: under the situation of using the kHZ crystal oscillator, the pre-divider default value is k-1, and pre-divider count down to the k value and produces 1 pulse per second (PPS) interruption.Therefore, for pre-frequency counter, one of every adjustment " bit ", the corresponding error of adjusting is: 1/k*1000,000 ppm, this adjustment can be adjusted in 1 second and be come into force by software control;
(2) adjustment of clock alignment register: under the window, temperature sensor is gathered outside temperature at a fixed time, and the numerical evaluation of utilizing temperature to check in frequency deviation goes out actual frequency deviations PPM number, thereby calculates the value of calibration register;
(3) by the temperature sensor sampling temperature, and the frequency of measuring under relevant temperature is exported, calculate frequency deviation acc with reference frequency, k value by the function of these mass data match temperature and frequency deviation, thereby produce the table of a temperature and frequency deviation, software can obtain frequency deviation PPM value accurately by tabling look-up, and this function is as follows:
(4) in the middle of the RTC interrupt service routine, write corresponding value to pre-frequency division register of RTC and calibration register.
The technical solution used in the present invention, write initial value to pre-frequency division register of RTC and clock alignment register, by host computer to RTC to the time, read the value of RTC pre-divider under the data of collecting temperature sensor and the corresponding temperature, constitute a tables of data, adopt data processing to set up frequency deviation and mathematic model of temperature; Make relevant parameters as the temperature of this batch crystal oscillator and the tables of data of frequency deviation according to model; Handle as the upset of pulse per second (PPS) with a timer, be used for test from IO mouth output pulse per second (PPS), enter the value of timer interruption read-out counter simultaneously, this value is used for the average of the umber of pulse that strides across at set time window calculation RTC, be used to calculate the value that writes the timer pre-divider, reach pulse per second (PPS) output accurately;
Read the value of external temperature sensor at the set time window, utilization is tabled look-up to such an extent that method draws frequency deviation value, obtain actual frequency deviations value and pre-frequency division value by data computation (can obtain) by corresponding M CU databook, calculate the value of calibration register again according to the PPM of a quantity, the value of so pre-frequency division value and calibration register has all obtained, and writes corresponding value to pre-frequency division register of RTC and calibration register in the RTC interrupt service routine.
The invention has the beneficial effects as follows: obtain accurately frequency deviation PPM by external temperature sensor, can budget obtain the actual value that writes calibration register, accurate calibration clock by this PPM.
Claims (1)
1.MCU built-in RTC realizes the method for the accurate timing of clock, it is characterized in that, may further comprise the steps:
(1) adjustment of pre-divider: under the situation of using the kHZ crystal oscillator, the pre-divider default value is k-1, pre-divider count down to the k value and produces 1 pulse per second (PPS) interruption, for pre-frequency counter, one of every adjustment " bit ", the corresponding error of adjusting is: 1/k*1000,000 ppm, this adjustment can be adjusted in 1 second and be come into force by software control;
(2) adjustment of clock alignment register: under the window, temperature sensor is gathered outside temperature at a fixed time, and the numerical evaluation of utilizing temperature to check in frequency deviation goes out actual frequency deviations PPM number, thereby calculates the value of calibration register;
(3) by the temperature sensor sampling temperature, and the frequency of measuring under relevant temperature is exported, calculate frequency deviation acc with reference frequency, k value by the function of these mass data match temperature and frequency deviation, thereby produce the table of a temperature and frequency deviation, software can obtain frequency deviation PPM value accurately by tabling look-up, and this function is as follows:
(4) in the middle of the RTC interrupt service routine, write corresponding value to pre-frequency division register of RTC and calibration register.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 201110044232 CN102176112B (en) | 2010-11-29 | 2011-02-24 | Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit) |
Applications Claiming Priority (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201010563599 | 2010-11-29 | ||
CN201010563599.1 | 2010-11-29 | ||
CN 201110044232 CN102176112B (en) | 2010-11-29 | 2011-02-24 | Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit) |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102176112A true CN102176112A (en) | 2011-09-07 |
CN102176112B CN102176112B (en) | 2013-04-24 |
Family
ID=44519304
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN 201110044232 Active CN102176112B (en) | 2010-11-29 | 2011-02-24 | Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit) |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102176112B (en) |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102435975A (en) * | 2011-11-07 | 2012-05-02 | 中国电力科学研究院 | Intelligent cost control electric energy meter and clock calibration method |
CN102932084A (en) * | 2012-10-17 | 2013-02-13 | 航天科工深圳(集团)有限公司 | Sampling clock synchronizing method and system |
CN103176400A (en) * | 2013-01-14 | 2013-06-26 | 杭州海兴电力科技股份有限公司 | Intelligent ammeter clock calibration method |
CN104898474A (en) * | 2015-04-01 | 2015-09-09 | 华南理工大学 | MCU-based multichannel uniform servo pulse generation method |
US9362920B2 (en) | 2013-03-01 | 2016-06-07 | Huawei Technologies Co., Ltd. | Correction circuit and real-time clock circuit |
CN106556724A (en) * | 2015-09-28 | 2017-04-05 | 华立科技股份有限公司 | Ammeter and its clock correcting method |
CN107884608A (en) * | 2017-11-02 | 2018-04-06 | 钜泉光电科技(上海)股份有限公司 | A kind of electric energy meter control system and clock correction method |
CN110401499A (en) * | 2019-08-29 | 2019-11-01 | 杭州博联智能科技股份有限公司 | For Fast Frequency Offset calibration method, device, equipment and the medium of radio-frequency module |
CN110519356A (en) * | 2019-08-20 | 2019-11-29 | 杭州先锋电子技术股份有限公司 | A kind of calibration gas meter, flow meter reports the method and device of success rate |
CN112073264A (en) * | 2020-08-31 | 2020-12-11 | 新华三信息安全技术有限公司 | Protocol detection method, device and network equipment |
CN112737507A (en) * | 2021-02-01 | 2021-04-30 | 山东新港电子科技有限公司 | Method for realizing RTC high precision based on temperature sensor |
CN113009899A (en) * | 2019-12-20 | 2021-06-22 | 金卡智能集团股份有限公司 | RTC (real time clock) calibration method for high-precision timing of metering instrument |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
PL225691B1 (en) * | 2013-07-18 | 2017-05-31 | Zbigniew Bigaj | A way of measuring and recording temperatures as a function of time and a system for measuring and recording temperatures as a function of time |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1573354A (en) * | 2003-06-10 | 2005-02-02 | 日本电气株式会社 | Portable terminal and GPS time keeping method |
CN1909375A (en) * | 2005-08-03 | 2007-02-07 | 乐金电子(中国)研究开发中心有限公司 | Real-time clock device and current time compensating method |
CN101170349A (en) * | 2006-10-23 | 2008-04-30 | 大唐移动通信设备有限公司 | Real time clock calibration circuit |
-
2011
- 2011-02-24 CN CN 201110044232 patent/CN102176112B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1573354A (en) * | 2003-06-10 | 2005-02-02 | 日本电气株式会社 | Portable terminal and GPS time keeping method |
CN1909375A (en) * | 2005-08-03 | 2007-02-07 | 乐金电子(中国)研究开发中心有限公司 | Real-time clock device and current time compensating method |
CN101170349A (en) * | 2006-10-23 | 2008-04-30 | 大唐移动通信设备有限公司 | Real time clock calibration circuit |
Non-Patent Citations (2)
Title |
---|
《沈阳教育学院学报》 20050630 孙雪梅等 实时时钟芯片在单片机系统中的应用 132-134 第7卷, 第2期 * |
《电测与仪表》 20030831 李浩等 实时时钟芯片RTC4553原理及应用 38-41 第40卷, 第452期 * |
Cited By (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102435975A (en) * | 2011-11-07 | 2012-05-02 | 中国电力科学研究院 | Intelligent cost control electric energy meter and clock calibration method |
CN102932084A (en) * | 2012-10-17 | 2013-02-13 | 航天科工深圳(集团)有限公司 | Sampling clock synchronizing method and system |
CN102932084B (en) * | 2012-10-17 | 2015-11-11 | 航天科工深圳(集团)有限公司 | The method and system that sampling clock is synchronous |
CN103176400A (en) * | 2013-01-14 | 2013-06-26 | 杭州海兴电力科技股份有限公司 | Intelligent ammeter clock calibration method |
US9362920B2 (en) | 2013-03-01 | 2016-06-07 | Huawei Technologies Co., Ltd. | Correction circuit and real-time clock circuit |
CN104898474A (en) * | 2015-04-01 | 2015-09-09 | 华南理工大学 | MCU-based multichannel uniform servo pulse generation method |
CN104898474B (en) * | 2015-04-01 | 2017-12-01 | 华南理工大学 | A kind of Multichannel uniform servo pulse generation method based on MCU |
CN106556724B (en) * | 2015-09-28 | 2019-04-12 | 华立科技股份有限公司 | Ammeter clock correcting method |
CN106556724A (en) * | 2015-09-28 | 2017-04-05 | 华立科技股份有限公司 | Ammeter and its clock correcting method |
CN107884608A (en) * | 2017-11-02 | 2018-04-06 | 钜泉光电科技(上海)股份有限公司 | A kind of electric energy meter control system and clock correction method |
CN110519356A (en) * | 2019-08-20 | 2019-11-29 | 杭州先锋电子技术股份有限公司 | A kind of calibration gas meter, flow meter reports the method and device of success rate |
CN110519356B (en) * | 2019-08-20 | 2022-02-01 | 杭州先锋电子技术股份有限公司 | Method and device for calibrating reporting success rate of gas meter |
CN110401499A (en) * | 2019-08-29 | 2019-11-01 | 杭州博联智能科技股份有限公司 | For Fast Frequency Offset calibration method, device, equipment and the medium of radio-frequency module |
CN113009899A (en) * | 2019-12-20 | 2021-06-22 | 金卡智能集团股份有限公司 | RTC (real time clock) calibration method for high-precision timing of metering instrument |
CN113009899B (en) * | 2019-12-20 | 2023-05-16 | 金卡智能集团股份有限公司 | RTC clock calibration method for high-precision timing of metering instrument |
CN112073264A (en) * | 2020-08-31 | 2020-12-11 | 新华三信息安全技术有限公司 | Protocol detection method, device and network equipment |
CN112737507A (en) * | 2021-02-01 | 2021-04-30 | 山东新港电子科技有限公司 | Method for realizing RTC high precision based on temperature sensor |
Also Published As
Publication number | Publication date |
---|---|
CN102176112B (en) | 2013-04-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102176112B (en) | Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit) | |
CN105573106B (en) | To the amendment circuit and its method of RTC accuracy of timekeeping in a kind of intelligent electric meter | |
CN201886034U (en) | Flow velocity and rate measurement instrument | |
US10541696B2 (en) | Method of controlling electronic device and electronic device | |
CN103248356B (en) | A kind of counter and implementation method based on adopting phase-locked loop pulse interpolation technology | |
CN108063617A (en) | The clock frequency calibration method and system of a kind of low frequency RC oscillators | |
CN202256438U (en) | Hardware real time clock (RTC) error compensation system of intelligent electric energy meter | |
CN104937504B (en) | The punctual method of quartz watch high accuracy | |
CN110262210B (en) | Crystal oscillator time keeping method based on counter | |
CN104154987A (en) | Vibration wire type sensor reader measuring meter | |
CN102163040B (en) | Built-in hardware clock module with temperature compensation function | |
CN106933300A (en) | Real-time clock temperature drift correction circuit | |
CN200993665Y (en) | Small digitalized prase-comparing measuring device | |
CN203858351U (en) | High-precision detection device of magnetic resonance signal of cesium optical pump | |
CN205333219U (en) | Multichannel temperature measuring circuit based on quartz crystal temperature sensor | |
CN201191306Y (en) | High precision electrical energy meter adopting frequency tracking sampling circuit | |
CN101556325A (en) | Method for quickly verifying electric energy error | |
CN102882672A (en) | Method and device for calibrating dynamic token clock | |
CN202434049U (en) | Water meter data acquirer | |
CN204679550U (en) | Electric energy accurate measuring device under a kind of fluctuating load | |
CN205384320U (en) | Photoelectric detection means | |
CN104007320A (en) | Digital RLC tester | |
CN202393904U (en) | Error verifying device used for electric energy metering device | |
CN201387481Y (en) | Error detecting device for digital watt-hour meter | |
CN201397233Y (en) | Three-line pendulum oscillatory cycle measuring instrument |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C56 | Change in the name or address of the patentee | ||
CP03 | Change of name, title or address |
Address after: 226200 Jiangsu city of Nantong province Qidong Economic Development Zone No. 666 Lin Yang Lu Patentee after: JIANGSU LINYANG ENERGY CO., LTD. Address before: Qidong City, Jiangsu province 226200 Nantong City Lin Yang Lu No. 666 Patentee before: Jiangsu Linyang Electronics Co., Ltd. |