JP2003270369A - Time correction method and time correction device for real time clock - Google Patents

Time correction method and time correction device for real time clock

Info

Publication number
JP2003270369A
JP2003270369A JP2002077722A JP2002077722A JP2003270369A JP 2003270369 A JP2003270369 A JP 2003270369A JP 2002077722 A JP2002077722 A JP 2002077722A JP 2002077722 A JP2002077722 A JP 2002077722A JP 2003270369 A JP2003270369 A JP 2003270369A
Authority
JP
Japan
Prior art keywords
time
real
clock
time clock
vibration source
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2002077722A
Other languages
Japanese (ja)
Inventor
Seita Nashimoto
清太 梨本
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Azbil Corp
Original Assignee
Azbil Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Azbil Corp filed Critical Azbil Corp
Priority to JP2002077722A priority Critical patent/JP2003270369A/en
Publication of JP2003270369A publication Critical patent/JP2003270369A/en
Pending legal-status Critical Current

Links

Landscapes

  • Electric Clocks (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a highly precise real time clock at a low cost. <P>SOLUTION: This real time clock RTC 2 with an error correction function forms a real time clock. An AT quartz resonator 3 is provided with a flatter temperature characteristic in comparison with a tuning fork type quartz resonator 1 within a usage temperature range. A counter 4 counts a reference clock, which inputs only oscillations of the AT quartz resonator 3 in an initial time, as a source of time counting. A memory 5 stores a count value. In an actual use time, the counter 4 counts oscillations of the AT quartz resonator 3 as a source of time counting for the real time clock. A CPU 6 computes a correction value minimizing an error of the real time clock from a differential between the count value of the actual use time and the count value of the memory 5 to set it to the real time clock RTC 2. <P>COPYRIGHT: (C)2003,JPO

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、時計機能が必要な
機器において時刻を刻むリアルタイムクロックの時刻補
正方法及び時刻補正装置に関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a time correction method and a time correction device for a real-time clock that keeps time in a device that requires a clock function.

【0002】[0002]

【従来の技術】従来、時刻と密接な関係を持たせて動作
させる必要がある装置ではリアルタイムクロック(以
下、RTCと略する)回路により計時を行っている。R
TC回路の時刻補償には以下のような方式がある。 (A)RTCの時刻カウントの元になる水晶振動子の負
荷容量を1台ずつトリミングし、時計の誤差を許容範囲
内に調整する。 (B)商用電源の周波数を基準として定期的にRTCの
時刻を補正する。 (C)FM放送等の時報を受信し、時報を基準としてR
TCの時刻を補正する。 (D)RTCとは別に高精度の水晶発振器を搭載し、こ
の水晶発振器の周波数を基準として定期的にRTCの時
刻を補正する。 (E)誤差補正機能付きRTCを利用して、工場出荷時
に外部からの基準クロックを基に補正値を算出、以降自
動的に時刻補償を行う。
2. Description of the Related Art Conventionally, in a device that needs to be operated in close relation to time, a real-time clock (hereinafter abbreviated as RTC) circuit is used for clocking. R
There are the following methods for time compensation of the TC circuit. (A) The load capacitance of the crystal unit, which is the source of the RTC time count, is trimmed one by one, and the error of the clock is adjusted within the allowable range. (B) The RTC time is periodically corrected based on the frequency of the commercial power source. (C) Receives time signal such as FM broadcast, and R
Correct the time of TC. (D) A high-precision crystal oscillator is mounted separately from the RTC, and the time of the RTC is regularly corrected based on the frequency of the crystal oscillator. (E) Using the RTC with error correction function, a correction value is calculated based on a reference clock from the outside at the time of factory shipment, and time compensation is automatically performed thereafter.

【0003】[0003]

【発明が解決しようとする課題】しかしながら、従来の
技術(1)では、1台ずつ人の手で調整する必要がある
ため、製造工程の工数とコストが増大するという問題点
があった。従来の技術(2)では、商用電源の周波数を
検出するための回路が必要となるため、回路規模が増大
し、コストが高くなるという問題点があった。また、電
源周波数が安定していない地域では利用できないという
問題点があった。従来の技術(3)では、装置毎にFM
チューナーが必要になるという問題点があった。そし
て、従来の技術(4)では、高価格の高精度水晶発振器
が必要となるため、コストが高くなるという問題点があ
った。
However, the conventional technique (1) has a problem that man-hours and cost of the manufacturing process increase because it is necessary to manually adjust each one. In the conventional technique (2), a circuit for detecting the frequency of the commercial power source is required, so that there is a problem that the circuit scale increases and the cost increases. In addition, there is a problem that it cannot be used in areas where the power supply frequency is not stable. In the conventional technology (3), FM is used for each device.
There was a problem that a tuner was needed. The conventional technique (4) requires a high-priced high-precision crystal oscillator, which causes a problem of high cost.

【0004】一方、従来の技術(5)では、時刻補償を
安価に実現できる。しかし、一般的に誤差補正機能付き
RTCに組み合わせて使用できる音叉型の低周波水晶振
動子は、電子機器の使用温度範囲(例えば0〜40℃)
内での温度偏差が大きいため、補正後のRTCの誤差は
1日あたり2秒程度が限界で、高精度の時刻補償を実現
できないという問題点があった。
On the other hand, in the prior art (5), time compensation can be realized at low cost. However, a tuning-fork type low-frequency crystal unit that can be used in combination with an RTC with an error correction function is generally used in the operating temperature range of electronic devices (for example, 0 to 40 ° C).
Since the internal temperature deviation is large, there is a problem that the corrected RTC error is limited to about 2 seconds per day, and highly accurate time compensation cannot be realized.

【0005】本発明は、上記課題を解決するためになさ
れたもので、高精度のリアルタイムクロックを低コスト
で実現することができるリアルタイムクロックの時刻補
正方法及び時刻補正装置を提供することを目的とする。
The present invention has been made to solve the above problems, and an object of the present invention is to provide a time correction method and time correction device for a real time clock capable of realizing a highly accurate real time clock at low cost. To do.

【0006】[0006]

【課題を解決するための手段】本発明は、第1の振動源
の発振を所定数カウントした期間を単位時間としてリア
ルタイムクロックを生成するリアルタイムクロック回路
に対し、補正値を設定して、この補正値に応じて前記所
定数を増減させて前記リアルタイムクロックを補正する
リアルタイムクロックの時刻補正方法において、使用温
度範囲内で前記第1の振動源より平坦な温度特性を有す
る第2の振動源の発振周波数を、初期時のみ入力される
基準クロックを計時の源として測定し、測定した発振周
波数を記憶する初期時測定手順と、前記第2の振動源の
発振周波数を、前記リアルタイムクロックを計時の源と
して測定する実使用時測定手順と、前記実使用時測定手
順で測定した発振周波数と前記初期時測定手順で記憶し
た発振周波数との差分から前記リアルタイムクロックの
誤差が最小となる前記補正値を算出し、この補正値を前
記リアルタイムクロック回路に設定する設定手順とを実
行するようにしたものである。また、本発明のリアルタ
イムクロックの時刻補正方法は、使用温度範囲内で前記
第1の振動源より平坦な温度特性を有する第2の振動源
の発振を、初期時のみ入力される基準クロックを計時の
源として所定の測定時間中カウントし、測定したカウン
ト値を記憶する初期時測定手順と、前記第2の振動源の
発振を、前記リアルタイムクロックを計時の源として所
定の測定時間中カウントする実使用時測定手順と、前記
実使用時測定手順で測定したカウント値と前記初期時測
定手順で記憶したカウント値との差分から前記リアルタ
イムクロックの誤差が最小となる前記補正値を算出し、
この補正値を前記リアルタイムクロック回路に設定する
設定手順とを実行するようにしたものである。また、本
発明のリアルタイムクロックの時刻補正方法の1構成例
は、前記実使用時測定手順の測定時間を測定の分解能よ
り大きくするようにしたものである。
According to the present invention, a correction value is set for a real-time clock circuit that generates a real-time clock with a period of counting a predetermined number of oscillations of a first vibration source as a unit time, and this correction is performed. In a real-time clock time correction method for correcting the real-time clock by increasing or decreasing the predetermined number according to a value, oscillation of a second vibration source having a flatter temperature characteristic than that of the first vibration source within an operating temperature range. The frequency is measured by using a reference clock that is input only at the initial stage as a timing source, and the measured oscillation frequency is stored, and the oscillation frequency of the second vibration source is measured by the real-time clock. Of the oscillation frequency measured in the actual measurement procedure and the oscillation frequency stored in the initial measurement procedure. Know calculates the correction value the smallest error of the real time clock is the correction value which was set to run a setup procedure for setting the real time clock circuit. Further, according to the time correction method of the real-time clock of the present invention, the oscillation of the second vibration source having a flatter temperature characteristic than that of the first vibration source is measured within the operating temperature range by measuring the reference clock input only at the initial time. Of the second vibration source, and counts the oscillation of the second vibration source during the predetermined measurement time by counting for the predetermined measurement time and storing the measured count value. During use measurement procedure, calculating the correction value that minimizes the error of the real-time clock from the difference between the count value measured in the actual use measurement procedure and the count value stored in the initial measurement procedure,
A setting procedure for setting the correction value in the real-time clock circuit is executed. Further, one configuration example of the time correction method of the real-time clock of the present invention is one in which the measurement time of the actual-use measurement procedure is made larger than the measurement resolution.

【0007】また、本発明のリアルタイムクロックの時
刻補正装置は、第1の振動源の発振を所定数カウントし
た期間を単位時間としてリアルタイムクロックを生成す
ると共に、設定された補正値に応じて前記所定数を増減
させて前記リアルタイムクロックを補正する誤差補正機
能付きリアルタイムクロック回路と、使用温度範囲内で
前記第1の振動源より平坦な温度特性を有する第2の振
動源と、前記第2の振動源の発振周波数を、初期時のみ
入力される基準クロックを計時の源として測定する初期
時測定手段と、この初期時測定手段で測定された発振周
波数を記憶する記憶手段と、前記第2の振動源の発振周
波数を、前記リアルタイムクロックを計時の源として測
定する実使用時測定手段と、この実使用時測定手段で測
定された発振周波数と前記記憶された発振周波数との差
分から前記リアルタイムクロックの誤差が最小となる前
記補正値を算出し、この補正値を前記誤差補正機能付き
リアルタイムクロック回路に設定する設定手段とを有す
るものである。また、本発明のリアルタイムクロックの
時刻補正装置は、第1の振動源の発振を所定数カウント
した期間を単位時間としてリアルタイムクロックを生成
すると共に、設定された補正値に応じて前記所定数を増
減させて前記リアルタイムクロックを補正する誤差補正
機能付きリアルタイムクロック回路と、使用温度範囲内
で前記第1の振動源より平坦な温度特性を有する第2の
振動源と、前記第2の振動源の発振を、初期時のみ入力
される基準クロックを計時の源として所定の測定時間中
カウントする初期時測定手段と、この初期時測定手段で
測定されたカウント値を記憶する記憶手段と、前記第2
の振動源の発振を、前記リアルタイムクロックを計時の
源として所定の測定時間中カウントする実使用時測定手
段と、この実使用時測定手段で測定されたカウント値と
前記記憶されたカウント値との差分から前記リアルタイ
ムクロックの誤差が最小となる前記補正値を算出し、こ
の補正値を前記誤差補正機能付きリアルタイムクロック
回路に設定する設定手段とを有するものである。また、
本発明のリアルタイムクロックの時刻補正装置は、前記
実使用時測定手段の測定時間を測定の分解能より大きく
するようにしたものである。
Further, the real time clock time correction device of the present invention generates the real time clock with a period of counting a predetermined number of oscillations of the first vibration source as a unit time and at the same time according to the set correction value. A real-time clock circuit with an error correction function that corrects the real-time clock by increasing or decreasing the number, a second vibration source having a flatter temperature characteristic than the first vibration source within an operating temperature range, and the second vibration. An initial measurement means for measuring the oscillation frequency of the source using a reference clock input only at the initial time as a timing source, a storage means for storing the oscillation frequency measured by the initial measurement means, and the second vibration. An actual use measuring means for measuring the oscillation frequency of the source as the real time clock source, and an oscillation frequency measured by the actual use measuring means. And a setting means for calculating the correction value that minimizes the error of the real-time clock from the difference between the stored oscillation frequency and setting the correction value in the real-time clock circuit with an error correction function. . In addition, the time correction device for the real-time clock of the present invention generates the real-time clock with a period of counting a predetermined number of oscillations of the first vibration source as a unit time, and increases or decreases the predetermined number according to a set correction value. A real-time clock circuit with an error correction function for correcting the real-time clock, a second vibration source having a flatter temperature characteristic than the first vibration source within an operating temperature range, and an oscillation of the second vibration source. The initial time measuring means for counting for a predetermined measuring time by using a reference clock input only at the initial time as a time source, a storage means for storing the count value measured by the initial time measuring means, and the second means.
Of the vibration source of the actual use measuring means for counting during the predetermined measurement time by using the real time clock as a time source, and the count value measured by the actual use measuring means and the stored count value The correction value that minimizes the error of the real-time clock is calculated from the difference, and the correction value is set in the real-time clock circuit with an error correction function. Also,
The time correction device of the real-time clock of the present invention is such that the measurement time of the actual-use measuring means is made larger than the measurement resolution.

【0008】[0008]

【発明の実施の形態】[第1の実施の形態]以下、本発
明の実施の形態について図面を参照して詳細に説明す
る。図1は本発明の第1の実施の形態となる電子機器の
構成を示すブロック図である。本実施の形態の電子機器
は、第1の振動源である音叉型水晶振動子1をクロック
ソースとする誤差補正機能付きRTC2と、第2の振動
源であるAT水晶振動子3の発振クロックをカウントす
る初期時測定手段及び実使用時測定手段となるカウンタ
4と、随時書き込み/読み出しが可能な記憶手段とな
る、例えばフラッシュROM等の不揮発性メモリ5と、
誤差補正機能付きRTC2の補正値を算出して設定する
設定手段となるCPU6とを有している。
BEST MODE FOR CARRYING OUT THE INVENTION [First Embodiment] Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. FIG. 1 is a block diagram showing the configuration of an electronic device according to a first embodiment of the present invention. The electronic device according to the present embodiment is provided with an RTC 2 with an error correction function that uses the tuning fork type crystal resonator 1 that is the first vibration source as a clock source, and the oscillation clock of the AT crystal resonator 3 that is the second vibration source. A counter 4 which serves as an initial measurement means for counting and an actual use measurement means, and a non-volatile memory 5 such as a flash ROM which serves as a storage means that can be written / read at any time.
It has a CPU 6 as a setting means for calculating and setting a correction value of the RTC 2 with an error correction function.

【0009】このような電子機器としては、例えばビル
内の設備の制御・管理を行うコントローラなどがある。
誤差補正機能付きRTC2の時計精度は、接続される音
叉型水晶振動子1の精度や負荷容量(RTC内蔵の発振
回路の容量及びプリント板の浮遊容量)に依存する。本
実施の形態では、可変容量等の調整は行わず、基準クロ
ックのカウント値と誤差補正機能付きRTC2の出力ク
ロックのカウント値とを比較することで誤差を算出し、
誤差を最小にする補正値を誤差補正機能付きRTC2に
設定することで、常温(初期時に補正値を設定するとき
の温度条件。想定される現場の環境から、出荷調整の温
度条件を規定する)で±3ppm(補正後の理想値±
1.5ppmに基準クロックの確度・自動計測の誤差を
加味する)の精度を実現する。
As such an electronic device, there is, for example, a controller for controlling / managing facilities in a building.
The clock precision of the RTC 2 with the error correction function depends on the precision and load capacitance of the tuning fork type crystal unit 1 to be connected (capacitance of the oscillation circuit incorporated in the RTC and stray capacitance of the printed board). In the present embodiment, the adjustment of the variable capacitance and the like is not performed, and the error is calculated by comparing the count value of the reference clock with the count value of the output clock of the RTC 2 with the error correction function,
By setting the correction value that minimizes the error in the RTC2 with the error correction function, the room temperature (temperature condition when setting the correction value at the initial stage. The temperature condition for shipping adjustment is specified from the assumed site environment) ± 3 ppm (ideal value after correction ±
The accuracy of 1.5 ppm is added to the accuracy of the reference clock and the error of automatic measurement).

【0010】以下、図1のような電子機器におけるRT
Cの時刻補正方法を説明する。まず、工場出荷時(初期
時)、予め校正された基準クロックCLKref を電子機
器に入力し、この基準クロックCLKref を使って計時
した所定の測定時間の間、AT水晶振動子3の発振クロ
ックをカウンタ4でカウントする。そして、CPU6
は、カウンタ4の測定結果のカウント値をメモリ5に格
納する(初期時測定手順)。
Hereinafter, the RT in the electronic equipment as shown in FIG.
The time correction method of C will be described. First, at the time of factory shipment (initial time), a pre-calibrated reference clock CLKref is input to an electronic device, and the oscillation clock of the AT crystal unit 3 is countered for a predetermined measurement time measured using this reference clock CLKref. Count at 4. And CPU6
Stores the count value of the measurement result of the counter 4 in the memory 5 (initial measurement procedure).

【0011】次に、基準クロックCLKref を使って計
時した測定時間の間、誤差補正機能付きRTC2のクロ
ック出力をCPU6内の図示しないカウンタでカウント
し、測定結果のカウント値と既知の調整目標カウント値
(誤差補正機能付きRTC2の誤差が0の場合のカウン
ト値)との差分をとることにより、誤差補正機能付きR
TC2の誤差分に相当する差分を求める。そして、CP
U6は、このカウント値の差分から誤差補正機能付きR
TC2の補正値を算出して、算出した補正値を誤差補正
機能付きRTC2に設定する。以上で、工場出荷時の初
期設定が終了する。
Next, during the measurement time measured by using the reference clock CLKref, the clock output of the RTC 2 with error correction function is counted by a counter (not shown) in the CPU 6, and the count value of the measurement result and the known adjustment target count value are counted. R with error correction function is obtained by taking the difference with (count value when error of RTC2 with error correction function is 0).
A difference corresponding to the error of TC2 is obtained. And CP
U6 is the R with error correction function based on the difference between the count values.
The correction value of TC2 is calculated, and the calculated correction value is set in the RTC2 with an error correction function. This completes the factory default settings.

【0012】次に、工場出荷後の時刻補正について説明
する。音叉型水晶振動子1は図2に示すような温度特性
を有するため、電子機器の動作中に周囲温度が変動する
と、音叉型水晶振動子1の発振周波数が変動して、誤差
補正機能付きRTC2の時刻に誤差が生じる。これに対
して、AT水晶振動子3は図2に示すように0〜50℃
における温度特性が平坦であるため、周囲温度が変動し
たとしても、発振周波数の変動は十分小さい。このよう
な関係を利用して、AT水晶振動子3の温度偏差による
誤差補正機能付きRTC2の誤差を求め、補正値を自動
的に再設定する。
Next, the time correction after shipment from the factory will be described. Since the tuning fork crystal unit 1 has temperature characteristics as shown in FIG. 2, if the ambient temperature fluctuates during the operation of the electronic device, the oscillation frequency of the tuning fork crystal unit 1 fluctuates, and the RTC 2 with the error correction function is provided. There is an error in the time of. On the other hand, the AT crystal unit 3 has a temperature of 0 to 50 ° C. as shown in FIG.
Since the temperature characteristic at is flat, the fluctuation of the oscillation frequency is sufficiently small even if the ambient temperature changes. Utilizing such a relationship, the error of the RTC 2 with an error correction function due to the temperature deviation of the AT crystal unit 3 is obtained, and the correction value is automatically reset.

【0013】カウンタ4は、誤差補正機能付きRTC2
を使って計時した所定の測定時間の間、AT水晶振動子
3の発振クロックをカウントする(実使用時測定手
順)。CPU6は、工場出荷設定時にメモリ5に格納し
たカウント値とカウンタ4の測定結果のカウント値との
差分を算出する。この差分が誤差補正機能付きRTC2
の誤差に相当する。CPU6は、求めた差分に基づい
て、誤差補正機能付きRTC2の誤差が最小となるよう
な補正値を算出して、誤差補正機能付きRTC2の補正
値を再設定する。
The counter 4 is an RTC 2 with an error correction function.
The oscillation clock of the AT crystal oscillator 3 is counted during a predetermined measurement time measured by using (measurement procedure during actual use). The CPU 6 calculates the difference between the count value stored in the memory 5 at the time of factory shipment and the count value of the measurement result of the counter 4. This difference is RTC2 with error correction function
Corresponds to the error of. Based on the obtained difference, the CPU 6 calculates a correction value that minimizes the error of the RTC 2 with the error correction function, and resets the correction value of the RTC 2 with the error correction function.

【0014】以上の手順により、安価な(すなわち、精
度の低い)水晶振動子を用いて、誤差補正機能付きRT
C2の1日あたりの誤差を最悪条件で1秒未満とするこ
とができる。1つのAT水晶振動子3でCPU6の動作
クロックに必要な水晶振動子とカウンタ4の水晶振動子
とを兼用すれば、コスト上昇を抑えることが可能であ
る。
According to the above procedure, an inexpensive (that is, low precision) crystal oscillator is used, and an RT with an error correction function is used.
The error of C2 per day can be set to less than 1 second under the worst condition. If one AT crystal unit 3 also serves as the crystal unit required for the operation clock of the CPU 6 and the crystal unit of the counter 4, it is possible to suppress the cost increase.

【0015】[第2の実施の形態]次に、本発明の第2
の実施の形態について説明する。図3は本発明の第2の
実施の形態となる電子機器の構成を示すブロック図であ
る。本実施の形態は、第1の実施の形態をより具体的に
説明するものである。本実施の形態の電子機器は、第1
の振動源である音叉型水晶振動子11と、誤差補正機能
付きRTC12と、第2の振動源であるAT水晶振動子
13と、随時書き込み/読み出しが可能な記憶手段とな
る、例えばフラッシュROM等の不揮発性メモリ15
と、誤差補正機能付きRTC12の補正値を算出して設
定する設定手段となるCPU16と、基準クロックCL
Kref をCPU16に入力するデジタル入力回路17と
を有している。
[Second Embodiment] Next, the second embodiment of the present invention will be described.
The embodiment will be described. FIG. 3 is a block diagram showing the configuration of the electronic device according to the second embodiment of the present invention. The present embodiment more specifically describes the first embodiment. The electronic device according to the present embodiment is the first
Tuning fork type crystal oscillator 11 which is a vibration source, an RTC 12 having an error correction function, an AT crystal oscillator 13 which is a second vibration source, and a storage means which can be written / read at any time, such as a flash ROM. Non-volatile memory 15
And a CPU 16 as a setting means for calculating and setting a correction value of the RTC 12 with an error correction function, and a reference clock CL
It has a digital input circuit 17 for inputting Kref to the CPU 16.

【0016】誤差補正機能付きRTC12を駆動する音
叉型水晶振動子11の発振周波数は32.768kHz
である。誤差補正機能付きRTC12は、音叉型水晶振
動子11により生成されるクロックの32768パルス
毎に1秒カウントアップを行う。この誤差補正機能付き
RTC12は、CPU16とバス経由で接続され、CP
U16から時刻の読み出し/書き込みや補正値の設定が
行われる。
The oscillation frequency of the tuning fork type crystal unit 11 for driving the RTC 12 with an error correction function is 32.768 kHz.
Is. The RTC 12 with an error correction function counts up for 1 second for each 32768 pulses of the clock generated by the tuning fork crystal unit 11. This RTC 12 with error correction function is connected to the CPU 16 via a bus,
From U16, time reading / writing and correction value setting are performed.

【0017】CPU16を動作させるためのAT水晶振
動子13の発振周波数は4MHzである。以下、このA
T水晶振動子13の発振を原発振と呼ぶ。CPU16の
内部で原発振の整数倍のシステムクロック(ここでは3
2MHz)が生成される。
The oscillation frequency of the AT crystal oscillator 13 for operating the CPU 16 is 4 MHz. Below, this A
The oscillation of the T crystal oscillator 13 is called original oscillation. Inside the CPU 16, a system clock that is an integral multiple of the original oscillation (3 in this case)
2 MHz) is generated.

