Go Down

### Topic: Internal Crystal drift calculation help (Read 828 times)previous topic - next topic

#### Drewski

##### Jun 27, 2015, 03:59 pmLast Edit: Jun 27, 2015, 04:00 pm by Drewski
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.

#### Peter_n

#1
##### Jun 27, 2015, 04:45 pmLast Edit: Jun 27, 2015, 04:46 pm by Peter_n
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 ?

#### jboyton

#2
##### Jun 27, 2015, 08:28 pmLast Edit: Jun 27, 2015, 08:36 pm by jboyton
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: http://forum.arduino.cc/index.php?topic=322538.msg2240887#msg2240887

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.

Go Up