1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Role of capacitor in crystal circuit for micro-controller.

Discussion in 'Microcontrollers' started by sysysy, Jan 13, 2011.

  1. sysysy

    sysysy New Member

    Joined:
    Dec 10, 2008
    Messages:
    34
    Likes:
    0
    Hi,

    May i know what is the actual functional of capacitor that we use in the crystal circuit? for example 2 22pf are using in connect between 2 terminal of crystal to Gnd.

    I remembered last time my friends take wrong value of the capacitor and connected to the crystal.As a result, the microcontroller is never getting work until he found out the problem.

    From the datasheet, it juz say that for higher capacitance that we use, the re is more stability of oscillator but also increase the the start-up time. Unfortunately, it did not say why must use or real purpose of this capacitor.

    Hope anyone know can share the discussion here.

    Thanks


    regards,

    sysysy.
     
    • Disagree Disagree x 1
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    Look at this pdf.

    EDIT:
    To make it clearer what are the requirements for the external capacitors I have edited the datasheet in order to highlight the importance
    of the external components.

    Hopefully this will dispel the 'Forum folk lore' explanations for the components.

    CrystalCaps.png
     

    Attached Files:

    Last edited: Jan 14, 2011
  3. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    The additional capacitors on either side of the crystal are basically to damp unwanted oscillation modes, The crystal will transfer any harmonic of it's resonant frequency to a greater or lesser degree, sometimes this is desired, but not in micro controllers, I've never seen a micro controller that uses an overtone crystal (non resonant but harmonically higher), in theory if you changed the cap values you could get a 10mhz crystal to start a micro controller up at 5mhz or 20mhz, assuming the oscillator circuitry allowed it, might require tweaking, but not needed, micro controllers almost always have clock divider options that would allow you to divide the incoming clock for the main frequency. Generally micros are run at their maximum allowable frequency all the time, situations where their running frequency needs to be tweaked don't occur regularly.

    When it's started up a crystal oscilator is basically fed a noise pulse, and the rest of the passive components in the circuit have to act to quickly to attenuate all the unwanted frequencies down to the one the oscilator can run at BUT that the MCU will run at, if there is no check on that noise you can get random false positive clock ticks at harmonics if they're not filtered out So you could get a 10mhz main clock but sometimes there are over or undertones causing extra ticks here or there, all that's desired is one and only one frequency where there is output. It may never stabilize which will really wreak havoc on code, or again in theory if the oscillator allowed it could stabilize at so high a frequencies the micro controller can't function properly (generally from flash timing)
     
    Last edited: Jan 13, 2011
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,049
    Likes:
    541
    Location:
    AZ 86334

    Nope, that is exactly the OWT that this thread is trying to dispell!

    The capacitors are there to resonate with the crystal inductance and cause the crystal to oscillate on its fundamental parallel-resonant mode.
    The reason that there are two capacitors in series is to create a network that creates a 180 degree phase inversion at resonance, because the amplifier (inverter) has a 180 degree phase inversion between its input and output. This makes the loop gain have a net phase shift of 360 degrees, which is what causes it to oscillate (look up Barkhausen Criterion).

    This is a Pierce oscillator; (look that up, too).
     
    Last edited: Jan 19, 2011
  6. ablemicky

    ablemicky New Member

    Joined:
    Jun 18, 2008
    Messages:
    4
    Likes:
    0
    the capacitors are there as starting capacitors.most crystal cant start oscillation on their own.if you want to stop bothering about capacitors, u can use a resonator instead.they are self oscillating or better still quickly finish mastering your pic commands and move to a higher one like 16f628 that have internal oscillator.
     
  7. sysysy

    sysysy New Member

    Joined:
    Dec 10, 2008
    Messages:
    34
    Likes:
    0
    Hi ablemicky,

    may i know how is the capacitance value take effect on it?
    why must the within range provided by the datasheet just able to start the crystal oscillation?

    how about if using too large value of capacitance?
     
  8. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,049
    Likes:
    541
    Location:
    AZ 86334
    The difference between a crystal with two capacitors compared to a ceramic resonator is that the capacitors happen to be integrated into the ceramic resonator. From an analysis standpoint, a ceramic resonator is equivalent to a crystal and two capacitors, except that the crystal has a higher Q and better frequency stability.
     
  9. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,049
    Likes:
    541
    Location:
    AZ 86334
    Read up on "Pierce Oscillator"; that explains it all.
     
    Last edited: Jan 19, 2011
  10. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    Well Mike, I can say this, the very start of my post makes perfect sense, the rest of it does however show I don't know how they actually function in the circuit =)
    Makes sense that's what they do, I've never done an AC analysis before though so my actual native understanding of their function in the circuit is zero and goes to show that I should just say what I know without trying to extemporizing on things I don't know well =>
     
  11. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,049
    Likes:
    541
    Location:
    AZ 86334
    Here is a pretty good explanation of what the capacitors do, and how the inverter inside the PIC makes an oscillator.
     

    Attached Files:

  12. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    That PDF recommends using a feedback resistor between 10-20meg on low crystal values basically anything lower than about 6mhz. I've never seen that before, but the explanation in the PDF is quiet good. I wonder how much this effects accuracy on something like real time clock crystals because I can't recall ever seeing a feedback resistor in a real time clock circuit.
     
    Last edited: Jan 18, 2011
  13. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,049
    Likes:
    541
    Location:
    AZ 86334
    The 10meg resistor is needed to "bias" one-sixth of a hex logic inverter into the linear gain region when the inverter is used as the gain block of a crystal oscillator. The resistor effectively turns the CMOS inverter into an inverting amplifier (phase shift of 180 degrees), with high input impedance, fairly low output impedance, with a gain bandwidth product of several hundred MHz.

    The two capacitors in series resonate with the effective inductance of the crystal at its parallel-resonant fundamental mode. The common point between the two capacitors is ground, so the crystal+2capacitors network has a net 180 degree phase shift between its two ports, which when combined with the 180degree phase shift in the amplifier adds up to 360, which means oscillation (loop gain >1, phase shift = 0 dgrees, or multiples of 360 degrees). That is by definition a Pierce Oscillator.

    The inverter integrated into a PIC chip or other similar IC doesn't need the external 10meg resistor because it is integrated inside the chip. The reason that sometimes the capacitors can be left out (and the oscillator will still oscillate) is because the pad/pin capacitance of the two pins at the input and output of the inverter have an intrinsic capacitance pushing ~10pf, but it is not good to expect that the crystal will start reliably if you leave out the external capacitors.
     
    Last edited: Jan 19, 2011

Share This Page