Method for improving RTC (real time clock) calibration precision based on time domain segmented interpolation compensation

文档序号:681569 发布日期:2021-04-30 浏览:28次 中文

阅读说明:本技术 一种基于时域分段插值补偿提高rtc校准精度的方法 (Method for improving RTC (real time clock) calibration precision based on time domain segmented interpolation compensation ) 是由 张晓东 杨国烨 华号 杨玉勇 陶英浩 钱晓明 张晨云 于 2020-12-07 设计创作,主要内容包括:本发明公开了一种基于时域分段插值补偿提高RTC校准精度的方法,包括数学建模、晶振校验、建立方程、方程求解、补偿值计算和时域分段插值补偿,时域分段插值补偿的方法如下:(1)以RTC芯片中能够写入到补偿寄存器的最小补偿步长作为基准补偿值;(2)设置一个预定长度的补偿时域周期,并将补偿时域周期分割为若干个时间分段;若干个时间分段由k1个正补偿时间分段、k2个负补偿时间分段和k3个零补偿时间分段所组成;(3)进行分段补偿:在每一个正补偿时间分段内,在补偿寄存器中增加一个基准补偿值;在每一个负补偿时间分段内,在补偿寄存器中减去一个基准补偿值;在每一个零补偿时间分段内,保持补偿寄存器中的值不变;本发明提高了RTC校准精度。(The invention discloses a method for improving RTC calibration precision based on time domain segmented interpolation compensation, which comprises mathematical modeling, crystal oscillator verification, equation establishment, equation solution, compensation value calculation and time domain segmented interpolation compensation, wherein the time domain segmented interpolation compensation method comprises the following steps: (1) taking the minimum compensation step length which can be written into a compensation register in the RTC chip as a reference compensation value; (2) setting a compensation time domain period with a preset length, and dividing the compensation time domain period into a plurality of time segments; the time segments consist of k1 positive compensation time segments, k2 negative compensation time segments and k3 zero compensation time segments; (3) and (3) carrying out sectional compensation: adding a reference compensation value in the compensation register in each positive compensation time segment; subtracting a reference compensation value from the compensation register in each negative compensation time segment; keeping the value in the compensation register unchanged in each zero compensation time segment; the invention improves the RTC calibration accuracy.)

1. A method for improving RTC calibration accuracy based on time domain segmented interpolation compensation is characterized by comprising the following steps:

step one, mathematical modeling: establishing an n-order curve mathematical model formula of the relation between the RTC crystal oscillator frequency error compensation value Ferr and the temperature T:

Ferr=Cn×Tn+Cn-1×Tn-1+Cn-2×Tn-2+…+C1×T+C0

wherein, Cn,Cn-1,Cn-2,…,C1,C0Compensating the undetermined coefficients for the error;

step two, crystal oscillator verification: acquiring Ferr check values of the RTC crystal oscillator at n +1 different temperature points through check equipment: ferr1,Ferr2,Ferr3,…Ferrn,Ferrn+1

Step three, establishing an equation: the sum of the Ferr check values obtained in the step twoSubstituting the corresponding temperature point data into the mathematical model of the n-times curve in the step one to form the undetermined coefficient C compensated by the errorn,Cn-1,Cn-2,…,C1,C0A (n +1) -ary system of equations of unknown numbers;

step four, solving an equation: solving the (n +1) -element linear equation set in the step three to obtain an error compensation undetermined coefficient Cn,Cn-1,Cn-2,…,C1,C0The actual value of (c); substituting the actual numerical value of the error compensation undetermined coefficient into the mathematical model formula in the first step;

step five, calculating a compensation value: carrying out temperature measurement for many times every minute, taking an average value, substituting the average value into a mathematical model formula, and calculating to obtain a frequency error compensation value Ferr;

step six, time domain segmented interpolation compensation: compensating the frequency error compensation value Ferr by a time domain segmented interpolation compensation method; the time domain segmented interpolation compensation method comprises the following steps:

(1) taking the ppm value of the minimum compensation step length which can be written into the compensation register in the RTC chip as a reference compensation value f;

