Internal Crystal drift calculation help

Hey All,

I'm trying to figure out how much in time the internal 8Mhz clock drifts in an hour in the Atmega328p. I've read that it is +/- 10% but I'm not sure how to do the calculation to get that into a measurement of time.

I'm just trying to compare it to an external 8Mhz clock for my current project and for future reference so I can easily figure out if I need one or not depending on the time sensitivity.

If you could layout the math for me I'd appreciate it. I like to learn to fish.

It depends on the temperature and voltage. The ATmega328P can read its own temperature and its own VCC voltage. It is possible to calculate that and compensate it to the OSCCAL register. I have done that once, to get a more precise bit rate. Atmel has a number of papers on the calibration of the internal oscillator.

I don't know in what way you have that 8MHz and how you want to compare it. With a logic analyzer ? or should the Arduino calculate its own drift ? How can it read the 8MHz ?

It won't drift 10%. You can find what you're interested in from the datasheet.

I was curious about the stability as well and took the time to measure it for one particular 328. In addition to the voltage and temperature drift there is also a fair amount of jitter, something around ±0.1%.

Look here for some details:

I was hoping to use the internal temperature and voltage measurements to compensate the frequency and get something useable for my project. It shouldn't be too hard to come up with a simple formula, but you'd need to calibrate it for each part.

I decided instead to use a 32.768Khz quartz crystal and the asynchronous timer for precision purposes, and just let the internal 8MHz system clock wax and wane with temperature and voltage changes.