【0018】CPU16は、プロセッサ・コア101
と、メモリ・コントローラ102と、32ビットタイマ
103−1,103−2と、汎用タイマ104と、イン
タフェース105と、内部バス・インタフェースユニッ
ト106と、外部バス・インタフェースユニット107
とを有している。
The CPU 16 is a processor core 101.
, Memory controller 102, 32-bit timers 103-1 and 103-2, general-purpose timer 104, interface 105, internal bus interface unit 106, and external bus interface unit 107.
And have.

【0019】32ビットタイマ103−1,103−2
を駆動するクロックソースとしてはシステムクロックを
分周したクロック信号(分周比は可変)を使用してい
る。
32-bit timers 103-1 and 103-2
A clock signal obtained by dividing the system clock (the division ratio is variable) is used as a clock source for driving the.

【0020】タイマ103−1,103−2とは別の汎
用タイマ104は、CPU16に内蔵されたRTCで、
システムクロックを分周したクロック信号PITRTC
LK(分周比は可変)を9600で割った周波数のクロ
ックで駆動される。32ビットタイマ103−1と汎用
タイマ104は、第1の実施の形態のカウンタ4に相当
する。
A general-purpose timer 104 different from the timers 103-1 and 103-2 is an RTC built in the CPU 16,
Clock signal PITRTC obtained by dividing the system clock
It is driven by a clock having a frequency obtained by dividing LK (variable division ratio) by 9600. The 32-bit timer 103-1 and the general-purpose timer 104 correspond to the counter 4 of the first embodiment.

