{"id":364,"date":"2014-02-12T10:31:27","date_gmt":"2014-02-12T16:31:27","guid":{"rendered":"http:\/\/thehackerworkshop.com\/?p=364"},"modified":"2014-02-12T21:45:19","modified_gmt":"2014-02-13T03:45:19","slug":"selecting-crystal-load-capacitors","status":"publish","type":"post","link":"https:\/\/thehackerworkshop.com\/?p=364","title":{"rendered":"Selecting Crystal Load Capacitors"},"content":{"rendered":"<p>When designing a circuit recently, I was faced with selecting appropriate load capacitors for the crystal oscillator on my microcontroller. While in the end this selection is rather straightforward, finding the relevant information can be a challenge. My Google searches weren't as helpful as I'd hoped they'd be, and I had to pull together information from several sources. I wrote this blog post to pull together all of the information I found into a single page that hopefully can serve as a reference for others.<\/p>\n<p>So let's begin: what are load capacitors and why are they needed?<!--more--><\/p>\n<p>The oscillator used by most (all?) microcontrollers is known as a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Pierce_oscillator\">Pierce oscillator<\/a>. To quote Wikipedia:<\/p>\n<blockquote><p>The <strong>Pierce oscillator<\/strong> is a type of <a title=\"Electronic oscillator\" href=\"http:\/\/en.wikipedia.org\/wiki\/Electronic_oscillator\">electronic oscillator<\/a> particularly well-suited for use in piezoelectric <a title=\"Crystal oscillator\" href=\"http:\/\/en.wikipedia.org\/wiki\/Crystal_oscillator\">crystal oscillator<\/a> circuits. Named for its inventor, <a title=\"G. W. Pierce\" href=\"http:\/\/en.wikipedia.org\/wiki\/G._W._Pierce\">George W. Pierce<\/a> (1872-1956),<sup id=\"cite_ref-0\"><a href=\"http:\/\/en.wikipedia.org\/wiki\/Pierce_oscillator#cite_note-0\">[1]<\/a><\/sup><sup id=\"cite_ref-1\"><a href=\"http:\/\/en.wikipedia.org\/wiki\/Pierce_oscillator#cite_note-1\">[2]<\/a><\/sup> the Pierce oscillator is a derivative of the <a title=\"Colpitts oscillator\" href=\"http:\/\/en.wikipedia.org\/wiki\/Colpitts_oscillator\">Colpitts oscillator<\/a>. Virtually all <a title=\"Digital electronics\" href=\"http:\/\/en.wikipedia.org\/wiki\/Digital_electronics\">digital IC<\/a> clock oscillators are of Pierce type, as the circuit can be implemented using a minimum of components: a single <a title=\"Inverter (logic gate)\" href=\"http:\/\/en.wikipedia.org\/wiki\/Inverter_%28logic_gate%29\">digital inverter<\/a>, two resistors, two capacitors, and the <a title=\"Quartz crystal\" href=\"http:\/\/en.wikipedia.org\/wiki\/Quartz_crystal\">quartz crystal<\/a>, which acts as a highly selective filter element. The low manufacturing cost of this circuit, and the outstanding frequency stability of the quartz crystal, give it an advantage over other designs in many <a title=\"Consumer electronics\" href=\"http:\/\/en.wikipedia.org\/wiki\/Consumer_electronics\">consumer electronics<\/a> applications.<\/p><\/blockquote>\n<p>In order to oscillate correctly, the oscillator needs a certain amount of capacitance across the leads of the crystal. This capacitance, known as the \"load capacitance,\" forms an essential part of the oscillator circuit.<\/p>\n<p>The required load capacitance is specified by the crystal manufacturer in the datasheet, usually as C<sub>L<\/sub>. The crystal manufacturer is saying that if the capacitance across the leads of the crystal is equal to C<sub>L<\/sub>, the crystal will resonate at its specified frequency.<\/p>\n<p>A naive solution to this problem is to simply use a single capacitor, of C<sub>L<\/sub>, across the leads of the crystal. Unfortunately, things aren't quite this easy. The naive solution looks like this:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_A.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-367\" title=\"Crystal_Load_Capacitor_A\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_A.png\" width=\"139\" height=\"284\" \/><\/a><\/p>\n<p>However, it's never done that way. Instead, load capacitors are placed from each lead of the crystal to ground. (I don't know why this is; I haven't yet found a good explanation in my research. If you have a good explanation, let us know in the comments!) The typical solution looks like this:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_B.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-368\" title=\"Crystal_Load_Capacitor_B\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_B-137x300.png\" width=\"137\" height=\"300\" \/><\/a><\/p>\n<p>Note that electrically, this is equivalent to two capacitors in series, with the circuit's ground on the segment between the two load capacitors. We can redraw the above circuit like this:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_C.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-369\" title=\"Crystal_Load_Capacitor_C\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_C-221x300.png\" width=\"221\" height=\"300\" srcset=\"https:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_C-221x300.png 221w, https:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Load_Capacitor_C.png 224w\" sizes=\"auto, (max-width: 221px) 100vw, 221px\" \/><\/a><\/p>\n<p>Now we have a problem we can solve. If we want the capacitance across the leads of the cystal to be C<sub>L<\/sub>, and we have two capacitors in series, we can figure out what value C to use for the capacitors. The formula for capacitors in series is:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Capacitors_In_Series.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-370\" title=\"Capacitors_In_Series\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Capacitors_In_Series.png\" width=\"228\" height=\"49\" \/><\/a><\/p>\n<p>For two capacitors, this formula reduces to:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Two_Capacitors_In_Series.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-371\" title=\"Two_Capacitors_In_Series\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Two_Capacitors_In_Series.png\" width=\"128\" height=\"60\" \/><\/a><\/p>\n<p>If we set C1 = C2 (which is almost always going to be the case with crystal load capacitors), and call that value C, we can further reduce this equation to:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Two_Identical_Capacitors_In_Series.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-372\" title=\"Two_Identical_Capacitors_In_Series\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Two_Identical_Capacitors_In_Series.png\" width=\"132\" height=\"53\" \/><\/a><\/p>\n<p>So, it would appear that if we need to find C such that C\/2 = C<sub>L<\/sub>, we should choose C = 2(C<sub>L<\/sub>), right?<\/p>\n<p>Well... almost. If the load capacitors were the only capacitance across the leads of the crystal, that would indeed be the case. However, there are additional sources of capacitance in the oscillator circuit. The first source is the \"stray capacitance\" of the circuit board traces. The second is the input capacitance of the oscillator circuit on the microcontroller.<\/p>\n<p>The input capacitance of the microcontroller's oscillator is specified in the datasheet. For the Atmel ATSAM3S controller I'm considering, it's specified in table 42-18 of the <a href=\"http:\/\/www.atmel.com\/Images\/doc6500.pdf\">datasheet<\/a> as 1pF typical.<\/p>\n<p>The stray capacitance of the circuit board is a bit more difficult to come by. Apparently, this is a difficult measurement to make, so the usual approach is to just guess. I've seen anything from 2pF to 5pF given as an appropriate value, and 3-5pF seems to be the most common guess.<\/p>\n<p>The crystal I've chosen for my circuit requires a load capacitance of 12.5pF to oscillate at its rated frequency. Choosing the load capacitors, then, looks like this:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Capacitor_Calculation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-375\" title=\"Capacitor_Calculation\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Capacitor_Calculation.png\" width=\"262\" height=\"205\" \/><\/a><\/p>\n<p>For this circuit, then, I'm going to use 18pF capacitors for C1 and C2.<\/p>\n<p>&nbsp;<\/p>\n<h4>Crystal 'Pulling'<\/h4>\n<p>So what happens then if we choose the wrong value for the load capacitors?<\/p>\n<p>Quoting Microchip App Note AN826 (linked below), crystals can be <em>pulled<\/em> from their specified operating frequency by adjusting the load capacitance the crystal sees in the circuit. An approximate equation for crystal pulling limits is:<\/p>\n<p><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Pulling.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-379\" title=\"Crystal_Pulling\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Crystal_Pulling.png\" width=\"148\" height=\"41\" \/><\/a><\/p>\n<p>Where:<\/p>\n<p style=\"padding-left: 30px;\">\u0394f = the pulled crystal frequency minus fs<br \/>\nfs = the crystal's resonant frequency<br \/>\nC1 = the motional arm capacitance of the crystal<br \/>\nC0 = the shunt capacitance of the crystal<br \/>\nCL = the actual load capacitance across the crystal's leads<\/p>\n<p>Whoa! These are new terms. What the heck do C0 and C1 represent? Well, a crystal actually has complex electrical properties. The electrical behavior of a crystal can be modeled like this:<\/p>\n<figure id=\"attachment_381\" aria-describedby=\"caption-attachment-381\" style=\"width: 251px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Quartz_crystal_equivalent.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-381\" title=\"Quartz_crystal_equivalent\" alt=\"\" src=\"http:\/\/thehackerworkshop.com\/wp-content\/uploads\/2012\/06\/Quartz_crystal_equivalent.png\" width=\"251\" height=\"190\" \/><\/a><figcaption id=\"caption-attachment-381\" class=\"wp-caption-text\">source: Wikipedia, released to public domain<\/figcaption><\/figure>\n<p>The shunt capacitance, C0, is the capacitance of the crystal's leads and package and is the only real value in the equivalent circuit. C1 is an equivalent value, a value that only exists in the model. Actual measurements for these values may or may not (and probably won't) be given in the crystal's datasheet. The crystal I'm using has a shunt capacitance C0 of 1.35pF typical, but the value C1 is not given. I was able to find one reference that gave typical values for C1 as 5-30fF (femtofarads). According to some resources I found, you might be able to pull a crystal by 100 or 200ppm. For the 32.768 kHz crystal I'm using, 100ppm would be 3.27Hz. In more realistic terms, 100ppm is about 8 seconds per day. Assuming I've chosen my load capacitors correctly, the +\/- 20ppm rating of the crystal is about 1.8 seconds per day.<\/p>\n<p>This is hardly a comprehensive review of the subject. I'm sure there's lots more to know about choosing capacitors that I either haven't found or don't care to dig in to. I'm hoping this information is enough to let me choose suitable capacitors for my designs, and I hope it is for you, too. But I have to say this again: just because I write a blog doesn't make me an expert.<\/p>\n<h4>Additional References:<\/h4>\n<p>http:\/\/www.crystek.com\/documents\/appnotes\/PierceGateLoadCap.pdf<\/p>\n<p>http:\/\/en.wikipedia.org\/wiki\/Pierce_oscillator<\/p>\n<p>http:\/\/www.fairchildsemi.com\/an\/AN\/AN-340.pdf<\/p>\n<p>http:\/\/www.crystek.com\/documents\/appnotes\/Pierce-GateIntroduction.pdf<\/p>\n<p>http:\/\/www.freescale.com\/files\/microcontrollers\/doc\/app_note\/AN3208.pdf<\/p>\n<p>http:\/\/www.atmel.com\/Images\/doc8128.pdf<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When designing a circuit recently, I was faced with selecting appropriate load capacitors for the crystal oscillator on my microcontroller. While in the end this selection is rather straightforward, finding the relevant information can be a challenge. My Google searches weren&#8217;t as helpful as I&#8217;d hoped they&#8217;d be, and I had to pull together information &hellip; <a href=\"https:\/\/thehackerworkshop.com\/?p=364\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Selecting Crystal Load Capacitors<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-364","post","type-post","status-publish","format-standard","hentry","category-hardware-news"],"_links":{"self":[{"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=\/wp\/v2\/posts\/364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364"}],"version-history":[{"count":0,"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=\/wp\/v2\/posts\/364\/revisions"}],"wp:attachment":[{"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thehackerworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}