Temperature fluctuation is a significant cause of frequency drift of crystal, and that makes temperature compensation crucial in RTCs.
As mentioned in part 1 of this series, temperature fluctuation is the most significant cause of frequency drift of crystal. There are a few options a system engineer can consider to mitigate this problem.
RTC with calibration register
For applications that operate in an environment where the temperature is stable, but the average temperature is not 25°C, an real-time clock (RTC) with calibration register may be used to correct the time. The concept is to add or subtract counts from the clock counter to speed up or slow down the clock. The amount of positive or negative counts required to correct the time can be calculated using the crystal frequency formula provided by the crystal supplier.
A system designer may also use such an RTC in conjunction with an external temperature sensor. Based on the output of the temperature sensor, a microcontroller can adjust the count value periodically. However, this approach has many disadvantages.
First, an extra temperature sensor will increase the system cost and take up more board space. Second, the microcontroller will need to adjust the calibration register periodically, and that will increase the overhead of the microcontroller. Third, the crystal frequency formula may not very accurately reflect the actual temperature response of the crystal because each crystal can be slightly different than others and the crystal frequency formula only represents the typical case. For high-accuracy applications, this solution may not be acceptable.
TCXO as clock source
A temperature-compensated crystal oscillator (TCXO) combines an oscillating crystal, temperature sensor, and digital logic in a single package. Its output frequency error is very low over the full operating temperature range. Simply connect the output of the TCXO to the crystal input or the clock input of the RTC to drive the timekeeping logic. This solution does not require a microcontroller to correct the time, but it still has board space, high cost, and higher power consumption issues.
RTC with integrated TCXO
A highly accurate RTC can be formed by integrating a temperature sensor, crystal, load capacitors, and temperature-compensation circuitries. This type of RTC’s accuracy specification is typically around 5 ppm or lower over the operating temperature range from -40 to 85°C for industrial grade, or -40 to 125°C for automotive grade. It saves board space, power, and microcontroller resources.
As discussed previously, other than the temperature, the RTC also needs to know the crystal’s temperature response characteristic in order to correct the frequency error. This information can be acquired from calibration process during manufacturing. Although crystal suppliers provide an equation to calculate the typical frequency, each crystal may have slightly different characteristics. At room temperature, a typical crystal can have up to 20 ppm of error.
Every RTC should be calibrated individually in order to achieve the highest accuracy performance. So, during the calibration process, the frequency of a crystal is measured at multiple different temperature points. Obviously, the more calibration points are measured, the better the measurement data will match the actual frequency-temperature characteristic curve.
During calibration, every time before a new measurement is made, the test engineer needs to change the temperature of the test chamber or move the wafer to a different chamber with a preset temperature. A measurement can be made after the temperature of the wafer reaches equilibrium. For these reasons, manufacturers don’t want to make a large number of measurements because that will dramatically increase the test time and, hence, the cost of the device.
Design engineers often use interpolation methods to reconstruct the frequency-temperature curve with the limited measured data points. Take the case when a designer takes into consideration a second-order equation, such as:
f is the frequency
t is the temperature
a, b, c are coefficients
It’s a good-enough approximation of the crystal’s frequency-temperature curve to satisfy the required accuracy specifications, so an engineer simply needs three data points measured at different temperature points to solve the three coefficients. For any kind of interpolation, the error is minimal at the given data points. The calculation will deviate more from the real curve as the input parameter is further away from the given data points. Therefore, the temperature of the measurements should be spaced out. Picking the temperature points at minimum, room, and maximum in this case is a reasonable choice.
Now, with the interpolation formula and a temperature sensor, the RTC knows “exactly” how far off the actual oscillator frequency is from the ideal 32.768 kHz. But how does the RTC correct the frequency? Using the calibration register as discussed previously is one possible method, but it is rarely implemented in an RTC with an integrated crystal. In the RTC with the external resonator section noted above, there are a few factors that can affect the crystal oscillation frequency.
One of them is the load capacitor. By manipulating the load capacitor, the temperature compensation circuit can precisely increase or decrease the oscillation frequency. An example of the variable capacitor would be a simple capacitor array plus a set of switches that disconnects or connects the capacitors in parallel.
A temperature sensor consumes lots of power compared to all of the other components inside the RTC. The more often the sensor is turned on, the higher the average overall current of the RTC will be. How often to measure the temperature and run the compensation algorithm depends on the needs of the operating environment. Some RTCs provide options for the user to set the appropriate temperature measurement interval.
Here is one example of an RTC with an integrated TCXO and crystal. DS3231SN features an accuracy specification that supports a maximum 3.5 ppm across the entire operating temperature range of -40° to 85°C, but only 2 ppm from 0° to 40°C. Figure 1 shows a plot conveying the accuracy difference between a TCXO and typical crystal oscillator.
Figure 1 A comparison between DS3231SN and typical crystal oscillator highlights the accuracy gains obtained by using the RTC with an integrated TCXO. Source. Maxim Integrated
RTC with integrated MEMS resonator
An RTC with integrated TCXO seems like a perfect solution; however, it still has some weaknesses. An RTC with integrated 32.768 kHz crystal is too bulky for wearables or other small form-factor applications. Crystal suppliers cannot reduce the size of the crystal because the frequency dictates its size. To further reduce the size, a different type of resonator can be used—namely, RTC with an integrated MEMS resonator.
MEMS is a very small electromechanical device that vibrates and generates highly stable reference frequency. The newer generation MEMS is much less sensitive to temperature change than crystals. Its mass is thousands of times smaller than a crystal. And because a MEMS resonator weighs much less, it is more resilient against vibration and mechanical shock. The MEMS resonator is mounted to the IC die, so the overall package size can be nearly as small as the die size.
The MEMS resonator generally consumes more power than a crystal resonator. The designer may reduce the power consumption by maximizing the impedance of the MEMS resonator so that the current consumption will be lower. The equivalent impedance is:
The impedance becomes the highest when CL approaches 0, and in this case, the resonator operates near its parallel resonance frequency. It will reduce the current and power consumption; however, a load capacitor will not be useful to adjust the oscillation frequency for temperature compensation simply because there will not be a load capacitor.
Since the output frequency of the oscillator cannot be changed by increasing or decreasing the load capacitance, the design engineer needs to implement a different method to adjust the frequency before feeding it into the RTC timekeeping logic. One solution is to insert a fractional divider in between the oscillator output and the RTC timekeeping clock input.
From an introductory digital design class, one might recall many methods to implement a clock divider that can divide by any positive integer number. A fractional divider can divide the clock by any fractional number. To understand the high-level concept of how a fractional divider works, let’s consider a very simple example. Assume the input clock is 100 Hz and the target is to get a 1-Hz output from that 100-Hz reference clock. We can simply divide the clock by 100.
Figure 2 A simple clock divider cannot produce a precise output frequency between 0.999 Hz and 1.009 Hz. Source. Maxim Integrated
What if the reference input clock is changed slightly from 100 Hz to 99.9 Hz? How can we generate 1 Hz from 99.9 Hz? We know that if the divisor is 100, the output will become 0.999 Hz; that is, slightly slower than 1 Hz. And if the divisor is 99, the output becomes 1.009 Hz; that is slightly faster than 1 Hz. Figure 3 shows the overlap of the divide-by-100 and divide-by-99 clock-out signals, and the ideal rising edge of the 1-Hz clock locates somewhere within the grey-zone area.
Figure 3 This diagram shows a divide-by-99 vs. divide-by-100 output clock operations. Source: Maxim Integrated
A simple clock divider cannot produce a precise output frequency between 0.999 Hz and 1.009 Hz. A fractional divider has a control circuit to modulate the divisor, so that its output clock frequency can switch between 0.999 Hz and 1.009 Hz. If the occurrence ratio between the two divisor values is carefully designed, the divider can theoretically generate an average of any frequency between 0.999 Hz and 1.009 Hz over time. Although each clock cycle is not an accurate 1-Hz clock cycle, the averaged output clock over time can be highly accurate.
Let x be the number of occurrences of 0.999 Hz clock and y be the number of occurrences of 1.009 Hz clock. To calculate the correct ratio of x to y occurrences, an equation can be set up this way:
x is the number of occurrences of divide-by-100 clock cycle
y is the number of occurrences of divide-by-99 clock cycle
TDiv_100 is the period of one divide-by-100 clock cycle (TDiv_100 = 100/99.9 Hz in this example)
TDiv_99 is the period of one divide-by-99 clock cycle (TDiv_99 = 99/99.9 Hz in this example)
TTarget is the period of one targeting averaged clock cycle (TTarget=1 in this example)
By substituting all the period variables:
With this equation, after a few algebraic manipulations, the calculated ratio of x:y is 9:1. That means when the input clock of the fractional divider is 99.9 Hz, for every 9 divide-by-100 clocks, insert 1 divide-by-99 clock. Over a total of 10 clock cycles, the averaged frequency will be exactly 1 Hz. This 9:1 pattern will repeat continuously until the input frequency is changed. As discussed previously, the input frequency can be determined by a temperature-to-frequency conversion function or look-up table that is obtained from calibration.
Maxim Integrated’s MAX31343 is the smallest RTC in the industry with an integrated resonator. It has a built-in temperature sensor and fractional divider for temperature compensation and consumes only 970 nA of timekeeping current. It has a robust accuracy spec over an operating temperature range of less than 5 ppm, making it suitable for all kinds of applications, especially those that are space constrained and require high accuracy and robustness to survive mechanical vibration and shock.
This article was originally published on EDN.
Gordon Lee is principal member of the technical staff at Applications, Core Products Group at Maxim Integrated.