Author Topic: What are they doing!? xtal/osc/caps  (Read 652 times)

0 Members and 1 Guest are viewing this topic.

Online PerranOak

  • Frequent Contributor
  • **
  • Posts: 450
  • Country: gb
What are they doing!? xtal/osc/caps
« on: April 03, 2021, 05:36:29 pm »
In the "standard" oscillator circuit (attached) for a crystal to use with a uC, what are the capacitors (C1 and C2) doing?

I mean, I know they're needed but what are they ACTUALLY doing that makes the xtal work whereas (I have found) without them or with the "wrong" caps the xtal does not "work".

I'd love an explanation of the application of the property of capacitance in this instance.

It's purely for education, thank you.
Some light can never be seen!
RJD
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 17188
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: What are they doing!? xtal/osc/caps
« Reply #1 on: April 03, 2021, 05:45:46 pm »
The crystal is operating in the series resonant mode, while the oscillator needs a parallel resonant feedback network (180 degree phase shift at resonance, gain peak at resonance; whereas series resonant to ground would be gain minima).  The capacitors act to give a series-parallel transformation, thus giving the desired characteristic.

The network's characteristic impedance is approximately the reactance of the capacitors.  This allows some tuning to be done, e.g. using a somewhat lower ESR crystal on a weak oscillator (perhaps STM family MCUs?).  Mind that the capacitance also has a small effect on the tuned frequency (give or take a kHz or so), so this will also affect exact frequency.  (If capacitance is being reduced, additional capacitance can be connected in parallel with the crystal to maintain the same total capacitance as seen by the crystal; or if increased, some can be connected in series with the crystal.)

You might think to use a crystal in the parallel resonant mode, shunting to ground, with a series impedance to supply it, thus making an impedance divider which has gain peak at resonance; but this has 0 phase shift at resonance (for a resistive supply, or 90 for an inductive one), so won't work with the simplest oscillator (an inverting amplifier).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 1557
  • Country: us
Re: What are they doing!? xtal/osc/caps
« Reply #2 on: April 03, 2021, 06:44:35 pm »
CuriousMarc made a good video on the workings of a crystal oscillator:

https://youtu.be/ad8azNovsF8

You can start watching at the 8:16 mark.
 

Offline TimFox

  • Super Contributor
  • ***
  • Posts: 2435
  • Country: us
  • Retired, now restoring antique test equipment
Re: What are they doing!? xtal/osc/caps
« Reply #3 on: April 03, 2021, 06:58:48 pm »
The two capacitors form a Colpitts oscillator (q.v.) with the crystal resonator.
There is a large literature about crystal oscillators.  My go-to reference book is R. J. Matthys:  "Crystal Oscillator Circuits", rev ed 1992, (orig. John Wiley, reprinted by Krieger Pub Co).
 
The following users thanked this post: oPossum, exe

Offline emece67

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: es
Re: What are they doing!? xtal/osc/caps
« Reply #4 on: April 03, 2021, 08:38:01 pm »
In the "standard" oscillator circuit (attached) for a crystal to use with a uC, what are the capacitors (C1 and C2) doing?

I mean, I know they're needed but what are they ACTUALLY doing that makes the xtal work whereas (I have found) without them or with the "wrong" caps the xtal does not "work".

I'd love an explanation of the application of the property of capacitance in this instance.

Here https://www.eevblog.com/forum/beginners/understandin-the-tank-circuit-in-hartley-and-colpitts-circuits/msg3220182/#msg3220182 you can find an explanation of how Colpitts/Hartley LC oscillators work. In this case:

  • XTAL and C1 form a voltage divider. At the oscillation frequency, XTAL is inductive and \(|X_{XTAL}| > |X_{C1}|\), thus V_OSC1 is 180º off from V_C2
  • The inverter inside the uC introduces another 180º phase shift so, at the oscillation frequency, V_OSC2 and V_C2 are in phase
  • For V_OSC2 and V_C2 to be in phase, the voltage divider formed by RS and {C1, C2, XTAL} must add 0º degrees. To achieve that, {C1, C2, XTAL} must be resistive at such frequency. As \(|X_{XTAL}| > |X_{C1}|\), {XTAL, C1} is inductive, so C2 must be, well, a C for {XTAL, C1, C2} be resistive.

The ratio of C2/C1 affects the loop-gain, as you need it to be > 1 for the oscillations to start, not all C2/C1 ratios do work.