【0021】CPU内蔵の汎用タイマ104の代わり
に、外付けのRTC12を使用している理由は、日差±
1秒以内を実現するために誤差補正機能付きRTCを使
う必要があるためと、停電等の電源断時にもRTCを動
作させるためにRTC12のみバッテリバックアップす
るためである。
The reason for using the external RTC 12 instead of the general-purpose timer 104 with a built-in CPU is that
This is because it is necessary to use the RTC with an error correction function in order to realize within 1 second, and because only the RTC 12 is backed up by a battery so that the RTC operates even when the power is cut off due to a power failure or the like.

【0022】以下、このような電子機器におけるRTC
の時刻補正方法を説明する。まず、工場出荷時、予め±
1ppm以内に校正された基準クロックCLKref を電
子機器に入力する。基準クロックCLKref は、デジタ
ル入力回路17を介してCPU16に入力され、CPU
16内部では外部バス・インタフェース・ユニット、内
部バス・インタフェース・ユニットを介して内部バスに
送られる。この基準クロックCLKref を用いて、単位
時間あたりの原発振(正確には原発振を分周して生成さ
れるクロック)のカウント数を測定する。
Hereinafter, the RTC in such electronic equipment
The time correction method will be described. First, at the time of factory shipment,
Input the reference clock CLKref calibrated within 1ppm to the electronic equipment. The reference clock CLKref is input to the CPU 16 via the digital input circuit 17,
16 is sent to the internal bus via the external bus interface unit and the internal bus interface unit. Using this reference clock CLKref, the number of counts of the original oscillation (correctly, a clock generated by dividing the original oscillation) per unit time is measured.

