Go Down

Topic: Resonator Vs Crystal Vs Internal Resonator (Read 4468 times) previous topic - next topic

MiB1986

Hello,

can someone explain me to the differences, i dont mean phyisically i mean in terms of the arduino, if the atmel processors come with internal resonators why not use them...

Why are we still using crystals, yes they are more accurate but is it really that important when a resonator is so close?

I just dont see why we are using crystals, i know atmel processors have always worked best with crystals but why?

Hope you guys understand what i mean and dont think im being a pain :)

Many Thanks
Martyn


RuggedCircuits

It is a matter of accuracy and intended application. The built-in oscillator has three limitations: a) it can only work at 8 MHz, b) it is only accurate to about 1-2%, and c) it varies with temperature.

A resonator is better, with 0.5% typical accuracy, while a quartz crystal is 0.01% accurate. If you are keeping time, for example, that's the difference between being off by 3.6 hours at the end of one month, or being off by 4 minutes.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

MiB1986

hello,

thats exactly what i thought, but i thought resonators had improved, is there a simple counter code i can run on two atmega168 ics with a serial out, one with resonator one without just to see them drift apart, be an excellent piece of research to experience first hand, the serial out would allow me to check the value, so i could mointor their counting over say a day, week, a month ?

kindest regards
Martyn

RuggedCircuits

Sure, a simple piece of code like this should work:

Code: [Select]

unsigned long count;
void setup(void) {
  Serial.begin(38400);
  count=0;
}

void loop(void) {
  delay(1000);
  Serial.println(count++);
}


The key is that you will have to program the fuses differently on the two ATmega168 devices, one to use the internal oscillator and the other to use an external resonator.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

westfw

Note that the internal oscillator is not a "resonator"; it's just an RC circuit (calibrated.)  A ceramic resonator is more stable, and a quartz crystal even more so.  Without looking at spec sheets, I'd expect the temperature variations to follow the same rule...

MiB1986

Hello,

thankyou for the code, i will try this later,

based on the information above that the internal oscilator will only be 8MHz it will be too slow. But thanks for the comment, i will look i the datasheet later about the internal osciallator for future reference though.

So back to a Resonator VS Crystal, was plannig to use a 16Mhz crystal with 22pf caps, anyone got any better suggestions?

Will increaseing the caps to 39pf do anything really?, other than change the output wave shape a little. Has anyone tried changing the value of the caps if yes what happened?

Kindest Regards
Martyn

retrolefty

Quote
Will increaseing the caps to 39pf do anything really?, other than change the output wave shape a little. Has anyone tried changing the value of the caps if yes what happened?


  Changing the size of the loading capacitors will change the frequency very slightly up to the point where it may stop oscillating all together. Three terminal 16 MHz ceramic resonators have their caps built in so it can save component count and costs slightly at a slight cost of absolute frequency accuracy compared to a crystal resonator.


Lefty

Jack Christensen


So back to a Resonator VS Crystal, was planning to use a 16Mhz crystal with 22pf caps, anyone got any better suggestions?


Not sure if this is a better suggestion, or just different. It's what I do.

Know the recommended load capacitance for the crystal (on the datasheet), and calculate the load capacitors accordingly. Note that load capacitance is not the same thing as load capacitor value. See http://www.foxonline.com/techfaqs_cry.htm#a4

The crystals that I happen to use call for 18pF load capacitance, so depending on the assumption for stray capacitance (2-5pF), the load capacitors should be between 26pF and 32pF. I usually use 27pF. My crystals also seem to work fine with 18pF, 22pF, and even with no capacitors! But, I haven't done any measurements, nor have I tried varying temperature, voltage, etc. And I probably won't, unless I have problems. In the meantime, I'll stick with the manufacturer's recommendations.

I don't know where what I will call the "22pF myth" comes from, it seems to be the default value that everyone always uses. It doesn't help that the ATmega328 datasheet recommends "12 to 22pF". I do not understand how they can make such a recommendation without knowing the specs of the specific crystal in use. Atmel does a good job on their datasheets, but that part I do not get.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

retrolefty

