I wanted know what should be the optimum distance between a microntroller(AT89C51ED2) and a crystal of frequency 11.0592MHz?
Electronic – the optimum distance between a micro-controller and a crystal on a PCB
crystalmicrocontrollerpcb-design
Related Solutions
My seat-of-the-pants understanding for load capacitors (corrections invited) goes like this:
When a crystal is cut for a certain load capacitance, it is measured with that capacitance across it during final factory trimming. There is nothing magical about the value. It is simply a way of saying, that if you design your circuit to present that same capacitance, then your crystal will be within the stated (.005% or whatever) tolerance.
So, you add up all the capacitance in your circuit, and then add in what's needed to bring it up to the spec. We'll use your numbers. The stray capacitance due to the traces on the board obviously will vary with the board, so let's guess 1.3 pf. A number I made up, to go with the capacitance of the microprocessor's oscillator, stated to be 1.7 pf. So, we've got 3 pf in parallel with the crystal. The crystal wants 18pf, so we have to make up the 15 pf difference with discrete parts.
Since the two load capacitors are in series (Gnd->cap->xtal->cap->Gnd), we double the cap value to 30pf. Two 30 pf caps in series give us the 15 pf we're looking for.
Note 1. I tried searching for typical PCB stray capacitance. It was all over the map. Suffice it to say, that as the hardware gets smaller, the capacitance will keep getting smaller. A lot of typical values claimed less than 1 pf.
Note 2. If there is more capacitance than spec, the crystal will oscillate at a lower frequency than specified. If there's less, then it's higher. You can see, that if you want to trim the oscillator to spec, it's easier to shoot for a lower capacitance and add some later, than to try the opposite.
Note 3. For fun, look up "gimmick capacitor".
Note 4. My "seat of the pants" explanation is sufficient as an introduction, and this technique works in many cases, but not everywhere. For a more in-depth look at the EE principles behind those capacitors, see this answer.
First, consider what crystal component really is: a capacitor with a fancy material between its plates. This should give you an insight at what happens to voltage/current across a crystal component.
The insulation material selected for this "crystal" capacitor exhibits piezoelectric properties (as other answer already expanded): it will mechanically deform a little when electrical field is applied; it can also produce some electrical field when elastic deformation is relieved. This particular property makes it behave similarly to an inductor. This observation allows us to come with an equivalent circuit of a crystal (a rather simple LC bandpass filter):
Then, to the bit of oscillator theory: to create oscillation you, commonly, need a filter and a high gain amplifier, feeding each other. During the oscillator start up, amplifier will produce some wide bandwidth thermal noise, filter will pass through only the desired frequency, this particular frequency will be further amplified by the amplifier until it's much higher power than noise, and the loop will close producing a sustained oscillation. Clearly, filter can be of any variety, crystals being the most convenient and stable ones (but you can easily substitute the crystal with a "wound" LC circuit or electromechanical tuning fork or any other filtering contraption of sort).
A bit of update on similarities between inductors and piezoelectric materials
As stated above, electric field applies a force to the piezoelectric material. The force exists, because matter inside the piezoelectric crystal is arranged in the form of tiny electric dipoles (for a bit of reference, the most common "dipole" molecule around is water, which acquires a lot of interesting properties because of this).
However, if there were only external electrostatic forces present, piezoelectric crystal will fall apart - evidently, some force is needed to counterbalance the electrostatic force and return the crystal to "normal" state when it is removed (thus, enabling its use in oscillators). This is a so called "elastic force" - force arising from (quantum) electrodynamic interactions between electrons and nuclei of the matter. That's the force responsible for preventing us from falling through the floor.
Not surprisingly, there exist 2 other types of oscillators which rely on elastic forces to provide the "push back" against the externally applied force:
- Mechanical spring pendulum - external mechanical force is balanced by the elastic forces in the spring material.
- Inductors - Lorentz force acting upon the conductor is counterbalanced (yet again) by the elastic forces of the wire. After all, if not for the elastic forces the electrons will simply fly away from the conductor, and no inductance will be observed.
That last effect is not readily observable in small signal electronics (copper is a fairly strong material and the currents are tiny) but becomes the dominant factor when currents start climbing into the 100A ranges and above - wires would jump all around the floor and solenoids will explode violently when Lorentz force suddenly overcomes the elastic forces.
To summarize:
In piezoelectric crystal oscillator:
Step 1: external field applies a force to dipole nano-sites inside the crystal affecting the electron configuration inside the crystalline structure, creating elastic deformation (and thus elastic counter force).
Step 2: when external field is removed, elastic forces restore the electron configuration to its "normal" state. As charge redistribution is involved, we observe a voltage across a crystal of a nature, rather similar to the "back emf" of inductors.
For comparison, in inductor based oscillator:
Step 1: external field invokes current in the inductor (because, unlike the piezoelectric crystal, electrons in conductors have a very high mobility and won't stick to specific sites inside the crystal). Current results in Lorentz force which deforms the electron configuration inside the material and creates elastic deformation (and thus elastic counter force, just like in the piezoelectric case).
Step 2: when external field is removed, we have exactly the same situation we had in the piezoelectric case - electron configuration is restored to normal, charge is being redistributed and "back emf" created. However, as we are dealing with highly mobile charge carriers in this case, it will be manifested in form of current, rather than voltage spike.
With the right choice of parameters, the math will look rather similar in both cases.
Best Answer
Once again, Atmel app notes to the rescue:
Atmel AVR 8-bit Microcontrollers Application Note - AVR042: AVR Hardware Design Considerations
Crystal/oscillator advice starts on page 13 and on page 16, it recommends a "Short distance between the crystal/capacitors and the MCU". Also, an example layout on page 18 shows how they laid-out the crystal circuit.