The XTAL datasheet states the capacitance it must see in order to resonate at its nominal frequency. Note that, at this frequency, the crystal as a unit is not "resonating" (is not resistive, but inductive, and it is working in parallel mode). As the frequency range at which the XTAL is inductive is quite narrow, the oscillation frequency is affected in not a big way by the values of {C1, C2}

RS tries to isolate the XTAL from the output of the gate, controls the loop-gain and affects XTAL drive and waveform.

Regards.

« Last Edit: April 03, 2021, 08:40:18 pm by emece67 »
Information must flow.
 

Offline MikeK

  • Frequent Contributor
  • **
  • Posts: 772
  • Country: us
Re: What are they doing!? xtal/osc/caps
« Reply #5 on: April 03, 2021, 08:44:11 pm »
The two capacitors form a Colpitts oscillator (q.v.) with the crystal resonator.
There is a large literature about crystal oscillators.  My go-to reference book is R. J. Matthys:  "Crystal Oscillator Circuits", rev ed 1992, (orig. John Wiley, reprinted by Krieger Pub Co).

It's a Pierce oscillator.
 

Offline TimFox

  • Super Contributor
  • ***
  • Posts: 2435
  • Country: us
  • Retired, now restoring antique test equipment
Re: What are they doing!? xtal/osc/caps
« Reply #6 on: April 03, 2021, 08:58:43 pm »
See pages 46 to 47 of the Mathis book on the distinction between Colpitts (more general than Pierce) and Pierce (specific for crystals) circuits.  The Pierce has a different ground point in an otherwise similar circuit, and can be considered as a (very useful) special case of the Colpitts.  Indeed, his circuit is a Pierce.
In the Pierce circuit, the capacitive loading on the crystal is good for Q and frequency stability, but requires higher amplifier gain than the basic Colpitts.
« Last Edit: April 03, 2021, 09:00:29 pm by TimFox »
 

Offline MikeK

  • Frequent Contributor
  • **
  • Posts: 772
  • Country: us
Re: What are they doing!? xtal/osc/caps
« Reply #7 on: April 03, 2021, 10:00:42 pm »
From wikip:

[attachimg=1]
 

Offline MikeK

  • Frequent Contributor
  • **
  • Posts: 772
  • Country: us
Re: What are they doing!? xtal/osc/caps
« Reply #8 on: April 03, 2021, 10:05:09 pm »
Also, from Microchip's AN826:

"The type of oscillator that appears on the PICmicro® microcontroller is the Pierce"

Anyway, the important thing is knowing what the caps do.
 

Offline emece67

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: es
Re: What are they doing!? xtal/osc/caps
« Reply #9 on: April 04, 2021, 11:43:54 am »
Another try:

We want a circuit that generates a self sustained oscillation at a given frequency. Our approach is to build an amplifier and add to it some network that, from the output of the amplifier, generates the input to be feed to the amplifier to produce such output. This network must be such that the supplied input signal to the amplifier exactly matches that needed to generate such output at the desired frequency, no others.

To get the amplifier we use a CMOS inverter polarized on its linear region, to achieve such polarization we use resistor \(R_F\). This amplifier has a negative gain and introduces a 180º phase shift between its input \(V_{OSC1}\) and its output \(V_O\).