Quote
The crystals that I happen to use call for 18pF load capacitance, so depending on the assumption for stray capacitance (2-5pF), the load capacitors should be between 26pF and 32pF. I usually use 27pF. My crystals also seem to work fine with 18pF, 22pF, and even with no capacitors!


I would think you would subtract the AVR stray capacitance value from the crystals recommended value, so 18 - (2 to 5) = 16 to 13 pf ? But as you said the actual value you use within a reasonable range doesn't seem to cause it not to oscillate. Only an accurate frequency counter with a very high impedenace (fet type) probe would give you the actual frequency it's running at.

Lefty


Jack Christensen


Quote
The crystals that I happen to use call for 18pF load capacitance, so depending on the assumption for stray capacitance (2-5pF), the load capacitors should be between 26pF and 32pF. I usually use 27pF. My crystals also seem to work fine with 18pF, 22pF, and even with no capacitors!


I would think you would subtract the AVR stray capacitance value from the crystals recommended value, so 18 - (2 to 5) = 16 to 13 pf ? But as you said the actual value you use within a reasonable range doesn't seem to cause it not to oscillate. Only an accurate frequency counter with a very high impedenace (fet type) probe would give you the actual frequency it's running at.

Lefty


See the formula in the link I included:
Quote
CL = ((C1 x C2) / (C1 + C2)) + Cstray


Now it's recommended that C1 = C2, so this reduces to:
       CL = (C / 2) + Cstray

Solve for C:
       C = 2(CL - Cstray)

Plug & chug:
       C = 2(18 - 5) = 26pF
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

MiB1986

Thank you so much for your replies,

I will set to work at making two boards one with resonator and one with a crystal...

May i ask where your quoting these tolerances from? and also how do they keep watches/clocks to keep time accurately then if crystals drift that much?

I will post back my findings if people are interested.

Kindest Regards
Martyn

Jack Christensen

Please do post your findings, always interested in such things.

Here is a crystal I use for a 16MHz system clock (with 27pF load caps). The tolerance, load capacitance, etc., can be found on the datasheet.  I also use these resonators, datasheet here.

For use with DS1307 RTCs I use this crystal ... datasheet.

The question about watch accuracy is a good one, there was some discussion around that not too long ago here on the forum, so I might do a search or two for that. I really don't know how they do it, but I wouldn't be surprised if there is some sort of calibration that happens on each unit as it comes off the assembly line.

I have a footprint in Eagle that will accommodate either the resonator or crystal, so I'll often do something like the attached so I will have the flexibility to choose a crystal, resonator, or even nothing and run from the internal oscillator.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

tim7

HereĀ“s some measurements of Arduino clock accuracy vs. temperature vs. clock-type:
http://arduino.cc/forum/index.php?topic=69316.15

MarkT


Note that the internal oscillator is not a "resonator"; it's just an RC circuit (calibrated.)  A ceramic resonator is more stable, and a quartz crystal even more so.  Without looking at spec sheets, I'd expect the temperature variations to follow the same rule...



Looking at the spec sheets recently it says the RC oscillator is +/-10% as it comes from the factory, yet can reach +/-1% after user calibration.  I think that means that factory calibration consists of writing the same value of OSCCAL into every chip on the wafer!!
[ I won't respond to messages, use the forum please ]

Jack Christensen


Looking at the spec sheets recently it says the RC oscillator is +/-10% as it comes from the factory, yet can reach +/-1% after user calibration.  I think that means that factory calibration consists of writing the same value of OSCCAL into every chip on the wafer!!


I have four ATmega328Ps running with the internal RC oscillator at 8MHz that seem to have no problem doing serial communication at 9600bps with whatever calibration comes from the factory. YMMV, I could very well just have a "good" batch. I'm just doing output, Serial.print() debug and informational stuff, but that seems to work fine.

Your post made me curious, so I checked OSCCAL and found all four were different, 0x9B, 0x9E, 0xA7, 0xB3. These chips were all from a single order from Mouser, they have the same date codes and all, but I wouldn't say that means that they're all from the same wafer.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Go Up