FIELD OF THE INVENTION
The present invention relates generally to devices that measure time.
BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 illustrates a time measurement system 100, according to one embodiment of the invention.
FIG. 2 illustrates a method of implementing an oscillator, according to one embodiment of the invention.
FIG. 3 illustrates a method of using the time measurement system 100, according to one embodiment of the invention.
DESCRIPTION OF EMBODIMENTS OF THE INVENTION
FIG. 1 illustrates an application system 100, according to one embodiment of the invention. The system 100 uses two oscillator circuits to be used in an accurate time measurement, while conserving energy. The system 100 can be used in any device that needs to measure time, such as a battery management system (e.g., state of charge monitor), or a clock. The system 100 can be used to provide an accurate, but also low power time measurement. In one embodiment of the invention, the system includes a first oscillator 105 and a second oscillator 110, which are of different qualities. The first oscillator 105 consumes lower power than the second oscillator 110, but is less accurate in time measurement. In one embodiment, the first oscillator 105 runs continuously. For example, if used in a battery management system, the first oscillator 105 would run continuously, regardless of whether the battery is sitting on a shelf or being actively used. In addition, in one embodiment, the power consumption of the first oscillator 105 is maintained low by running the first oscillator 105 at a frequency lower than the second oscillator 100, and thus minimizing the number of transitions of its output. For example, the frequency of the first oscillator 105 could be around 4 Hz. The first oscillator 105 is used by application processor 115 time measurement for the particular application being implemented, such as a battery management system. The second oscillator 110 consumes more power than the first oscillator 105, but is more accurate in time measurement. In one embodiment, the second oscillator 110 is capable of being disabled and consumes negligible power when disabled. The second oscillator 110 may also be of a higher frequency than the first oscillator 105. For example, its frequency could be between 1 kHz and 10 MHz. The application processor 115 has a time management controller 120 and a counter 125. Periodically, the second oscillator 110 is turned on by the time management controller 120 and is used to measure the period or frequency of the first oscillator 105 by counter 125 counting the output of second oscillator 110 between selected transitions of the output of first oscillator 105. This accurately measured period of the first oscillator 105 is then used by the time management controller 120 to compensate the first oscillator 105 to a more correct time measurement.
First oscillator 105 can be of the simple form illustrated in FIG. 2. Second oscillator 110 can be a higher accuracy crystal oscillator. Note that multiple other methods of implementing the oscillators may be used. For example, the first oscillator 105 can comprise, but is not limited to: a low frequency resistor/capacitor (RC) oscillator, a relation oscillator, and/or a trimmable RC oscillator. As other examples, the second oscillator 110 can comprise, but is not limited to: a crystal oscillator (e.g., >1 MHz) and/or a ceramic resonator (e.g., >1 MHz).
FIG. 3 illustrates a method of using the system 100, according to one embodiment of the invention. This method provides for an accurate time measurement using the first and second oscillators 105 and 110. By periodic compensation of the first oscillator 105 by the second oscillator 110, the overall system power consumption is minimized while still keeping an accurate time measurement. This element is useful in devices that need a low-power accurate clock, such as in a battery state-of-charge (SOC) monitor, a low-power clock, systems with both active and sleep states where the elapsed time of the sleep state needs to be accurately known, etc.
Turning to FIG. 3, in step 305, a designated interval N is determined, upon which the second oscillator 110 is activated so that it can be used to measure the first oscillator 105. The interval N can be determined by a user. Alternatively, the time management controller 120 may determine this interval N according to multiple algorithms.
For example, in one embodiment, a fixed time interval N can be used. The interval N may, for example, be the period of time in which 256 rising edges of the output of the first oscillator 105 occurs.
In another embodiment, the time management controller 120 can adjust the interval N by determining if the change in the period of time of the first oscillator 105 since the last transition is within an acceptable error margin. If so, then the interval N between measurements can be increased, such as by doubling, tripling, etc. the period of time between measurements to 2N, 3N, etc. Conversely, if the change in the period of time of the first oscillator 105 since the last measurement is outside an acceptable error margin, the interval N between measurements is decreased, such as by halfing, thirding, etc. the period of time between measurements to ½N, ⅓N, etc. This algorithm may be used repeatedly such that the intervals between measurements can become very long (for the case where the environment and hence the first oscillator 105 is stable), or very short (for the case where the environment and hence the first oscillator 105 is rapidly changing). This algorithm may be thought of as expending just enough power in order to stay within the desired frequency error budget of the first oscillator 105.
In an additional embodiment, the time management controller 120 can anticipate the amount which a time measurement will change over an interval N. This is accomplished by looking at the amount the time measurement has changed between intervals in the past and assuming the same amount of change will occur in the future. In this way, the time management controller 120 can anticipate the drift that will occur over the period of time, and adjust the system 100 accordingly.
In step 310, at the designated interval, the second oscillator 110 is enabled and the counter 125 is reset. In step 315, the counter 125 is incremented using the output of the second oscillator 110. In step 320, when the time management system 115 detects a designated transition of the first oscillator 105 to define a period of time, e.g., the next rising edge, it disables the second oscillator 110 or stops the counter 125. In step 325, the number stored in the counter 125 is now an accurate measure of the period of time between successive rising edges of the first oscillator 105. Thus, the frequency or period of the first oscillator 105 is now accurately known. In step 330, this accurate value of the frequency or period is used in the time management controller 120 and application processor 115. This accurate measurement can be used in any application that needs an accurate low-power time measurement. For example, in a battery management system, the accurate value can be used in the algorithms for integrating current over a period of time in order to measure charge drained from the battery.