(2) setting a compensation time domain period with a preset length, and dividing the compensation time domain period into a plurality of time segments, wherein the time duration of each time segment is t; the time segments are composed of k1 positive compensation time segments, k2 negative compensation time segments and k3 zero compensation time segments;

(3) and (3) carrying out sectional compensation: in each positive compensation time segment of the compensation time domain period, adding a reference compensation value f, namely + f, in a compensation register; subtracting a reference compensation value f, namely-f, from a compensation register in each negative compensation time segment of the compensation time domain period; in each zero compensation time segment of the compensation time domain period, keeping the value in the compensation register unchanged, namely + 0; by setting the appropriate k1, k2 and k3, the required frequency error compensation value Ferr within the compensation time domain period is achieved.

2. The method for improving the RTC calibration accuracy based on the time-domain piecewise interpolation compensation of claim 1, wherein n in the n-th order curve mathematical model is greater than or equal to 5.

3. The method of claim 1, wherein the time domain period of the compensation is 60s, and the duration of the time segment is 5 s.

4. The method of claim 3, wherein the starting point of compensation for each time segment in the compensated time domain period is 3s, 8s, 3s, 13s, 18s, 23s, 28s, 33s, 38s, 43s, 48s, 53s, and 58 s.

5. The method for improving the RTC calibration accuracy based on the time-domain segmented interpolation compensation of claim 4, wherein the minimum compensation step size which can be written into the compensation register in the RTC chip is 0.96ppm, which is converted into a compensation value of 0.08 s/day.

6. The method as claimed in claim 5, wherein the initial value of the daily timing error in the compensated time domain period is-0.04 s/day, and the accuracy compensation result of-0.02 s/day is achieved by setting the segment compensation method for each time segment from 3s to 58s in the compensated time domain period to + f, -f, +0, +0, + f, -f, +0, +0, + f, -f, +0, +0, +0.

7. The method as claimed in claim 5, wherein the initial value of the daily timing error in the compensation time domain period is-0.05 s/day, and the accuracy compensation result of-0.01 s/day is achieved by setting the segment compensation method for each time segment from 3s to 58s in the compensation time domain period to + f, +0, -f, +0, + f, +0, -f, +0, + f, +0, -f, +0.

8. The method as claimed in claim 5, wherein the initial value of the daily timing error in the compensated time domain period is +0.04s/day, and the accuracy compensation result of +0.02s/day is achieved by setting the segment compensation method for each time segment from 3s to 58s in the compensated time domain period to-f, + f, +0, +0, -f, + f, +0, + f, +0, -f, +0, +0.

9. The method of claim 5, wherein the initial value of the daily timing error in the compensation time domain period is +0.05s/day, and the accuracy compensation result of +0.01s/day is achieved by sequentially setting the segment compensation method for each time segment from 3s to 58s in the compensation time domain period to-f, +0, + f, +0, -f, +0.

10. The method of claim 5, wherein compensation starting points of the compensation time domain periods are staggered from each other according to different daily timing errors caused by temperature changes.

Technical Field

The invention relates to the technical field of real-time clock calibration, in particular to a method for improving RTC calibration precision based on time domain segmented interpolation compensation.

Background

With the further release of electricity selling business, the spot transaction will occupy the core position in the future electricity market. The intelligent electric energy meter is used as a basic unit in the whole power grid, the realization of spot transaction needs to carry out load analysis by collecting basic data of the intelligent electric energy meter, and the essence of the spot transaction is the division and calculation of the load in different time periods. This inevitably requires the smart electric energy meter to have an accurate real-time clock function. At present, common intelligent electric energy meters have a real-time clock function, and are required to meet the requirements of less than 1s/day (11.5ppm) in the working temperature range and less than 0.5s/day (5.75ppm) at 23 ℃ according to the industry standard.