【0023】ここでは、10分前後の測定時間でもカウ
ンタの分解能による誤差が問題とならないような周期の
カウンタを使用する。よって、初期時測定手段となるカ
ウンタとして32ビットタイマ103−1を使用し、測
定対象のクロックソースとして前記システムクロックを
16分周したクロックCLKx を使用する。このクロッ
クCLKx の周波数をfCPM とすると、システムクロッ
クが32MHzなので、周波数fCPM は2MHzであ
る。
Here, a counter having a cycle is used so that the error due to the resolution of the counter does not pose a problem even in the measurement time of about 10 minutes. Therefore, the 32-bit timer 103-1 is used as the counter which serves as the initial measurement means, and the clock CLKx obtained by dividing the system clock by 16 is used as the clock source to be measured. If the frequency of this clock CLKx is f CPM , the system clock is 32 MHz, so the frequency f CPM is 2 MHz.

【0024】基準クロックCLKref を使って計時した
測定時間M秒の間、32ビットタイマ103−1によっ
てクロックCLKx を数えたカウント値をCx とする。
このとき、M秒間のカウント値Cx12 を12分間の値に
換算したカウント値Cx12 は次式のように得られる。 Cx12 =Cx ×60(sec)×12(min)/M =720×Cx /M(カウント) ・・・(1) プロセッサ・コア101は、32ビットタイマ103−
1の測定結果Cx から算出したカウント値Cx12 をメモ
リ15に格納する。
The count value obtained by counting the clock CLKx by the 32-bit timer 103-1 during the measurement time M seconds measured using the reference clock CLKref is Cx.
At this time, the count value Cx12 obtained by converting the count value Cx12 for M seconds into a value for 12 minutes is obtained by the following equation. Cx12 = Cx × 60 (sec) × 12 (min) / M = 720 × Cx / M (count) (1) The processor core 101 includes a 32-bit timer 103-
The count value Cx12 calculated from the measurement result Cx of 1 is stored in the memory 15.

【0025】以上の初期時測定手順に含まれる誤差は以
下のようになる。 (a)クロックCLKx の入力から割込み発生までの回
路の遅延。最大125μsec。 (b)割込み発生から32ビットタイマ読み出しまでの
S/W処理時間。割り込み処理内で読み出すため(A)
に比べて非常に小さく、無視できる。 (c)32ビットタイマ103−1の分解能。クロック
CLKx の周波数fCPMが2MHzの場合、1/2MH
z=500nsec。 以上(a)、(b)、(c)により、計測誤差はマージ
ンをみて200μsecとする。測定時間を12分とす
ると誤差は200(μsec)/720(sec)=
0.278ppmとなる。
The errors included in the above initial measurement procedure are as follows. (A) Circuit delay from clock CLKx input to interrupt generation. Up to 125 μsec. (B) S / W processing time from interrupt generation to 32-bit timer reading. To read during interrupt processing (A)
It is very small compared to and can be ignored. (C) Resolution of the 32-bit timer 103-1. When the frequency f CPM of the clock CLKx is 2MHz, 1 / 2MH
z = 500 nsec. From the above (a), (b), and (c), the measurement error is set to 200 μsec with a margin. If the measurement time is 12 minutes, the error is 200 (μsec) / 720 (sec) =
It becomes 0.278 ppm.

【0026】次に、基準クロックCLKref を用いて、
誤差補正機能付きRTC12の補正値を算出して設定す
る。ここでは、カウンタとして32ビットタイマ103
−2を使用し、測定対象の誤差補正機能付きRTC12
のクロック出力をインタフェース105を通じて32ビ
ットタイマ103−2でカウントし、測定後のカウント
値と調整目標のカウント値(既知)との差分をとる(測
定時間は、要求される時計精度に応じて事前に決定す
る。また調整目標値は、音叉型水晶振動子11の温度特
性を考慮し、製品の動作温度範囲内で日差が最小になる
ように設定する)。
Next, using the reference clock CLKref,
The correction value of the RTC 12 with the error correction function is calculated and set. Here, a 32-bit timer 103 is used as a counter.
-2, RTC12 with error correction function for measurement target
The clock output of is counted by the 32-bit timer 103-2 through the interface 105, and the difference between the count value after measurement and the count value (known) of the adjustment target is calculated (measurement time is adjusted in advance according to the required clock accuracy). Further, the adjustment target value is set in consideration of the temperature characteristics of the tuning fork type crystal unit 11 so that the day difference is minimized within the operating temperature range of the product).

【0027】プロセッサ・コア101は、カウント値の
差分から誤差補正機能付きRTC12の補正値を算出
し、算出した補正値をインタフェース105を通じて誤
差補正機能付きRTC12の時計誤差補正レジスタに設
定すると共に、メモリ・コントローラ102を通じてメ
モリ15に格納する。
The processor core 101 calculates the correction value of the RTC 12 with the error correction function from the difference of the count values, sets the calculated correction value in the clock error correction register of the RTC 12 with the error correction function through the interface 105, and stores it in the memory. -Stored in the memory 15 through the controller 102.

【0028】以降は、誤差補正機能付きRTC12がバ
ッテリバックアップされている限り後述のように自動的
に時刻補正が行われる。バッテリバックアップが中断さ
れた場合は、メモリ15に格納されている補正値を誤差
補正機能付きRTC12に再設定する。
After that, as long as the RTC 12 with the error correction function is backed up by the battery, the time is automatically corrected as described later. When the battery backup is interrupted, the correction value stored in the memory 15 is reset in the RTC 12 with the error correction function.

【0029】次に、誤差補正機能付きRTC12の補正
値の算出方法を具体的に説明する。ここでは、誤差補正
機能付きRTC12の調整目標発振周波数ft を32.
768kHz、測定時間を10分とする。よって、10
分間測定した場合の調整目標カウント値Ct は、327
68×60(sec)×10(min)=196608
00カウントとなる。
Next, a method of calculating the correction value of the RTC 12 with the error correction function will be specifically described. Here, the adjustment target oscillation frequency ft of the RTC 12 with the error correction function is set to 32.
The measurement time is 10 minutes at 768 kHz. Therefore, 10
The adjustment target count value Ct when measured for a minute is 327
68 x 60 (sec) x 10 (min) = 196608
It becomes 00 count.

【0030】調整対象の実際の発振周波数、すなわち音
叉型水晶振動子11の発振周波数をfx とすると、fx
>ftの場合(時計が進んでいる場合)、補正値αは次
式で得られるように定められている。 α=(fx−ft+0.1)/(fx ×3.051×10-6) ≒(fx−ft)×10+1 ・・・(2)
If the actual oscillation frequency to be adjusted, that is, the oscillation frequency of the tuning fork type crystal oscillator 11 is fx, then fx
When> ft (when the clock is advanced), the correction value α is defined to be obtained by the following equation. α = (fx−ft + 0.1) / (fx × 3.051 × 10 −6 ) ≈ (fx−ft) × 10 + 1 (2)

【0031】基準クロックCLKref を使って計時した
10分間、32ビットタイマ103−2によって誤差補
正機能付きRTC12のクロック出力を数えたカウント
値をCy とすると、式(2)を次式のように書き換える
ことができる。 α=(Cy−Ct)/600×10+1 ・・・(3)
When the count value obtained by counting the clock output of the RTC 12 with the error correction function by the 32-bit timer 103-2 is Cy for 10 minutes measured using the reference clock CLKref, the equation (2) is rewritten as the following equation. be able to. α = (Cy−Ct) / 600 × 10 + 1 (3)

【0032】一方、fx<ftの場合(時計が遅れている
場合)、補正値αは次式で得られるように定められてい
る。 α=(fx−ft)/(fx ×3.051×10−6) ≒(fx−ft)×10=(Cy−Ct)/600×10 ・・・(4)
On the other hand, when fx <ft (when the clock is delayed), the correction value α is set to be obtained by the following equation. α = (fx−ft) / (fx × 3.051 × 10−6) ≈ (fx−ft) × 10 = (Cy−Ct) / 600 × 10 (4)

【0033】プロセッサ・コア101は、このようにし
て計算した補正値αを7ビットの符号付き2進数にして
誤差補正機能付きRTC12の時計誤差補正レジスタに
設定する。前述のように、誤差補正機能付きRTC12
は、通常、音叉型水晶振動子11により生成されるクロ
ックの32768パルス毎に1秒カウントアップを行う
が、誤差補正機能付きRTC12の図示しない時計誤差
補正回路は、秒桁が00秒、20秒、40秒となったと
きに、時計誤差補正レジスタの値により1秒のカウント
値を変更する。
The processor core 101 converts the thus calculated correction value α into a 7-bit signed binary number and sets it in the clock error correction register of the RTC 12 with an error correction function. As described above, the RTC 12 with the error correction function
Normally counts up for 1 second for each 32768 pulses of the clock generated by the tuning fork crystal unit 11, but the clock error correction circuit (not shown) of the RTC 12 with error correction function has a second digit of 00 seconds, 20 seconds. , 40 seconds, the count value of 1 second is changed according to the value of the clock error correction register.