To generate \(V_{OSC1'}\) from \(V_O\) we use the {RS, C2, X, C1} network. On it there are two voltage dividers of interest here:
  • The one built with RS and {C2, X, C1}
  • The one built with X and C1.



We want \(V_{OSC1'}\) to be equal to \(V_{OSC1}\), such that connecting \(V_{OSC1'}\) to \(V_{OSC1}\) will fulfill our desire for the circuit to supply its own input signal, thus self-sustaining oscillations. To get \(V_{OSC1'} = V_{OSC1}\) we need both signals to have the same phase and amplitude. Lets first talk about their phases, from \(V_{OSC1}\) to \(V_{OSC1'}\) the signal suffers 3 phase changes:
  • from \(V_{OSC1}\) to \(V_O\). As stated before, this is 180º at all frequencies
  • from \(V_O\) to \(V_X\). Its phase shift is that produced by the voltage divider RS and {C2, X, C1} above
  • \(V_X\) to \(V_{OSC1'}\). Its phase shift is that produced by the voltage divider X and C1 above

We select X and C1 such that, at the desired oscillation frequency, X is inductive and \(|X_X| > |X_{C1}|\), when this happens, \(V_{OSC1'}/V_X=X_{C1}/(X_X+X_{C1})<0\) (numerator is < 0, denominator is > 0) so there is a 180º phase shift from \(V_X\) to \(V_{OSC1'}\). The frequency range at which X is inductive is quite narrow, so this can only happen in a quite narrow range of frequencies.

Now we dealt with the remaining phase shift: that from \(V_O\) to \(V_X\). As we want the overall phase shift to be 0º and we have now 180º+180º, we need this last phase shift to also be 0º. This phase shift is that produced by the voltage divider RS and ZR. For it to produce a 0º phase shift it is needed for ZR to be resistive. As \(Z_R = Z_{C2}//Z_X\) and ZX is inductive (because we have selected X and C2 such that \(|X_X| > |X_{C1}|\)), \(Z_{C2}\) must be capacitive. So, the phase shift from \(V_O\) to \(V_X\) will be 0º when ZR is resistive, that is, when {C2, X, C1} resonates. X sees {C1, C2 in series}, so this phase shift will be 0º when the reactance of X equals (with changed sign) that of C1//C2. The datasheet of X states the capacitance it must see (the load capacitance \(C_L\) = C1//C2) for the whole {C2, X, C1} to resonate at the nominal frequency of X.

So, any pair {C2, C1} that satisfy C2//C1 = \(C_L\) will produce an overall phase shift of 0º from \(V_{OSC1}\) to \(V_{OSC1'}\) at the nominal frequency of X. At other frequencies the overall phase shift will be different from 0º and the circuit will not self-sustain oscillations.

But for the oscillations to self-sustain the overall phase shift of 0º is not enough, the overall amplitude gain from \(V_{OSC1}\) to \(V_{OSC1'}\) must be 1. In fact we use a gain > 1 to ensure that the oscillations start and rise in amplitude. When the signal amplitude is high enough for the amplifier to start behaving non linearly (saturating) the effective gain decreases, reaching an effective value of 1 when the amplitude of oscillations finally stabilize. If the initial gain is much bigger than 1, the amplifier will be driven deeper into non linear regions and the signal will have more harmonics/be more distorted.

The overall gain at the resonant frequency depends on the ratio C2/C1 and the value of RS (and ZR). A common approach is to set C2 = C1 = \(2C_L\) (then the X and C1 voltage divider shows a "gain" of 0.5, demanding the amplifier to have a gain > 2). RS can be adjusted, given the amplifier and ZR, to ensure oscillations start and the signal level is not too high. Many times RS is not present: the oscillations will start, but the drive level of X may be high, as distortion.

So, when all above is designed in such way, \(V_{OSC1'}\) will be in phase with \(V_{OSC1}\) only at the nominal frequency of X and with an overall amplitude gain > 1. Thus connecting \(V_{OSC1'}\) to \(V_{OSC1}\) the circuit will supply its own input and generate a signal at such frequency.

Hope this helps. Regards.

« Last Edit: April 04, 2021, 11:53:28 am by emece67 »
Information must flow.
 
The following users thanked this post: PerranOak

Online PerranOak

  • Frequent Contributor
  • **
  • Posts: 450
  • Country: gb
Re: What are they doing!? xtal/osc/caps
« Reply #10 on: April 04, 2021, 05:12:06 pm »
Wow! Cheers all.

I didn't realise it was so involved.

emece67: I've copied your post and am going to study it tonight.  ;D
Some light can never be seen!
RJD
 

Online PerranOak

  • Frequent Contributor
  • **
  • Posts: 450
  • Country: gb
Re: What are they doing!? xtal/osc/caps
« Reply #11 on: April 08, 2021, 02:20:59 pm »
I think I understood but for one part: I don’t quite get where Zr comes from?
Some light can never be seen!
RJD
 

Offline TimFox

  • Super Contributor
  • ***
  • Posts: 2435
  • Country: us
  • Retired, now restoring antique test equipment
Re: What are they doing!? xtal/osc/caps
« Reply #12 on: April 08, 2021, 04:02:11 pm »
In his drawing, Zr is the ratio calculated from the indicated voltage Vxapplied to that node divided by the current flowing into the circuit to the right induced by that voltage.  Of course, the ratio is complex.
 

Online PerranOak

  • Frequent Contributor
  • **
  • Posts: 450
  • Country: gb
Re: What are they doing!? xtal/osc/caps
« Reply #13 on: April 10, 2021, 04:12:38 pm »
Ah, I see. That's why the phase shift is zero as this element is from the resistor.
Some light can never be seen!
RJD
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf