0
\$\begingroup\$

I would like to do precise timing of events which trigger hardware interrupts on a microcontroller. I am aware of the stability issues associated with microcontroller oscillators and I think a 30ppm (or smaller) stability in 50 MHz (or greater) oscillator will be good enough for my project. But an oscillator can be very stable and yet be inaccurate as a time keeper because the frequency of oscillator may not be what one thinks it is. So my question is: How does one go about calibrating the external oscillator of a microcontroller board?

Thank you!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Why don't you use one of the really accurate (factory calibrated) canned oscillators? \$\endgroup\$ Nov 5 '14 at 19:19
  • \$\begingroup\$ Here's an answer to a closely-related question \$\endgroup\$
    – Dave Tweed
    Nov 5 '14 at 20:19
  • \$\begingroup\$ Wouter. Can you give a manufacturer and part number? \$\endgroup\$
    – D_J_S
    Nov 5 '14 at 20:37
  • \$\begingroup\$ I think the search term is TCXO (Temperature Controller Crystal Oscillator). KT7050A20000KAW33TAD is an example at Mouser. \$\endgroup\$ Nov 6 '14 at 6:31
2
\$\begingroup\$

If you are willing to do the measurement over a period of time (one midnight to the next), the frequency of the US power grid is maintained to exactly 60 Hz over a 24-hour period as discussed here. The frequency will vary during the day, but it is trimmed at the end of the day so that exactly 5,184,000 (60*60*60*24) cycles will occur from one midnight to the next.

To count this, you will need a zero-crossing detector. There are many such circuits on the web, here's a fairly simple one:

enter image description here

Count up how many cycles your clock is putting out in 24 hours (perhaps after going through a divider), and then compare those counts with the counts off the power lines.

Run this the first time and it will give you the frequency. Run it another day and it will give you the drift.

\$\endgroup\$
1
  • \$\begingroup\$ Right, and also the power grid(s) in Europe are calibrated to be exactly 50 Hz over a 24-hour period. During daytime it's allowed to slow down a bit because the loads are high; at nighttime it's run a bit faster to compensate for the daytime. The reason is that there's a plethora of different tariff clocks/grid control gizmos/whatever devices in the grid, that take their timing reference from the grid's frequency and this way they keep their time for extended periods of time. \$\endgroup\$
    – PkP
    Nov 6 '14 at 16:36
1
\$\begingroup\$

Let me expand a bit on tcrosley's excellent answer from yesterday. Let's define first how accurate you wish to be. You say 30 ppm, so that means more accurate than two seconds (exactly 2.592 seconds) drift per 24 hours.

You could follow tcrosley's idea of locking on to the power grid. And with it, you could do continual adjustment of the device if it's continuously connected to the grid.

There's a couple of other alternatives. You could use GPS time. There's an excellent article "The Science of Timekeeping", which is Hewlett-Packard's Application Note 1289 and by quick googling, it's available for example here. Did you know that Hewlett-Packard started by doing oscillators and frequency counters?

Using the atomic clock provided by GPS might be easier than you think. Your computer might already use NTP protocol to keeping its time in sync with UTC. If not, you can install a NTP client to your computer. NTP servers generally derive their time from GPS atomic clocks and in any case the accuracy is way better than 2 seconds per day. So calibrating (checking) the speed of the microcontroller's oscillator might be as simple as sending the microcontroller's "time" periodically to a PC and writing a small PC application to display the time and compare that to the PC's NTP corrected time.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you very much for the link to the "Science of Timekeeping" article. And I will consider GPS. \$\endgroup\$
    – D_J_S
    Nov 6 '14 at 20:42
0
\$\begingroup\$

The most standard way to characterize and calibrate self-made oscillators is to use proper calibration instruments, like frequency counters with a stable time base (say, Rubidium clock). Example of affordable tool is Stanford Research SR625 Frequency Counter. The tool is accurate to 0.1ppb (part per Billion), if I calculated this correctly. The price tag is just $7k, but you can rent it for a lot less.

\$\endgroup\$
-1
\$\begingroup\$

U can use DFLL(Digital frequency locked loop) with RTC clock or any external cheap crystals with less ppm, given as input to the DFLL, to calibrate the microcontroller. From my personal experience, Atmel's ATXMega series would give u variety of controllers with reliable internal oscillator.

There is also a PLL inside some micro-controllers. U can connect a one second accurate clock (a RTC clock) and multiply it with a factor of 1-31, so that to get an accurate system clock

Atmel XMega:

  1. In-built DFLL circuitry.
  2. In-built PLL circuitry.
  3. Factory calibrated internal 2MHz oscillator.
  4. Factory calibrated internal 32.768 KHz RTC oscillator.
  5. 32MHz run-time calibrated and tuneable oscillator

For calibrating the clock source refer this datasheet. U can get some ideas by clicking here

\$\endgroup\$
2
  • \$\begingroup\$ I was thinking of using the TI Hercules Launchpad and it's external oscillator in this project. I don't think any internal oscillator (crystal or RC) on a commercial uCon can do better than the accuracy of the oscillator I am trying to calibrate. Am I wrong? I am newbie. \$\endgroup\$
    – D_J_S
    Nov 5 '14 at 19:49
  • \$\begingroup\$ @D_J_S External oscillator will always do better than internal oscillators. There is a trade-off between reliability and accuracy. U can rely on internal osc but for high accuracy u go for external oscillator. For cost effective solution and high accuracy, u can use external RTC 32.768 KHz and internal PLL multiplier. RTC crystals \$\endgroup\$
    – gzix
    Nov 6 '14 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.