Offline
Newbie
Karma: 0
Posts: 18
|
 |
« on: November 28, 2011, 06:38:31 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #1 on: November 28, 2011, 07:38:13 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #2 on: November 28, 2011, 09:17:56 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #3 on: November 28, 2011, 09:35:06 pm » |
Sure, a simple piece of code like this should work: 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
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay Area (USA)
Offline
Faraday Member
Karma: 78
Posts: 5453
Strongly opinionated, but not official!
|
 |
« Reply #4 on: November 29, 2011, 01:28:34 am » |
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...
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #5 on: November 29, 2011, 08:34:54 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #6 on: November 29, 2011, 09:49:49 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Grand Blanc, MI, USA
Offline
Edison Member
Karma: 43
Posts: 2491
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #7 on: November 29, 2011, 03:16:22 pm » |
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#a4The 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.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #8 on: November 29, 2011, 05:16:44 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Grand Blanc, MI, USA
Offline
Edison Member
Karma: 43
Posts: 2491
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #9 on: November 29, 2011, 07:09:34 pm » |
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: CL = ((C1 x C2) / (C1 + C2)) + Cstray Now it's recommended that C 1 = C 2, so this reduces to: C L = (C / 2) + C straySolve for C: C = 2(C L - C stray) Plug & chug: C = 2(18 - 5) = 26pF
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #10 on: December 03, 2011, 01:31:33 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Grand Blanc, MI, USA
Offline
Edison Member
Karma: 43
Posts: 2491
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #11 on: December 03, 2011, 01:54:15 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
0
Offline
Tesla Member
Karma: 71
Posts: 6603
Arduino rocks
|
 |
« Reply #13 on: December 23, 2011, 01:25:28 pm » |
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!!
|
|
|
|
|
Logged
|
|
|
|
|
Grand Blanc, MI, USA
Offline
Edison Member
Karma: 43
Posts: 2491
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #14 on: December 23, 2011, 03:20:43 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
|