【0034】2進数表記の補正値αをF6,F5,F4,
F3,F2,F1,F0 とすると、最上位ビットF6 が0
のとき、((F5,F4,F3,F2,F1,F0)−1)×
2だけカウント値が増加し、時計が遅れる。例えば、
(F6,F5,F4,F3,F2,F1,F0 )=(0,0,
0,1,0,00)のとき、カウント値が32768+
(8−1)×2=32782になる。時計誤差補正回路
は、通常は、クロックの32768パルス毎に1秒カウ
ントアップを行うが、20秒に1度は32782パルス
で1秒カウントアップを行うことになる。
The correction value α in binary notation is set to F6, F5, F4,
If F3, F2, F1, and F0, the most significant bit F6 is 0
Then, ((F5, F4, F3, F2, F1, F0) -1) x
The count value increases by 2 and the clock is delayed. For example,
(F6, F5, F4, F3, F2, F1, F0) = (0, 0,
0, 1, 0:00), the count value is 32768+
(8-1) × 2 = 32782. The clock error correction circuit normally counts up for 1 second for each 32768 pulses of the clock, but once for 20 seconds, it counts up for 32782 pulses for 1 second.

【0035】最上位ビットF6 が1のとき、((バーF
5,バーF4,バーF3,バーF2,バーF1,バーF0)+
1)×2だけカウント値が減少し、時計が進む。例え
ば、(F6,F5,F4,F3,F2,F1,F0 )=(1,
1,1,1,1,10)のとき、カウント値が3276
8+(−2)×2=32764になる。時計誤差補正回
路は、20秒に1度は32764パルスで1秒カウント
アップを行う。
When the most significant bit F6 is 1, ((bar F
5, bar F4, bar F3, bar F2, bar F1, bar F0) +
1) The count value decreases by 2 and the clock advances. For example, (F6, F5, F4, F3, F2, F1, F0) = (1,
1,1,1,1,10), the count value is 3276
8 + (− 2) × 2 = 32764. The clock error correction circuit counts up for 1 second with 32764 pulses once every 20 seconds.

【0036】なお、Cy=Ctの場合、プロセッサ・コア
101は、0,+1,−64,−63のいずれかの値を
誤差補正機能付きRTC12の時計誤差補正レジスタに
設定する。このときは補正は行われない。
When Cy = Ct, the processor core 101 sets any one of 0, +1, -64, and -63 in the clock error correction register of the RTC 12 with an error correction function. At this time, no correction is made.

【0037】補正値αの許容値範囲は、−62≦α≦6
3というように予め定められている。これにより、調整
目標カウント値Ct と測定結果のカウント値Cy との差
分(Cy−Ct)の許容値は、以下のように表せる。
The allowable value range of the correction value α is -62≤α≤6.
3 is set in advance. Accordingly, the allowable value of the difference (Cy−Ct) between the adjustment target count value Ct and the measurement result count value Cy can be expressed as follows.

【0038】補正値αが最大となるのは、fx>ftの場
合(0<α、時計が進んでいる場合)である。式(3)
から次式が得られる。 (Cy−Ct)=(α−1)×Tm/10 ・・・(5) 差分(Cy−Ct)の最大値を(Cy−Ct)max 、補正値
αの最大値をαmax とすると、式(5)より次式が得ら
れる。 (Cy−Ct)max =(αmax −1)×Tm/10=(63−1)×Tm/10 =62×Tm/10 ・・・(6)
The maximum correction value α is when fx> ft (0 <α, when the clock is advanced). Formula (3)
The following equation is obtained from (Cy−Ct) = (α−1) × Tm / 10 (5) The maximum value of the difference (Cy−Ct) is (Cy−Ct) max, and the maximum value of the correction value α is αmax. The following equation is obtained from (5). (Cy-Ct) max = (αmax-1) × Tm / 10 = (63-1) × Tm / 10 = 62 × Tm / 10 (6)

【0039】また、補正値αが最小となるのは、fx<
ftの場合(α<0、時計が遅れている場合)である。
式(4)から次式が得られる。 (Cy−Ct)=α×Tm/10 ・・・(7) 差分(Cy−Ct)の最小値を(Cy−Ct)min 、補正値
αの最小値をαmin とすると、式(7)より次式が得ら
れる。 (Cy−Ct)min =αmin ×Tm/10=−62×Tm/10 ・・(8)
The minimum correction value α is fx <
This is the case of ft (α <0, clock is behind).
The following equation is obtained from the equation (4). (Cy−Ct) = α × Tm / 10 (7) If the minimum value of the difference (Cy−Ct) is (Cy−Ct) min and the minimum value of the correction value α is αmin, then from equation (7) The following equation is obtained. (Cy−Ct) min = αmin × Tm / 10 = −62 × Tm / 10 (8)

【0040】式(6)、式(8)より、差分(Cy−C
t)の許容値範囲は次のようになる。 −62×Tm/10≦(Cy−Ct)≦62×Tm/10 ・・・(9)
From the equations (6) and (8), the difference (Cy-C
The allowable range of t) is as follows. −62 × Tm / 10 ≦ (Cy−Ct) ≦ 62 × Tm / 10 (9)

【0041】基準クロックCLKref が出力する正しい
パルスに対し、誤差補正機能付きRTC12の出力クロ
ックのCPU16への入力→割込み発生→32ビットタ
イマ読み出しまでの処理時間により、以下のような誤差
が発生する。 (d)誤差補正機能付きRTC12の出力クロックのC
PU16への入力から割込み発生までの回路の遅延。入
力のフォトカプラ、RCフィルタでの遅延は毎回のパル
スで一定と考え、無視できる。デジタル入力の状態変化
検出回路(16kHz −50/+25%)のクロック
を使用するため、遅延は0〜125μsの間で変動す
る。その結果、計測誤差は最大125μsecである。
With respect to the correct pulse output from the reference clock CLKref, the following error occurs due to the processing time from input of the output clock of the RTC 12 with error correction function to the CPU 16 → interrupt generation → 32-bit timer reading. (D) C of the output clock of the RTC 12 with error correction function
Delay of circuit from input to PU16 to generation of interrupt. The delay in the input photocoupler and RC filter is considered to be constant for each pulse and can be ignored. Since the clock of the state change detection circuit (16 kHz-50 / + 25%) of the digital input is used, the delay varies from 0 to 125 μs. As a result, the maximum measurement error is 125 μsec.

【0042】(e)割込み発生から32ビットタイマ読
み出しまでのS/W処理時間。割り込み処理内で読み出
すため(d)に比べて非常に小さく、無視できる。 (f)32ビットタイマの分解能。32.768kHz
の場合で30.5μsecである。 以上(d)、(e)、(f)により、計測誤差はマージ
ンをみて300μsecとする。測定時間を10分とす
ると誤差は300(μsec)/600(sec)=
0.5ppmとなり、補正分解能3ppmと比較し許容
範囲内である。
(E) S / W processing time from interrupt generation to 32-bit timer reading. Since it is read in the interrupt processing, it is much smaller than (d) and can be ignored. (F) 32-bit timer resolution. 32.768 kHz
In the case of, it is 30.5 μsec. Due to the above (d), (e), and (f), the measurement error is 300 μsec with a margin. If the measurement time is 10 minutes, the error is 300 (μsec) / 600 (sec) =
It becomes 0.5 ppm, which is within the allowable range as compared with the correction resolution of 3 ppm.

【0043】以上のように、工場出荷時(初期時)に誤
差補正機能付きRTC12が時刻補正される。次に、工
場出荷後の時刻補正について説明する。温度偏差の小さ
い原発振を使用したカウンタを24時間走らせる。基準
クロックCLKref を使って計時した12分間の原発振
のカウント値がメモリ15に格納されているので、誤差
補正機能付きRTC12の出力クロックを使って計時し
た24時間の原発振のカウント値とメモリ15に格納さ
れたカウント値とを比較すれば、誤差補正機能付きRT
C12の誤差を算出することができる。
As described above, the RTC 12 with the error correction function is time-corrected at the time of factory shipment (initial time). Next, the time correction after shipment from the factory will be described. A counter using an original oscillation with a small temperature deviation is run for 24 hours. Since the count value of the 12-minute original oscillation measured using the reference clock CLKref is stored in the memory 15, the 24-hour original oscillation count value and the memory 15 measured using the output clock of the RTC 12 with error correction function are stored. RT with error correction function by comparing with the count value stored in
The error of C12 can be calculated.

【0044】工場出荷時の場合のように、カウンタとし
て32ビットタイマを使用した場合、クロックソースを
2MHzより遅くできないため、たとえば1時間分のカ
ウント値は2000000×60(sec)×60(m
in)=7200000000であり、32ビットカウ
ンタがオーバーフローするため、32ビットの桁上がり
ごとにS/W処理が必要となる。したがって、ここでは
原発振からの分周比が大きいクロックソースを使用でき
る汎用タイマ104をカウンタ(実使用時測定手段)と
して用いる。
When a 32-bit timer is used as the counter as in the case of factory shipment, the clock source cannot be slower than 2 MHz, so that the count value for one hour is, for example, 2000000 × 60 (sec) × 60 (m).
in) = 72000000, and the 32-bit counter overflows, so S / W processing is required for each carry of 32 bits. Therefore, here, the general-purpose timer 104, which can use a clock source having a large frequency division ratio from the original oscillation, is used as a counter (measurement means during actual use).

