One of the most frequently asked questions about microcontrollers has to be
"What kind of crystal capacitors do I use on this chip."
Unfortunately, that's even the wrong question!
This also applies to any other common chip that uses an external crystal timebase.
- First, the crystal determines the capacitor values, not the chip.
Atmel's application notes correctly leave off the cap values, since they can't tell you what values to use!
- There are two types of crystals. Series resonant, and Parallel resonant.
Most microcontrollers use parallel resonant crystals.
- If you use series resonant crystals in a circuit designed for parallel resonant crystals, you will never get the crystal to the right frequency.
Why?
Because every crystal has two resonant points, the parallel point, and the series point.
They are very close together, but they cannot ever be on the same frequency.
Which one you use, depends on the circuit the crystal is used in.
Crystals are sold as parallel or series resonant, depending on which of these two points is intended to be used.
The other point is still there, but it may not perform well.
- All parallel resonant crystals have a specification that tells you how much loading capacitance is expected to be in the final circuit. However, you can't use that value directly.
First, there will be some amount of parasitic capacitance in the circuit, which we'll call "CP"
This happens in the traces, wires, and sockets.
Second, the chip itself will have some amount of input capacitance, which we'll call "CI"
Finally, the specified load capacitance, which we'll call "CL"
- A key point, is that from the crystal's point of view, the capacitors are in series.
This means that the values you need would be twice the value specified for CL.
If your crystal wants 22pF, then you would start out with an estimated value of 44pF for each cap.
However, you must subtract a bit for the parasitic capacitance, and the chip's input capacitance.
The final formula comes out as C=2(CL)-(CP+CI)
- You can estimate (CP+CI) to be about 5pF as a starting point, so our C value becomes:
C=(44)-(5) or 39pF.
If all you wanted is to get your project going, then this is what you needed.
However, if you'd also like to minimize your EMI output, then carry on to the next section.
Microcontroller Crystals, Advanced.
So we've got the right cap values, what more could there be?
- As it turns out, it's not quite so simple, if you care about minimising your EMI output.
The normal sort of crystal oscillator circuit has an input pin, and an output pin. The input pin is pretty simple-minded, it basically looks like a capacitor. But what's on the other side of that capacitor?- Answer: Ground, and VCC. So current into or out of this pin, ends up on Ground or VCC.
When you think about it, it makes sense. That current has got to flow, and it has got to return to the source.
This is a key point that's often missed, or not fully understood.
- Also, the output pin is a pair of FETs that source current alternately, from VCC, and to Ground.
Is this taking shape yet?- If you really want to get it as quiet as possible, you now split your caps (39pF from the previous example) into a pair of 19pF caps on each side, one to VCC, and one to ground!
- It is critical that these caps connect directly, and only to the processor power pins, by a separate track.
Don't dump the ground side caps into a plane, and don't connect the VCC side caps to any other point on the VCC tracks.
If you do, you have just created a shunt-fed antenna, driven by the microcontroller, passing the higher order odd harmonics of the crystal frequency through the caps!
If anything else is connected to these tracks, then it's an antenna!- So why don't you see this technique used more frequently?
Probably because of the extra expense of two more capacitors.
Also, because "The other guys don't do it that way."
Remember, when you copy the other guy's answers, you also copy his mistakes.
Sean:
The purpose in using capacitors with a crystal is two fold:#1) The oscillator consists of the inverter inside the PIC, the crystal, and external capacitance (both parasitic and actual capacitors). The total phase shift around the loop (from one inverter terminal, through the inverter, across the crystal/capacitor network, back into the inverter) has to be either 0 or 360 (the same thing) degrees for oscillation. The capacitance adjusts the phase shift of the network to allow oscillation.
#2) Crystals are designed to "see" a certain type of load. Most are designed to see a certain, specified capacitance, referred to as the Load Capacitance. In order for your crystal to operate at the correct frequency, it must see this value of capacitance at its terminals.
The total value of capacitance at the crystal's terminals is (Ca+Cp)/2, where Ca is the actual value of capacitor, per pin, that you place at the OSC1 and OSC2 pins, and Cp is the per pin parasitic capacitance. Cp is usually about 8pF or so. So, if your crystal wants to see a 20pF load, you will need to put 32pF capacitors at both OSC1 and OSC2: (32+8)/2 = 20pF This is one of the very useful and neat things that I learned from the PICLIST :-)
In [many cases], it probably "just works" because the parasitic capacitance is enough to satisfy #1 and [the] oscillator is probably running with perhaps 0.1% frequency error, a few kHz with an xtal in the several MHz range.
[This] question is almost a FAQ, and every time it comes up, there is always a debate about the last point that you make: what is the difference between "series" and "parallel" crystals. Here is the usual consensus: there is no difference. Every crystal has a parallel resonant frequency and a series resonant frequency. They are separated by a few kHz and which one you get depends on what value of external capacitance you place on the crystal (I think it ultimately has to do with #2 and exactly what frequency gives the 0 deg phase shift through the whole network). Crystals sold as "parallel" crystals achieve their rated frequency when loaded with the recommended load capacitance. Those sold as "series" crystals achieve their rated frequency when operated in series resonant mode (determined by the external capacitance, but I'm not sure how to figure this one out numerically,since it isn't specified for xtals sold as "series").
If you need a rough frequency standard, just use the (Ca+Cp)/2 formula. If you need strict accuracy, you will have to use a trimmer cap for one of the caps and use it to adjust the frequency.
Ref: David VanHorn
5 comments:
The capacitors are there to provide feedback which is necessary for the oscillator to function. Stray capacitance is often sufficient, but the crystal requires the specified load to operate at the correct frequency.
Leon
Those capacitances are necessary to make the oscillator oscillate. Some people like to think of those 2 capacitors as setting the gain of the amplifier stage, similar to the 2 resistors in an inverting op-amp stage. Others look at them as a feedback voltage divider across the resonator (crystal).
For an accurate, thorough, analysis of those parts' function look at a college-level electronics text (I think Horowitz & Hill is currently a very popular one) or perhaps any edition of the "Radio Amateur's Handbook" from the last 25 years or so. There may also be a Microchip Application note that provides a circuit analysis, and several of the crystal manufacturers show pretty good analyses of oscillator circuits in their catalogs. Look for a discussion of "Crystal Oscillators" - if memory serves, this is sometimes called the "Pierce" circuit; it's in the "Colpitts" family.
Microcontroller oscillators often oscillate without explicit capacitors, especially if you're using a solderless breadboard and have an analog layout that's fairly clean. Even though there's no explicit "capacitor", there will always be some "capacitance" on those nodes. If you don't provide a particular capacitor value the oscillator frequency will often be outside the crystal's specified tolerance, and since the oscillator is depending on uncontrolled stray, and parasitic, capacitances to function - it's hard to guess whether the oscillator will be especially sensitive to temperature, vibration, humidity, etc. It's not terribly rare for one of these oscillators (without explicit capacitors) to start and stop oscillation as your hand passes close to it.
Dale
The primary purpose of these capacitors is to provide the phase shift necessary for the oscillator to run.
As a crystal load, all circuit reactances external to the crystal should be thought of as a series equivalent. In
order to know the total load reactance seen by the crystal, the total shunt reactances on either terminal
are summed, and the series equivalent is calculated.
The reactances are the sum total of selected fixedcapacitors, any trimmer capacitors which may be
desired, and circuit strays. If a loop is considered from one crystal terminal through one phase shift capacitor
through ground and the second phase shift capacitor,to the second crystal terminal, all the reactances
including the crystal motional parameters must add upto zero, at the desired operating frequency.
This should include the OSC1 and OSC2 terminal reactances,but these are negligible if they are sufficiently
small when compared to the phase shift capacitors.
The value of these capacitors, is then chosen to be twice the specified load capacity of the crystal.
The PIC18FXXX oscillator design requires the use of aparallel cut crystal.
Use of a series cut crystal may give a frequency out of the crystal manufacturers specifications.
There is no difference in the construction of a series resonant crystal and a parallel resonant crystal, which
are manufactured exactly alike. The only difference between them is that the desired operating frequency
of the parallel resonant crystal is set 100 ppm or so above the series resonant frequency. Parallel resonance
means that a small capacitance, called load capacitance should be placed across the crystal terminals to
obtain the desired operating frequency .
The oscillator circuit
The Inverting Amplifier is the workhorse of the circuit. It must provide enough gain to amplify a very small signal
at start-up where only noise is provided to the input.
The Crystal has its lowest AC impedance near the resonant frequency. The crystal is placed in the path between the output and input of the inverting amplifier to permit feedback and therefore oscillation at the desired resonant frequency.
The output of the inverting amplifier is fed back to its input to create an "unstable" loop. When the inverter output is high and is fed back to the input, this causes the output to go low, which reverses the process.
Stable oscillation is achieved when the output is delayed by enough to provide 360 degrees of delay in the circuit and the circuit components attached achieve this feedback with "unity gain" only at the desired frequency.
Frequencies other than the desired frequency are filtered by the oscillator circuit and are, therefore, not amplified back into the signal. Oscillation is achieved when the signal rings back and forth through the crystal or resonator, sustained by the energy stored in the capacitors.
So, oscillation is achieved when a charge bounces back and forth through the crystal or resonator, between the capacitors. The amplifier is then adding a push at the right time and of the right amount to sustain oscillation.
The capacitors C1 and C2 make up the rest of the basic oscillator circuit when combined with the inverting
amplifier and the crystal or resonator. Again, when the circuit is ringing at the resonant frequency, charge is
transferred back and forth through the crystal or resonator, between the capacitors. Both capacitors, then,
work together to sustain the oscillation. Generally, they are chosen to be the same value to provide a symmetrical store of energy on both sides of the crystal or resonator and are chosen to match the load capacitance specified by the crystal or resonator manufacturer.
The capacitors provide 90 degrees of the phase shift, 45 degrees for each capacitor, with the crystal or resonator providing 90 degrees of the phase shift (seen as a resistive element at resonant frequency) with the
inverting amplifier providing the final 180 degrees to achieve the total 360 degrees required by the circuit.
Since each resonator/crystal has its own characteristics, the user should consult the resonator/crystal manufacturer for appropriate values of external components, or verify oscillator performance.
gabu
Getting Stable Oscillator Circuits
For accurate timekeeping purposes it is necessary to use Quartz crystal oscillators but everything around them needs to be constant to give a stable frequency. By taking some precautions it is possible to improve on the normal stabilities achievable. The things that can vary are the oscillator circuit voltage; circuit loading; power dissipation, temperature effects and the type of construction of the crystal can. The more parameters you can keep constant the better will be the oscillator. AWR Technology manufacture and sell Sidereal and Universal Time Clocks using the techniques outlined here (see clocks price list).
SOME BASIC REQUIREMENTS
An error of 1 part per million (1 ppm) will give a running error of 1 second in 12 days when used in a clock. Five times better than this would give an acceptable error rate! To achieve this needs special care in circuit design, the adjustment resolution and the drift need to be very small. The discrimination in the frequency setting component (usually a variable capacitor) needs to be about 0.05ppm. For a 180 degree mechanical rotation, about 100 times the discrimination would give an acceptable adjustment range. From experience with the CMOS 4060 oscillator circuit we have found that a 5ppm adjustment equates to about 0.9pF change in the loading capacitance. Special care is needed to design a series / parallel combination of loading capacitors with a variable element to give the desired adjustment range.
CRYSTAL CAPACITORS
The capacitors used around the crystal oscillator need to have zero temperature coefficient. Ceramic capacitors of dielectric type NP0 need to be used. Surface mount types enable a small footprint to be achieved, so reducing the strays and the susceptability from external interference. We have found some variable capacitors wandering on short timescales giving an instability.
VOLTAGE COEFFICIENT
The supply to the HC4060 was found to produce a voltage coefficient on the running frequency of about 1ppm per volt. By adding a series resistor (R2) with the crystal of about 27k (for the crystal under test) we reduced this voltage coefficient to a minimum, about 0.1ppm per volt. This value will be dependant on the crystal frequency, type of oscillator circuit and is tied to the operating power. Taking care of this parameter does improve the performance with the temperature effect on the regulator usually used. Thus the regulator performance also needs to be watched over the working ambient temperature range.
CIRCUIT LOADING
Adding any circuits to the HC4060 first output (pin 9) changes the operating frequency. Beware if you use this pin for calibrating. It is far safer to use an output right at the other end of the divider chain.
TEMPERATURE EFFECTS
Crystals can be 'tuned' during manufacture to provide different variations with temperature. By reducing the specified temperature range and closing up the tolerance it can be possible to achieve turning points within 0 to 25 deg C. The tight tolerance crystals we use have a temperature coefficient of less than 0.2ppm per degree C (typical). It is worth giving the circuit with a blast with the hair drier and monitoring the frequency variations with temperature when the circuit cools down. Freezer spray can also be used. The only way to remove temperature effects is to put the crystal in a small oven, monitored and kept at a constant temperature. AWR Technology do a crystal oven version, running at about 35 degrees C (but settable) which gives 0.2ppm change over an ambient temperature change of 40 degrees C ie 0.005ppm per degree C. Selecting the oven temperature at the turning point improves this immensely but you still have long term drift.
CRYSTAL CONSTRUCTION
Quartz crystals can come in various cans: soldered, cold welded etc and each version will give a particular ageing rate. This is a long term drift in frequency which makes the whole circuit need re-calibration every so often to maintain accuracy. The best types are those which have the lowest initlal drift rates, but even these can be 1ppm per year.
OVENING
The crystal can be kept at a constant temperature (higher than the expected normal ambient temperature) by means of a small heater, diode for temperature measurement and an error correcting amplifier as we do in the OVEN option for the SIDEREAL CLOCKS. Insulation is required and it needs carefull construction to reduce temperature gradients within the working cavity. Although the crystal may have 0.2 ppm per deg C by all other methods taken care of, if you keep the temperature constant to 1 degree C over an ambient of 0 to 35 degreees C then you get a 35 times better error rate ie 0.006ppm / deg C. We use this technique in our Intelligent Handset and oven option for the Sidereal Clock.
Ref: AWR Technology
Thanks contributors! Exactly what I was looking for.
Post a Comment