ATMega Oscillator Stability

Now that I have my HP 5328A frequency counter up and running, I figured I'd show you the contrast between the stability of the internal RC oscillator built into the ATMega328 (the brains of the Arduino) and the external 16MHz crystal that you usually need to use with it.

Video:


Datasheets referenced in the video are for the ATMega328P and a random 16MHz crystal I found on Digikey.  I bought the specific crystal used for this demo on eBay, so I know almost nothing about it, but these crystals are usually rated in the range of 20-50ppm.

The two avrdude commands I used were:
avrdude -p m328p -c usbtiny -U lfuse:w:0x86:m -U hfuse:w:0xd9:m
avrdude -p m328p -c usbtiny -U lfuse:w:0xa2:m -U hfuse:w:0xd9:m

This really demonstrates how both oscillators, but particularly the internal one, are very sensitive to temperature changes around the microcontroller.  This is why my counter's oscillator is contained in a small oven, such that it's held at a specific elevated temperature and doesn't change temperature along with the room.  Another compensation option is to not try and control temperature (which takes a lot of power), but instead merely compensate for it.  High-end real time clocks such as the DS3232 do this, by measuring the ambient temperature and trying to compensate the crystal in the other direction.  It's better than nothing, but this does still introduce uncertainty.

When buying this counter, I specifically looked for one with the HPIB  option on the back, because it means that I will eventually be able to connect this meter up to my computer and take these measurements over a LONG period of time.  Once that is possible, we can start asking more subtle stability questions about better oscillators, such as real time clocks, and even my Rb reference.

Popular Posts