【0045】汎用タイマ104のクロックソースである
クロック信号PITRTCLKは、原発振を4分周、す
なわちシステムクロックを32分周したものである。し
たがって、クロック信号PITRTCLKの周波数は1
MHzである。汎用タイマ104は、クロック信号PI
TRTCLKを9600分周したクロックをカウントす
るので、汎用タイマ104は1/{1(MHz)/96
00}=9.6msec毎に1カウントアップすること
になる。
The clock signal PITRTCLK, which is the clock source of the general-purpose timer 104, is the original oscillation divided by 4, that is, the system clock divided by 32. Therefore, the frequency of the clock signal PITRTCLK is 1
MHz. The general-purpose timer 104 uses the clock signal PI
Since the clock obtained by dividing TRTCLK by 9600 is counted, the general-purpose timer 104 uses 1 / {1 (MHz) / 96
00} = 1 count up every 9.6 msec.

【0046】24時間に対する汎用タイマ104の分解
能による誤差は、9.6(msec)/24(H)=
0.111ppmであり、問題ない。この誤差に比べ
て、誤差補正機能付きRTC12の割り込み→汎用タイ
マ読み出しまでのS/W処理による誤差は十分に小さい
ため無視する。
The error due to the resolution of the general-purpose timer 104 for 24 hours is 9.6 (msec) / 24 (H) =
It is 0.111 ppm and there is no problem. Compared to this error, the error due to the S / W processing from the interrupt of the RTC 12 with the error correction function to the reading of the general-purpose timer is sufficiently small and is ignored.

【0047】誤差補正機能付きRTC12を使って計時
した24時間の間、クロック信号PITRTCLKを9
600分周したクロックを汎用タイマ104によって数
えたカウント値をCr とすると、同24時間の間、32
ビットタイマ103−1によってクロックCLKx を数
えたカウント値Cz は次式のようになる。Cz =Cr×
CPM×9600 ・・・
(10)
The clock signal PITRTCLK is set to 9 for 24 hours measured by the RTC 12 with the error correction function.
Assuming that the count value obtained by counting the clock divided by 600 by the general-purpose timer 104 is Cr, it is 32 during the same 24 hours.
The count value Cz obtained by counting the clock CLKx by the bit timer 103-1 is as follows. Cz = Cr ×
f CPM × 9600 ・ ・ ・
(10)

【0048】初期時における測定時間は12分(正確に
はM秒を12分に換算)で、実使用時における測定時間
は24時間であるから、測定したカウント値を比較する
には、測定時間が同一となるようにカウント値を換算す
る必要がある。メモリ15に格納されたカウント値Cx1
2 を24時間の値に換算したカウント値Cx120は次式の
ように得られる。 Cx120=Cx12×5×24(H) ・・・(11) カウント値Cx120は基準クロックCLKref を使って計
時した場合の値であるから、カウント値Cz の真の値で
ある。
The measurement time at the initial stage is 12 minutes (more precisely, M seconds is converted to 12 minutes), and the measurement time at the time of actual use is 24 hours. It is necessary to convert the count value so that Count value Cx1 stored in memory 15
A count value Cx120 obtained by converting 2 into a value of 24 hours is obtained by the following equation. Cx120 = Cx12 × 5 × 24 (H) (11) Since the count value Cx120 is a value measured by using the reference clock CLKref, it is a true value of the count value Cz.

【0049】したがって、誤差補正機能付きRTC12
の24時間の誤差に相当する、クロックCLKx のカウ
ント数eを、式(10)、式(11)より次式のように
求めることができる。 e=Cx120−Cz=(Cx12×5×24)−(Cr×fCPM×9600) =Cx12×23×3×5−Cr×fCPM×27×3×52 ・・・(12) 式(12)において、カウント数eが正の場合、時計が
進み、カウント数eが負の場合、時計が遅れていること
になる。
Therefore, the RTC 12 with the error correction function
The count number e of the clock CLKx corresponding to the error of 24 hours can be obtained from the equations (10) and (11) by the following equation. e = Cx120-Cz = (Cx12 × 5 × 24) - (Cr × f CPM × 9600) = Cx12 × 2 3 × 3 × 5-Cr × f CPM × 2 7 × 3 × 5 2 ··· (12) In Expression (12), when the count number e is positive, the clock is advanced, and when the count number e is negative, the clock is delayed.

【0050】誤差補正機能付きRTC12の補正値を±
1増減すると、20秒毎に32768Hzのパルスが±
2増減される。したがって、誤差補正機能付きRTC1
2の補正値を±1修正したとき、誤差補正機能付きRT
C12の24時間あたりの補正量TADJ は次式のように
なる。 TADJ ={2(パルス)/(32768(パルス)×20(sec))} ×60(sec)×60(min)×24(H) =33×5/29(sec)≒0.264(sec) ・・・(13)
The correction value of the RTC 12 with the error correction function is set to ±
If you increase / decrease by 1, a pulse of 32768Hz will be ± every 20 seconds.
Increases or decreases by 2. Therefore, RTC1 with error correction function
RT with error correction function when the correction value of 2 is corrected by ± 1
The correction amount T ADJ of C12 per 24 hours is as follows. T ADJ = {2 (pulse) / (32768 (pulse) × 20 (sec))} × 60 (sec) × 60 (min) × 24 (H) = 3 3 × 5/2 9 (sec) ≒ 0. 264 (sec) ... (13)

【0051】この補正量TADJ の時間中、32ビットタ
イマ103−1によってクロックCLKx を数えたとき
のカウント値Ch は次式のようになる。 Ch =TADJ×fCPM×1000000 =33×5/29×fCPM×1000000=fCPM×33×57/23 ・・・(14)
During the time of the correction amount T ADJ , the count value Ch when the clock CLKx is counted by the 32-bit timer 103-1 is given by the following equation. Ch = T ADJ × f CPM × 1000000 = 3 3 × 5/2 9 × f CPM × 1000000 = f CPM × 3 3 × 5 7/2 3 ··· (14)

【0052】したがって、誤差補正機能付きRTC12
の補正値の修正量Xは、式(12)、式(14)より次
式のようになる。 X=(RTCの誤差分のカウント数)/(補正値±1ぶんのカウント数) =e/Ch =(Cx12×23×3×5−Cr×fCPM×28×3×52) /(fCPM×33×57/23) =(Cx12×23−Cr×28×5)/(fCPM×32×56/23) =(Cx12−Cr×25×5)×26/(fCPM×32×56) =(Cx12−160×Cr)×64/(fCPM×140625) ・・・(15)
Therefore, the RTC 12 with the error correction function
The correction amount X of the correction value of is expressed by the following equation from the equations (12) and (14). X = (RTC error count) / (correction value ± 1 count) = e / Ch = (Cx12 × 2 3 × 3 × 5-Cr × f CPM × 2 8 × 3 × 5 2 ) / (f CPM × 3 3 × 5 7/2 3) = (Cx12 × 2 3 -Cr × 2 8 × 5) / (f CPM × 3 2 × 5 6/2 3) = (Cx12-Cr × 2 5 × 5) × 2 6 / (f CPM × 3 2 × 5 6 ) = (Cx12−160 × Cr) × 64 / (f CPM × 140625) (15)

【0053】プロセッサ・コア101は、メモリ15に
格納されたカウント値Cx12 と汎用タイマ104による
測定結果Cr とから式(15)により修正量Xを算出
し、この修正量Xを四捨五入した値を、誤差補正機能付
きRTC12の時計誤差補正レジスタの現在の補正値に
加算することで補正値を修正し再設定すると共に、この
修正後の補正値をメモリ15に格納する。
The processor core 101 calculates the correction amount X by the formula (15) from the count value Cx12 stored in the memory 15 and the measurement result Cr by the general-purpose timer 104, and rounds the correction amount X to the rounded value. The correction value is corrected and reset by adding it to the current correction value of the clock error correction register of the RTC 12 with the error correction function, and the corrected correction value is stored in the memory 15.

【0054】ただし、修正前と修正後で補正値の符号が
変わる、または修正後に補正値が0となる場合はさらに
±1加算する(補正値に加算する修正量が正のときはさ
らに+1加算し、加算する修正量が負の場合はさらに−
1加算する)。以上のようにして、誤差補正機能付きR
TC12が自動的に補正される。
However, if the sign of the correction value before and after the change is different, or if the correction value becomes 0 after the correction, an additional ± 1 is added (when the correction amount to be added to the correction value is positive, an additional +1 is added). If the correction amount to be added is negative,
Add 1). As described above, R with error correction function
TC12 is automatically corrected.

【0055】なお、工場出荷時の設定に戻せるように、
工場出荷時の補正値はメモリ15に残しておく。汎用タ
イマ104は電源断中カウントしないため、電源投入後
最初の補正タイミングまで汎用タイマ104のカウンタ
は無効である(電源投入から24時間後に初めて補正が
行なわれる)。
In addition, in order to restore the factory settings,
The correction value at the time of factory shipment is left in the memory 15. Since the general-purpose timer 104 does not count during power-off, the counter of the general-purpose timer 104 is invalid until the first correction timing after power-on (correction is performed only 24 hours after power-on).

【0056】本補正方式の誤差は以下のように算出でき
る。 (g)工場出荷設定時に使用する基準クロックCLKre
f 自体の誤差1.0ppm。 (h)工場出荷時設定に含まれる誤差0.278pp
m。 (i)工場出荷後の汎用タイマ104の分解能による誤
差0.111ppm。 (j)RTC補正値の分解能による誤差1.526pp
m。
The error of this correction method can be calculated as follows. (G) Reference clock CLKre used at factory shipment
The error of f itself is 1.0 ppm. (H) 0.278 pp error included in factory settings
m. (I) 0.111 ppm error due to the resolution of the general-purpose timer 104 after factory shipment. (J) Error due to resolution of RTC correction value 1.526 pp
m.