According to the requirement of industry standard, for example, 0.5s/day, if the time is deviated by 15 seconds after one month, the inaccuracy of time inevitably affects the fairness of the transaction from the point of view of the spot transaction. Therefore, the precision requirement of the real-time clock is inevitably higher and higher in the future, and the higher precision requirement is also put forward in laboratory detection in some countries, and the highest requirement is 0.02s/day at present. However, some of the host controllers currently in use have RTCs built in, such as R7F0C004 of rassa electronics, with a minimum compensation resolution of ((1/32768) × 1/32) seconds, i.e., actually inserting several clocks every 32 seconds; turn "((1/32768) × 1/32)" to ppm units, then the step size of the compensation is: (1/2^20) ((10 ^6), about 0.96ppm, that is to say every written value offsets 0.08s/day, which is far from the accuracy requirement of 0.02 s/day.

At present, the intelligent electric energy meter industry adopts a mode that a master control chip is provided with an RTC (real time clock) as a clock, the accuracy of the clock completely depends on the consistency of a curve of an external 32.768kHz crystal oscillator and the calibration of the curve, the temperature and frequency deviation curve of the 32.768kHz crystal oscillator is shown in figure 1, and a common crystal oscillatorThe vibration handbook recommends a formula Ferr ═ B (T-T0) which is close to a 2-time curve2. Such as crystal oscillator of type VT-200-F, conventionally used in japan, B ═ 0.035ppm/(° c) and T0 ═ 25 ℃. The general method adopts the integral deviation degree of a single-point calibration curve, and a compensation formula Ferr ═ B (T-T0)2And + K, K is the crystal oscillation compensation value at the temperature of T0. At high temperatures, e.g. greater than 50 ℃, the compensation formula becomes Ferr ═ (B + M1) × (T-T0)2+ K, M1 is the correction value of B at high temperature, and at low temperature, for example, less than-15 deg.C, the compensation formula becomes Ferr ═ (B + M2) × (T-T0)2+ K, M2 is a correction value for the B value at high temperature. At different temperature points, different coefficients are adopted to realize calibration, and since the coefficients are values of a certain temperature point, for example, M1 is an offset value at 50 ℃, if the temperature becomes 55 ℃, calibration accuracy is inevitably lost due to the characteristics of a quadratic curve (depending on whether T0 is accurate), and calibration accuracy is also lost if measurement errors occur when the temperature is measured, and the error accuracy which we hope to obtain is 0.08s/day in many times but the actual calibration accuracy is 0.16 s/day.

Disclosure of Invention

The invention aims to realize high-precision calibration of a real-time clock by a time domain segmentation interpolation-based compensation method on the basis of not increasing hardware cost, and the highest characteristic detection requirement of 0.02s/day is met so as to meet the requirement of clock precision. The specific technical scheme is as follows:

a method for improving RTC calibration accuracy based on time domain segmented interpolation compensation comprises the following steps:

step one, mathematical modeling: establishing an n-order curve mathematical model formula of the relation between the RTC crystal oscillator frequency error compensation value Ferr and the temperature T:

Ferr=Cn×Tn+Cn-1×Tn-1+Cn-2×Tn-2+…+C1×T+C0

wherein, Cn,Cn-1,Cn-2,…,C1,C0Compensating the undetermined coefficients for the error;

step two, crystal oscillator verification: acquiring Ferr check values of the RTC crystal oscillator at n +1 different temperature points through check equipment: ferr1,Ferr2,Ferr3,…Ferrn,Ferrn+1

Step three, establishing an equation: substituting the Ferr check value obtained in the step two and the corresponding temperature point data into the mathematical model of the curve for n times in the step one to form the undetermined coefficient C compensated by the errorn,Cn-1,Cn-2,…,C1,C0A (n +1) -ary system of equations of unknown numbers;

step four, solving an equation: solving the (n +1) -element linear equation set in the step three to obtain an error compensation undetermined coefficient Cn,Cn-1,Cn-2,…,C1,C0The actual value of (c); substituting the actual numerical value of the error compensation undetermined coefficient into the mathematical model formula in the first step;

step five, calculating a compensation value: carrying out temperature measurement for many times every minute, taking an average value, substituting the average value into a mathematical model formula, and calculating to obtain a frequency error compensation value Ferr;

step six, time domain segmented interpolation compensation: compensating the frequency error compensation value Ferr by a time domain segmented interpolation compensation method; the time domain segmented interpolation compensation method comprises the following steps:

(1) taking the ppm value of the minimum compensation step length which can be written into the compensation register in the RTC chip as a reference compensation value f;

(2) setting a compensation time domain period with a preset length, and dividing the compensation time domain period into a plurality of time segments, wherein the time duration of each time segment is t; the time segments are composed of k1 positive compensation time segments, k2 negative compensation time segments and k3 zero compensation time segments;

(3) and (3) carrying out sectional compensation: in each positive compensation time segment of the compensation time domain period, adding a reference compensation value f, namely + f, in a compensation register; subtracting a reference compensation value f, namely-f, from a compensation register in each negative compensation time segment of the compensation time domain period; in each zero compensation time segment of the compensation time domain period, keeping the value in the compensation register unchanged, namely + 0; by setting the appropriate k1, k2 and k3, the required frequency error compensation value Ferr within the compensation time domain period is achieved.

Preferably, n in the mathematical model of the n-degree curve is more than or equal to 5.

More preferably, n is greater than or equal to 5 in the mathematical model of the n-degree curve.

As a preferred scheme of the time domain period compensation in the present invention, the time domain period compensation is 60s, and the time duration of the time segment is 5 s. (remarks: where s is the time unit second, the same applies hereinafter)

The compensation starting points of the time segments in the compensation time domain period are respectively the 3 rd, 8 th, 3 rd, 13 th, 18 th, 23 th, 28 th, 33 th, 38 th, 43 th, 48 th, 53 th and 58 th.

The minimum compensation step length which can be written into the compensation register in the RTC chip is 0.96ppm, and the minimum compensation step length is converted into a compensation value of 0.08 s/day.

When the initial value of the daily timing error in the compensation time domain period is-0.04 s/day, the precision compensation result of-0.02 s/day is realized by setting the segmental compensation method of each time segment from the 3 rd to the 58 th time segment in the compensation time domain period to + f, -f, +0, +0, + f, -f, +0, +0, + f, -f, +0, +0, +0.

When the initial value of the daily timing error in the compensation time domain period is-0.05 s/day, the precision compensation result of-0.01 s/day is realized by setting the segmented compensation method of each time segment from the 3 rd to the 58 th in the compensation time domain period to + f, +0, -f, +0, + f, +0, -f, +0, + f, +0, -f, +0 in sequence.

When the initial value of the daily timing error in the compensation time domain period is +0.04s/day, the precision compensation result of +0.02s/day is realized by setting the subsection compensation method of each time subsection from the 3 rd to the 58 th in the compensation time domain period to-f, + f, +0, + f, +0, +0.

When the initial value of the daily timing error in the compensation time domain period is +0.05s/day, the precision compensation result of +0.01s/day is realized by sequentially setting the subsection compensation method of each time subsection from the 3 rd to the 58 th in the compensation time domain period to-f, +0, + f, +0, -f, +0, + f, +0.

Wherein the reference compensation value f is 0.08 s/day.

Considering that the temperature measurement has a certain error, which may have a 0.01 deviation, it is preferable that the compensation starting points of the compensation time domain periods are arranged to be staggered with each other according to different daily timing errors caused by temperature changes, so as to minimize the influence of temperature.

The invention has the beneficial effects that:

firstly, the method for improving RTC calibration accuracy based on time domain segmented interpolation compensation of the invention realizes the high-accuracy calibration of a real-time clock by a time domain segmented interpolation compensation based on the time domain segmented interpolation compensation method without increasing hardware cost, and reaches the highest characteristic detection requirement of 0.02s/day so as to meet the requirement of clock accuracy. By the method, the precision of the daily timing is greatly improved, so that the clock precision is also improved, and fairness is provided for accurate spot transaction.

Secondly, the method for improving the RTC calibration accuracy based on the time domain segmented interpolation compensation establishes a high-order curve mathematical model formula of the relationship between the RTC crystal oscillator frequency error compensation value Ferr corrected by the calibration equipment and the temperature T, and has higher accuracy compared with the traditional Ferr calculation formula.

Drawings

FIG. 1 is a schematic diagram of an implementation of the method for improving RTC calibration accuracy based on time domain piecewise interpolation compensation according to the present invention;

fig. 2 is a temperature and frequency deviation curve of a crystal oscillator.

Detailed Description

The following description of the embodiments of the present invention will be made with reference to the accompanying drawings. The following examples are only for illustrating the technical solutions of the present invention more clearly, and the protection scope of the present invention is not limited thereby.

Example 1:

fig. 1 to 2 show an embodiment of a method for improving RTC calibration accuracy based on time-domain segmented interpolation compensation according to the present invention, which includes the following steps:

step one, mathematical modeling: establishing an n-order curve mathematical model formula of the relation between the RTC crystal oscillator frequency error compensation value Ferr and the temperature T:

Ferr=Cn×Tn+Cn-1×Tn-1+Cn-2×Tn-2+…+C1×T+C0

wherein, Cn,Cn-1,Cn-2,…,C1,C0Compensating the undetermined coefficients for the error;

step two, crystal oscillator verification: acquiring Ferr check values of the RTC crystal oscillator at n +1 different temperature points through check equipment: ferr1,Ferr2,Ferr3,…Ferrn,Ferrn+1

Step three, establishing an equation: substituting the Ferr check value obtained in the step two and the corresponding temperature point data into the mathematical model of the curve for n times in the step one to form the undetermined coefficient C compensated by the errorn,Cn-1,Cn-2,…,C1,C0A (n +1) -ary system of equations of unknown numbers;

step four, solving an equation: solving the (n +1) -element linear equation set in the step three to obtain an error compensation undetermined coefficient Cn,Cn-1,Cn-2,…,C1,C0The actual value of (c); substituting the actual numerical value of the error compensation undetermined coefficient into the mathematical model formula in the first step;

step five, calculating a compensation value: carrying out temperature measurement for many times every minute, taking an average value, substituting the average value into a mathematical model formula, and calculating to obtain a frequency error compensation value Ferr;

step six, time domain segmented interpolation compensation: compensating the frequency error compensation value Ferr by a time domain segmented interpolation compensation method; the time domain segmented interpolation compensation method comprises the following steps:

(1) taking the ppm value of the minimum compensation step length which can be written into the compensation register in the RTC chip as a reference compensation value f;

(2) setting a compensation time domain period with a preset length, and dividing the compensation time domain period into a plurality of time segments, wherein the time duration of each time segment is t; the time segments are composed of k1 positive compensation time segments, k2 negative compensation time segments and k3 zero compensation time segments;

(3) and (3) carrying out sectional compensation: in each positive compensation time segment of the compensation time domain period, adding a reference compensation value f, namely + f, in a compensation register; subtracting a reference compensation value f, namely-f, from a compensation register in each negative compensation time segment of the compensation time domain period; in each zero compensation time segment of the compensation time domain period, keeping the value in the compensation register unchanged, namely + 0; by setting the appropriate k1, k2 and k3, the required frequency error compensation value Ferr within the compensation time domain period is achieved.

Preferably, n in the mathematical model of the n-degree curve is more than or equal to 5.

More preferably, n is greater than or equal to 5 in the mathematical model of the n-degree curve.

As a preferred scheme of the time domain period compensation in the present invention, the time domain period compensation is 60s, and the time duration of the time segment is 5 s. (remarks: where s is the time unit second, the same applies hereinafter)

The compensation starting points of the time segments in the compensation time domain period are respectively the 3 rd, 8 th, 3 rd, 13 th, 18 th, 23 th, 28 th, 33 th, 38 th, 43 th, 48 th, 53 th and 58 th.

The minimum compensation step length which can be written into the compensation register in the RTC chip is 0.96ppm, and the minimum compensation step length is converted into a compensation value of 0.08 s/day.

When the initial value of the daily timing error in the compensation time domain period is-0.04 s/day, the precision compensation result of-0.02 s/day is realized by setting the segmental compensation method of each time segment from the 3 rd to the 58 th time segment in the compensation time domain period to + f, -f, +0, +0, + f, -f, +0, +0, + f, -f, +0, +0, +0.

When the initial value of the daily timing error in the compensation time domain period is-0.05 s/day, the precision compensation result of-0.01 s/day is realized by setting the segmented compensation method of each time segment from the 3 rd to the 58 th in the compensation time domain period to + f, +0, -f, +0, + f, +0, -f, +0, + f, +0, -f, +0 in sequence.

When the initial value of the daily timing error in the compensation time domain period is +0.04s/day, the precision compensation result of +0.02s/day is realized by setting the subsection compensation method of each time subsection from the 3 rd to the 58 th in the compensation time domain period to-f, + f, +0, + f, +0, +0.

When the initial value of the daily timing error in the compensation time domain period is +0.05s/day, the precision compensation result of +0.01s/day is realized by sequentially setting the subsection compensation method of each time subsection from the 3 rd to the 58 th in the compensation time domain period to-f, +0, + f, +0, -f, +0, + f, +0.

Wherein the reference compensation value f is 0.08 s/day.

Considering that the temperature measurement has a certain error, which may have a 0.01 deviation, it is preferable that the compensation starting points of the compensation time domain periods are arranged to be staggered with each other according to different daily timing errors caused by temperature changes, so as to minimize the influence of temperature.

Example 2:

the embodiment is used for establishing a cubic curve mathematical model formula of the relationship between the frequency error compensation value Ferr and the temperature T of the RTC crystal oscillator, and performing RTC correction compensation according to the mathematical model formula, and the method can be independent of the inherent B value and the T0 value of the crystal oscillator, namely, the measurement error of the temperature can be eliminated in the calibration.

After a compensation value is obtained according to the mathematical model formula, the value needs to be written into a register of a chip, the chip performs corresponding frequency compensation according to the value, but the compensation step length of a plurality of chips is large and reaches 0.96PPM (PPM), namely 0.08s/day, and when the compensation step length is increased to 0.24PPM, namely 0.02s/day, the calibration precision can be further increased by using an interpolation algorithm.

The method comprises the following specific steps:

1. establishing a mathematical model of a multiple curve:

Ferr=Cn×Tn+Cn-1×Tn-1+Cn-2×Tn-2+…+C1×T+C0

2. according to the model, if a complete curve is required, only the compensation values required by (n +1) temperature points need to be known, and the more power the curve is known according to the principle of the least square method, the more accurate the final result value is.

3. Assuming that curve compensation is performed four times, compensation values of 5 temperature points are required to be obtained, wherein the 5 points can be selected from-25 ℃, 0 ℃, 25 ℃, 45 ℃ and 65 ℃, and the overall formula is as follows:

Ferr1=C4×(-25)4+C3×(-25)3+C2×(-25)2+C1×(-25)+C0

Ferr2=C0

Ferr3=C4×(25)4+C3×(25)3+C2×(25)3+C1×(25)+C0

Ferr3=C4×(45)4+C3×(45)3+C2×(45)3+C1×(45)+C0

Ferr3=C4×(65)4+C3×(65)3+C2×(65)3+C1×(65)+C0

wherein, Ferr1, Ferr2, Ferr3, Ferr4 and Ferr5 are register values written into the chip by converting daily timing errors obtained by the checking equipment. C can be calculated by the above formula4,C3,C3,C1,C0

And during calculation of the compensation value, measuring the temperature for many times every minute, taking an average value, substituting into a curve formula, calculating the Ferr, and writing the Ferr into a register of the chip. Therefore, accurate compensation in the whole temperature range can be realized.

4. Through the calibration, because the step length is 0.08s/day, the final calibration resolution is ± 0.04s/day, if the calibration needs to be improved, 60 seconds are used as a time period, and if the daily timing error needs to be calibrated to be within ± 0.02s/day, interpolation compensation needs to be performed in the time domain, and the specific algorithm is as follows: we use 5s as a time division point, and choose to start from 03 seconds to avoid the more specific time point of 00 seconds, as shown in the following table:

the foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the technical principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:以24小时为周期的按时段显示小时数字的计时显示界面、钟表、电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!