【0057】(k)原発振の10〜55℃での温度偏差
3.0ppmによる工場出荷設定時と工場出荷後の補正
時の差の最悪値6.0ppm。 (l)水晶の経年変化2.0ppm。 以上(g)、(h)、(i)、(j)、(k)、(l)
を合計すると総合的な最大誤差は10.915ppmで
あり、日差±1秒(誤差11.574ppm)以内であ
る。
(K) The worst value of 6.0 ppm, which is the difference between the factory shipment setting and the correction after the factory shipment due to the temperature deviation of 3.0 ppm at 10 to 55 ° C. of the original oscillation. (L) Aging change of crystal is 2.0 ppm. Above (g), (h), (i), (j), (k), (l)
The total maximum error is 10.915 ppm, which is within ± 1 second per day (error 11.574 ppm).

【0058】なお、第1、第2の実施の形態では、AT
水晶振動子13の発振周波数を直接測定する代わりに、
AT水晶振動子13の原発振を分周したクロックをカウ
ントしているが、AT水晶振動子13の原発振又は原発
振を分周したクロックの周波数を測定して、誤差補正機
能付きRTCの誤差を求めるようにしてもよい。
In the first and second embodiments, the AT
Instead of directly measuring the oscillation frequency of the crystal unit 13,
Although the clock obtained by dividing the original oscillation of the AT crystal oscillator 13 is counted, the frequency of the original oscillation of the AT crystal oscillator 13 or the frequency of the clock obtained by dividing the original oscillation is measured to determine the error of the RTC with the error correction function. May be requested.

【0059】[0059]

【発明の効果】本発明によれば、使用温度範囲内で第1
の振動源より平坦な温度特性を有する第2の振動源の発
振周波数を、初期時のみ入力される基準クロックを計時
の源として測定し、測定した発振周波数を記憶する初期
時測定手順と、第2の振動源の発振周波数を、リアルタ
イムクロックを計時の源として測定する実使用時測定手
順と、実使用時測定手順で測定した発振周波数と初期時
測定手順で記憶した発振周波数との差分からリアルタイ
ムクロックの誤差が最小となる補正値を算出し、補正値
をリアルタイムクロック回路に設定する設定手順とを実
行するようにしたことにより、高精度の時刻補正を実現
でき、高精度のリアルタイムクロックを生成することが
できる。その結果、リアルタイムクロック回路とその時
刻補正装置を例えば設備コントローラに搭載すれば、設
備のスケジュール運転を行う際の時間ずれが少なくな
り、信頼性の高いシステムを提供することができる。
According to the present invention, within the operating temperature range, the first
The oscillation frequency of the second oscillation source having a flatter temperature characteristic than that of the oscillation source, the reference clock that is input only at the initial time is measured as a timing source, and the measured oscillation frequency is stored. The real-time measurement procedure for measuring the oscillation frequency of the vibration source of 2 as a real-time clock source and the difference between the oscillation frequency measured in the actual measurement procedure and the oscillation frequency stored in the initial measurement procedure By calculating the correction value that minimizes the clock error and performing the setting procedure to set the correction value in the real-time clock circuit, high-precision time correction can be realized and a high-precision real-time clock is generated. can do. As a result, if the real-time clock circuit and its time correction device are mounted on, for example, an equipment controller, a time lag when performing scheduled operation of equipment is reduced, and a highly reliable system can be provided.

【0060】また、第2の振動源の発振周波数を測定す
る代わりに、第2の振動源の発振をカウントすること
で、同様に高精度の時刻補正を実現でき、高精度のリア
ルタイムクロックを生成することができる。
Further, by counting the oscillation of the second vibration source instead of measuring the oscillation frequency of the second vibration source, similarly highly accurate time correction can be realized and a highly accurate real time clock is generated. can do.

【0061】また、実使用時測定手順の測定時間を測定
の分解能より大きくすることにより、測定の分解能によ
る誤差を小さくすることができる。
Further, by making the measurement time of the actual use measurement procedure longer than the measurement resolution, the error due to the measurement resolution can be reduced.

【図面の簡単な説明】[Brief description of drawings]

【図1】 本発明の第1の実施の形態となる電子機器の
構成を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of an electronic device according to a first embodiment of the present invention.

【図2】 水晶振動子の温度特性を示す図である。FIG. 2 is a diagram showing temperature characteristics of a crystal unit.

【図3】 本発明の第2の実施の形態となる電子機器の
構成を示すブロック図である。
FIG. 3 is a block diagram showing a configuration of an electronic device according to a second embodiment of the present invention.

【符号の説明】[Explanation of symbols]

1、11…音叉型水晶振動子、2、12…誤差補正機能
付きRTC、3、13…AT水晶振動子、4…カウン
タ、5、15…メモリ、6、16…CPU、17…デジ
タル入力回路、101…プロセッサ・コア、102…メ
モリ・コントローラ、103−1、103−2…32ビ
ットタイマ、104…汎用タイマ、105…インタフェ
ース、106…内部バス・インタフェースユニット、1
07…外部バス・インタフェースユニット。
1, 11 ... Tuning fork type crystal oscillator, 2, 12 ... RTC with error correction function, 3, 13 ... AT crystal oscillator, 4 ... Counter, 5, 15 ... Memory, 6, 16 ... CPU, 17 ... Digital input circuit , 101 ... Processor core, 102 ... Memory controller, 103-1, 103-2 ... 32-bit timer, 104 ... General-purpose timer, 105 ... Interface, 106 ... Internal bus interface unit, 1
07 ... External bus interface unit.

Claims (6)

【特許請求の範囲】[Claims] 【請求項1】 第1の振動源の発振を所定数カウントし
た期間を単位時間としてリアルタイムクロックを生成す
るリアルタイムクロック回路に対し、補正値を設定し
て、この補正値に応じて前記所定数を増減させて前記リ
アルタイムクロックを補正するリアルタイムクロックの
時刻補正方法において、 使用温度範囲内で前記第1の振動源より平坦な温度特性
を有する第2の振動源の発振周波数を、初期時のみ入力
される基準クロックを計時の源として測定し、測定した
発振周波数を記憶する初期時測定手順と、 前記第2の振動源の発振周波数を、前記リアルタイムク
ロックを計時の源として測定する実使用時測定手順と、 前記実使用時測定手順で測定した発振周波数と前記初期
時測定手順で記憶した発振周波数との差分から前記リア
ルタイムクロックの誤差が最小となる前記補正値を算出
し、この補正値を前記リアルタイムクロック回路に設定
する設定手順とを実行することを特徴とするリアルタイ
ムクロックの時刻補正方法。
1. A correction value is set for a real-time clock circuit that generates a real-time clock with a period of counting a predetermined number of oscillations of a first vibration source as a unit time, and the predetermined number is set according to the correction value. In a real-time clock time correction method for increasing and decreasing to correct the real-time clock, an oscillation frequency of a second vibration source having a flatter temperature characteristic than the first vibration source within an operating temperature range is input only at an initial stage. Initial measurement procedure of measuring a reference clock as a timing source and storing the measured oscillation frequency, and an actual use measurement procedure of measuring the oscillation frequency of the second vibration source as the real-time clock as a timing source. And the difference between the oscillation frequency measured in the actual use measurement procedure and the oscillation frequency stored in the initial measurement procedure, the real time A time correction method for a real-time clock, wherein the correction value that minimizes the clock error is calculated, and a setting procedure for setting the correction value in the real-time clock circuit is executed.
【請求項2】 第1の振動源の発振を所定数カウントし
た期間を単位時間としてリアルタイムクロックを生成す
るリアルタイムクロック回路に対し、補正値を設定し
て、この補正値に応じて前記所定数を増減させて前記リ
アルタイムクロックを補正するリアルタイムクロックの
時刻補正方法において、 使用温度範囲内で前記第1の振動源より平坦な温度特性
を有する第2の振動源の発振を、初期時のみ入力される
基準クロックを計時の源として所定の測定時間中カウン
トし、測定したカウント値を記憶する初期時測定手順
と、 前記第2の振動源の発振を、前記リアルタイムクロック
を計時の源として所定の測定時間中カウントする実使用
時測定手順と、 前記実使用時測定手順で測定したカウント値と前記初期
時測定手順で記憶したカウント値との差分から前記リア
ルタイムクロックの誤差が最小となる前記補正値を算出
し、この補正値を前記リアルタイムクロック回路に設定
する設定手順とを実行することを特徴とするリアルタイ
ムクロックの時刻補正方法。
2. A correction value is set for a real-time clock circuit that generates a real-time clock with a period of counting a predetermined number of oscillations of the first vibration source as a unit time, and the predetermined number is set according to the correction value. In a time correction method of a real-time clock that increases or decreases to correct the real-time clock, the oscillation of a second vibration source having a flatter temperature characteristic than the first vibration source within an operating temperature range is input only at an initial stage. An initial measurement procedure for counting a reference clock as a time source during a predetermined measurement time and storing the measured count value, and an oscillation of the second vibration source for a predetermined measurement time with the real-time clock as a time source. Medium-count actual measurement procedure, count value measured in the actual measurement procedure, and count value stored in the initial measurement procedure And a setting procedure for setting the correction value in the real-time clock circuit so that the correction value that minimizes the error in the real-time clock is executed, and a time correction method for the real-time clock.
【請求項3】 請求項1又は2記載のリアルタイムクロ
ックの時刻補正方法において、 前記実使用時測定手順の測定時間を測定の分解能より大
きくすることを特徴とするリアルタイムクロックの時刻
補正方法。
3. The time correction method for a real-time clock according to claim 1, wherein the measurement time of the actual-use measurement procedure is set larger than the resolution of measurement.
【請求項4】 第1の振動源の発振を所定数カウントし
た期間を単位時間としてリアルタイムクロックを生成す
ると共に、設定された補正値に応じて前記所定数を増減
させて前記リアルタイムクロックを補正する誤差補正機
能付きリアルタイムクロック回路と、 使用温度範囲内で前記第1の振動源より平坦な温度特性
を有する第2の振動源と、 前記第2の振動源の発振周波数を、初期時のみ入力され
る基準クロックを計時の源として測定する初期時測定手
段と、 この初期時測定手段で測定された発振周波数を記憶する
記憶手段と、 前記第2の振動源の発振周波数を、前記リアルタイムク
ロックを計時の源として測定する実使用時測定手段と、 この実使用時測定手段で測定された発振周波数と前記記
憶された発振周波数との差分から前記リアルタイムクロ
ックの誤差が最小となる前記補正値を算出し、この補正
値を前記誤差補正機能付きリアルタイムクロック回路に
設定する設定手段とを有することを特徴とするリアルタ
イムクロックの時刻補正装置。
4. A real-time clock is generated with a period in which a predetermined number of oscillations of the first vibration source are counted as a unit time, and the real-time clock is corrected by increasing or decreasing the predetermined number according to a set correction value. A real-time clock circuit with an error correction function, a second vibration source having a flatter temperature characteristic than the first vibration source within an operating temperature range, and an oscillation frequency of the second vibration source are input only at an initial stage. Initial measurement means for measuring a reference clock as a time source, storage means for storing the oscillation frequency measured by the initial measurement means, and the oscillation frequency of the second vibration source for measuring the real time clock. The actual-use measuring means for measuring as the source of the rear-use and the difference between the oscillation frequency measured by the actual-use measuring means and the stored oscillation frequency, It calculates the correction value error is minimal time clock, the time correction apparatus of the real-time clock; and a setting means for setting the correction value to the error correcting function real-time clock circuit.
【請求項5】 第1の振動源の発振を所定数カウントし
た期間を単位時間としてリアルタイムクロックを生成す
ると共に、設定された補正値に応じて前記所定数を増減
させて前記リアルタイムクロックを補正する誤差補正機
能付きリアルタイムクロック回路と、 使用温度範囲内で前記第1の振動源より平坦な温度特性
を有する第2の振動源と、 前記第2の振動源の発振を、初期時のみ入力される基準
クロックを計時の源として所定の測定時間中カウントす
る初期時測定手段と、 この初期時測定手段で測定されたカウント値を記憶する
記憶手段と、 前記第2の振動源の発振を、前記リアルタイムクロック
を計時の源として所定の測定時間中カウントする実使用
時測定手段と、 この実使用時測定手段で測定されたカウント値と前記記
憶されたカウント値との差分から前記リアルタイムクロ
ックの誤差が最小となる前記補正値を算出し、この補正
値を前記誤差補正機能付きリアルタイムクロック回路に
設定する設定手段とを有することを特徴とするリアルタ
イムクロックの時刻補正装置。
5. A real-time clock is generated with a period in which a predetermined number of oscillations of the first vibration source are counted as a unit time, and the real-time clock is corrected by increasing or decreasing the predetermined number according to a set correction value. A real-time clock circuit with an error correction function, a second vibration source having a flatter temperature characteristic than the first vibration source within an operating temperature range, and an oscillation of the second vibration source are input only at an initial stage. An initial measurement means for counting a reference clock as a time source during a predetermined measurement time, a storage means for storing a count value measured by the initial measurement means, and an oscillation of the second vibration source for the real time An actual-use measuring means that counts for a predetermined measuring time using a clock as a time source, and a count value measured by the actual-use measuring means and the stored value. The difference between the real-time clock and the error value of the real-time clock is calculated from the difference between the real-time clock circuit and the real-time clock circuit having the error correction function. Time correction device.
【請求項6】 請求項4又は5記載のリアルタイムクロ
ックの時刻補正装置において、 前記実使用時測定手段の測定時間を測定の分解能より大
きくすることを特徴とするリアルタイムクロックの時刻
補正装置。
6. The time correction device for a real-time clock according to claim 4 or 5, characterized in that the measurement time of said actual-use measuring means is made larger than the resolution of measurement.
JP2002077722A 2002-03-20 2002-03-20 Time correction method and time correction device for real time clock Pending JP2003270369A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002077722A JP2003270369A (en) 2002-03-20 2002-03-20 Time correction method and time correction device for real time clock

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002077722A JP2003270369A (en) 2002-03-20 2002-03-20 Time correction method and time correction device for real time clock

Publications (1)

Publication Number Publication Date
JP2003270369A true JP2003270369A (en) 2003-09-25

Family

ID=29205820

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002077722A Pending JP2003270369A (en) 2002-03-20 2002-03-20 Time correction method and time correction device for real time clock

Country Status (1)

Country Link
JP (1) JP2003270369A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006349241A (en) * 2005-06-15 2006-12-28 With Mate:Kk Drive control device
WO2007094266A1 (en) * 2006-02-13 2007-08-23 National Institute Of Information And Communications Technology Distance measuring system
KR100948178B1 (en) 2008-01-24 2010-03-16 주식회사 유니크 Electron clock for vehicle enabling self correction and method of correcting the same
JP2015020351A (en) * 2013-07-19 2015-02-02 京セラドキュメントソリューションズ株式会社 Image forming apparatus and image forming method
US9548724B2 (en) 2013-03-26 2017-01-17 Seiko Epson Corporation Clock generation device, electronic apparatus, moving object, and clock generation method

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006349241A (en) * 2005-06-15 2006-12-28 With Mate:Kk Drive control device
WO2007094266A1 (en) * 2006-02-13 2007-08-23 National Institute Of Information And Communications Technology Distance measuring system
JP2007212420A (en) * 2006-02-13 2007-08-23 National Institute Of Information & Communication Technology Distance measuring system
US8279111B2 (en) 2006-02-13 2012-10-02 National Institute Of Information And Communications Technology Distance measuring system
KR100948178B1 (en) 2008-01-24 2010-03-16 주식회사 유니크 Electron clock for vehicle enabling self correction and method of correcting the same
US9548724B2 (en) 2013-03-26 2017-01-17 Seiko Epson Corporation Clock generation device, electronic apparatus, moving object, and clock generation method
JP2015020351A (en) * 2013-07-19 2015-02-02 京セラドキュメントソリューションズ株式会社 Image forming apparatus and image forming method

Similar Documents

Publication Publication Date Title
KR100687230B1 (en) Real time clock apparatus and the real time compensating method thereof
JP4950922B2 (en) Time device and portable electronic device
JP2624176B2 (en) Electronic clock and time correction method
WO2006090831A1 (en) Clock signal outputting device and its control method, and electronic device and its control method
US4708491A (en) Time of day clock
CN107831647B (en) Positioning device, electronic timepiece, positioning control method, and storage medium
JP2007078405A (en) Timing program of software timepiece
JP5228392B2 (en) Temperature compensated oscillation circuit, real-time clock device and electronic equipment
JP2006309479A (en) Clock correction circuit, clock correction method, and microcontroller
EP2525265B1 (en) Method of operation of a timepiece device
US4761771A (en) Electronic timekeeping apparatus with temperature compensation and method for compensating same
US6747374B2 (en) Circuit for correcting deviation in oscillating frequency
JP2000199792A (en) Time piece and time correction method
JP2003270369A (en) Time correction method and time correction device for real time clock
JPH0856153A (en) Oscillation circuit having frequency correction function
US7679466B1 (en) Counter-based resonator frequency compensation
JP2002016438A (en) Crystal oscillation circuit, clock device and measuring instrument
JP4711546B2 (en) Temperature correction method for real-time clock and processing device provided with real-time clock
JP2017020852A (en) Embedded device
US4730286A (en) Circuit and method for correcting the rate of an electronic timepiece
KR20170093356A (en) Method for adjusting time information of real time clock device in programmable logic controller and the programmable logic controller
US8630386B2 (en) Clock recovery in a battery powered device
JP2896004B2 (en) Calendar iC correction method
JPH1114775A (en) Method for automatically correcting display time of electronic clock
JP2001217708A (en) Frequency oscillator

Legal Events

Date Code Title Description
A621 Written request for application examination

Effective date: 20041224

Free format text: JAPANESE INTERMEDIATE CODE: A621

A977 Report on retrieval

Effective date: 20060201

Free format text: JAPANESE INTERMEDIATE CODE: A971007

A131 Notification of reasons for refusal

Effective date: 20060704

Free format text: JAPANESE INTERMEDIATE CODE: A131

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20060904

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20061031