Quartz crystal oscillators allow us to overcome a number of issues that may have a substantial impact on the frequency stability of an oscillator circuit. These influences include, but are not restricted to, temperature variations, fluctuations in the load connected to the oscillator, and even changes in the DC power supply voltage. All of these might cause the oscillator’s frequency to vary, which is generally undesirable when attempting to produce steady and accurate output signals.
Selecting Components for Improved Frequency Stability
In order to enhance the stability of the oscillator’s output signal, we need to carefully choose the components which are included in the resonant feedback circuit.
This includes both the feedback components and the amplifier, which is crucial to guaranteeing stable oscillation. But even with the very best components for traditional circuits such as LC (inductor-capacitor) and RC (resistor-capacitor) tank circuits, we can only obtain only moderate stability.
These circuits have inherent frequency stability restrictions, which means that improvements to them are relatively low or impossible.
The Role of Quartz Crystals in Achieving Greater Stability
To achieve a considerably greater level of frequency stability, we commonly use Quartz Crystals as the frequency-determining element in the oscillator circuit.
By integrating a Quartz Crystal into the design we may create an oscillator with substantially more stability compared to traditional LC or RC circuits.
This produces an entirely different form of oscillator known as a Quartz Crystal Oscillator or XO, that allows us to maintain a far greater precision and stable frequency output under a variety of situations.
The Piezoelectric Effect: How Quartz Crystals Respond to Voltage
When we supply a voltage source to a small thin slice of quartz crystal, an intriguing event happens. The crystal now begins to physically change form, which we refer to as the Piezoelectric Effect.
This phenomenon is unique for some crystals such as quartz, and it occurs when an electrical charge is applied to the crystal, which causes it to deform or change shape.
Conversely when we apply a mechanical force, like pressure or compression, to the crystal, it generates an electrical charge. In simple terms, this phenomenon enables energy to flow in both directions: electrical energy may cause mechanical movement, and mechanical movement can generate electrical energy.
Piezoelectric Devices as Transducers
Because of its capacity to transform energy from one form to another, piezoelectric devices are classified as “transducers.” A transducer is a device which can convert one form of energy into another, therefore these crystals are extremely versatile.
These piezo transducers may be used to convert electrical energy into mechanical vibrations or the other way around. The mechanical vibrations or oscillations produced by piezoelectric crystals are very useful in many different kinds of technological applications.
These can even be used to replace the usual LC (inductor-capacitor) tank circuits seen in oscillators, giving an innovative approach of creating stable oscillations.
The Importance of Quartz in Oscillators
There are several types of crystals that may be used as oscillators, all of which have unique features. However quartz is one of the most important minerals in electrical circuits.
Quartz stands out because to its high mechanical strength and stability. Its capacity to resist stress without losing shape or functioning makes it an excellent choice for creating constant and stable oscillations.
This is why in most electrical equipment requiring great accuracy and stability, quartz crystals are commonly used for achieving the necessary performance.
Physical Characteristics of Quartz Crystals in Oscillators
The quartz crystal which is utilized in Quartz Crystal Oscillator circuits is a tiny, precisely manufactured piece of quartz. This crystal is thin and crafted into a precise form, commonly known as a wafer. To make it electrically operational, a coating of metal is applied to the two flat, parallel sides of the crystal material.
This metallization enables us to create the required electrical connections to the crystal. One of the most important characteristics of quartz crystals is their physical size and thickness.
These parameters are meticulously controlled since they have a direct influence on the fundamental frequency of the oscillations produced by the crystal. This basic frequency is sometimes referred to as the “characteristic frequency” of the crystal.
Electrical Representation of a Vibrating Quartz Crystal
Once you cut and shape the crystal to these precise dimensions, it gets locked into a specific frequency. In other words the size and shape of the quartz crystal permanently determines its fundamental oscillation frequency. Then you cannot use that crystal to operate at any other frequency once it has been prepared in this way.
The characteristic frequency of a crystal is closely related to its physical properties, particularly its thickness. The frequency at which it oscillates is inversely proportional to the thickness of the quartz between the two metallized surfaces. This means that, the thinner the crystal is, the higher its characteristic frequency will be, and the thicker it is, the lower its frequency will be.
Understanding an Equivalent Circuit Model of a Quartz Crystal
When the crystal is vibrating mechanically, we may express it in terms of a corresponding electrical circuit.
This circuit could be made up of various components that emulate or reproduce the behavior of the vibrating crystal.
These components consist of a low resistance (R), a big inductance (L), and a modest capacitance (C). All of these aspects work together to describe how the crystal behaves electrically, which demonstrates the correlation between mechanical vibrations and the electrical characteristics that arise.
Please refer to the following diagram for more details:
The above shown equivalent electrical circuit for a quartz crystal can be understood as something that combines components representing both the crystal’s mechanical vibrations and its electrical connections.
When you look at it, you see a series RLC circuit which replicates or models the mechanical movements of a crystal. This circuit is created using a resistor (R), an inductor (Ls), and a capacitor (Cs) all of which are working together in series. Alongside this we can also see a parallel capacitor Cp, which represents the electrical connections to the crystal.
Whenever I practically work with quartz crystal oscillators, I mostly aim for them to operate around their “series resonance.” This is because, this is the point where the crystal operates most efficiently with its impedance at the lowest.
Actually what happens is that the series capacitor (Cs) resonates with the inductor (Ls) at the main operating frequency of the crystal and we refer to this frequency as the “series frequency” or the fs.
But that is not the only thing to consider. In addition to the series frequency, there is also one more important frequency point. You might find that this occurs due to the parallel resonance in the circuit which happens when the inductor (Ls) and series capacitor (Cs) resonate together with the parallel capacitor (Cp).
This parallel resonance becomes responsible for creating a second frequency point. Both, the series and parallel resonances are very important and both together determines how the quartz crystal performs in an oscillator circuit.
Understanding these interactions helps us to see how the crystal operates across different frequencies and why crystals can be so effective for enabling a stable frequency in an oscillator circuit.
Plotting Crystal Impedance against Frequency
R = R and XLS = 2πfLS
XCS = 2πfCS and XCP = 2πfCP
ZS = √[RS2 + (XLS – XCS)2]
∴ ZP = (ZS * XCP)/(ZS + XCP)
Referring to the above figure, let us take a closer look and understand how the impedance of a quartz crystal impedance behaves as we increase the frequency across its terminals.
Suppose you start raising the frequency, something important happens at a specific point: the series capacitor (Cs) and the inductor (Ls) interact with each other creating what we call a series resonance circuit.
This interaction causes the impedance of the crystal to drop to its lowest possible value; which is equal to Rs. This specific point we refer to as the crystal’s “series resonant frequency,” or ƒs. Below this frequency you will notice that the crystal behaves more like a capacitor.
But as we continue increasing the frequency above this series resonant point, the crystal no longer acts like a capacitor, instead it begins to behave like an inductor. This continues until we reach another important point which we call as the “parallel resonant frequency,” or ƒp.
At this frequency, the inductor (Ls) and the parallel capacitor (Cp) form a parallel-tuned LC tank circuit, and the impedance of the crystal reaches its maximum value.
Now what we can see is that, a quartz crystal works using the combination of both, a series and a parallel resonant circuit.
The crystal oscillates at two different frequencies; one for series resonance and one for parallel resonance. These frequencies are very close to each other; and the difference between them depends on how the crystal is cut during its manufacturing.
Since the crystal can either function at its series or parallel resonant frequencies; the oscillator circuit needs to be tuned to one of these frequencies, because we can not use both at the same time.
So depending on how your circuit is designed, a quartz crystal can act like a capacitor, an inductor, a series resonant circuit, or a parallel resonant circuit.
To demonstrate this more clearly suppose we plot the crystal’s reactance against frequency, and you will see how the crystal shifts between these different states as the frequency changes.
This helps us to visualize the dynamic nature of the crystal’s behavior in an oscillator circuit.
Plotting Crystal Reactance against Frequency
XS = R2 + (XLS – XCS)2
XCP = -1/2πfCP
XP = (XS * XCP)/(XS + XCP)
Next, let us take a closer look at how the reactance of the quartz crystal behaves as we change the frequency levels. If we plot the slope of the reactance of the crystal against the frequency; it shows us something quite interesting.
At the series resonant frequency fs, the series reactance is inversely proportional to the value of the capacitor Cs. This means that below the level of the frequency fs and above the level of the frequency fp, the crystal behaves very much like a capacitor. Within these regions, the crystal appears to have a capacitive nature.
Now let us look at the behavior of the crystal when the frequencies is between fs and fp. In this middle range of the frequency, the crystal behaves more like an inductor. This is because the effects of the two parallel capacitances cancel each other out, leaving us with an inductive characteristic.
So when you are trying to understand the crystal’s behavior at series resonance, the most important thing to remember is that its series reactance at frequency fs is determined by the capacitor Cs.
Formula for Calculating the Series Resonant Frequency
If you want to calculate the exact series resonant frequency fs for the crystal, you can use the following formula:
fs = 1/[2 * π *√(Ls * Cs)]
Formula for Calculating the Series Resonant Frequency
As we learned before, parallel resonance happens when the reactance of the series LC leg (which includes the inductor and capacitor in series) becomes equal to the reactance of the parallel capacitor Cp.
This is the point where the effects of the series components and the parallel capacitor balances each other out. When this happens we say that the crystal is at its parallel resonance frequency.
If you want to calculate this parallel resonance frequency fp, it can be determined using the following formula:
fp = 1/(2 * π * √Ls[(Cp * Cs)/(Cp + Cs)]
Solving a Quart Crystal Oscillator Problem #1
Let us imagine we are working with a quartz crystal that has the following specific values:
- The series resistance Rs is given as 6.5 Ω which is the resistance the crystal experiences during its series resonance.
- The value of the series capacitor Cs is measured at 0.09988 picofarads.
- And the series inductor Ls is measured at 2.646 millihenries.
- Additionally the parallel capacitance across the crystal’s terminals known as Cp is measured at 28.95 picofarads.
With all of these data in hand we can determine the crystal’s two important frequencies: its fundamental oscillation frequency (series resonant frequency) and its secondary resonance frequency (parallel resonant frequency).
Let us begin by calculating the crystal’s fundamental oscillation frequency, and then proceed to calculate the secondary resonance frequency.
Formula:
fs = 1/[2 * π *√(Ls * Cs)]
= 1/[2 * π *√(0.002646 * 0.00000000000009988)]
= 9790073.33206 Hz
= 9.79 MHz
2. Secondary Resonance Frequency (Parallel Resonance, fp):
Formula:
fp = 1/(2 * π * √Ls[(Cp * Cs)/(Cp + Cs)]
Cp = 28.95 pF = 0.00000000002895 Farad
fp = 1/(2 * π * √0.002646((0.00000000002895 * 0.00000000000009988)/(0.00000000002895 + 0.00000000000009988)))
fp = 9806947 Hz = 9.8069 MHz
When we analyze carefully the difference between the “fs” which is the crystal’s fundamental frequency, and the “fp” which is the parallel resonance frequency, we notice that this difference is quite small… just around 16kHz.
In between this small frequency range we find that the crystal’s Q-factor, or Quality Factor, is actually extremely high. You already know that the Q-factor is a measure of how efficient the crystal is at oscillating and a higher Q-factor means that less energy is lost to resistance and other inefficiencies.
In this case the crystal’s inductance is far greater than its capacitance or resistance, which gives rise to a very very high Q-factor.
Calculating the Q-Factor of the Crystal Oscillator Circuit
Now if we pay our attention specifically on the series resonance frequency “fs”, we find that the Q-factor of the crystal is particularly high and we can calculate it using a special formula as given bellow.
The Q-factor of the crystal at the series resonance point indicates us about the fact, just how well the crystal can maintain stable oscillations with minimal energy loss.
Q = XL/R = 2πfL/R
= (2 * π * 9.79 * 106 * 0.002646)/6.5
= 25040 or simply 25000
Let us take a closer look at the Q-factor of our crystal. In this example we find the Q-factor is around 25,000 which looks quite impressive. This high Q-factor is primarily because of the large ratio of “XL” (reactance of the inductor) to “R” (resistance).
Most crystals will typically have Q-factors in the range of 20000 to 200000, which really stands out. In contrast, a good LC tuned tank circuit (like the ones we have discussed earlier) may usually have a Q-factor of much lower than 1000.
This huge difference in Q-factor is what gives crystals their greater frequency stability, and turns them into ideal components for building crystal oscillator circuits.
What we are seeing is that a quartz crystal operates in a way that is very similar to an electrically tuned LC tank circuit but having a much higher Q-factor.
This is primarily because of its low series resistance (denoted as Rs). Due to this the quartz crystals mostly become a perfect choice for use in oscillators, especially when you need to work with very high-frequency oscillators.
Speaking about frequencies, the typical crystal oscillators can have oscillation frequencies that range from as low as about 40kHz to well over 100MHz. The exact frequency depends on the circuit configuration and the amplifying device which is being used.
Another interesting thing to note is that, the way the crystal is cut affects how it behaves and perform. Some crystals can vibrate at more than one frequency, giving rise to additional oscillations, which we call as overtones.
If the crystal is not uniformly thick, it may even give rise to multiple resonant frequencies, each causing what we refer to as harmonics (for example like second or third harmonics).
But the fundamental oscillating frequency for a quartz crystal typically remains much stronger than these secondary harmonics that surround it. This is exactly why the fundamental frequency is generally the one that we use.
From the graphs we have examined so far, we have seen that a equivalent circuit of a crystal consists of three reactive components; two capacitors and an inductor. That is why we find that there are two resonant frequencies—the lower one is the series resonant frequency and the higher one is the parallel resonant frequency.
As we have studies in our previous discussions, an amplifier circuit will oscillate as long as it has a loop gain greater than, or equal to 1 and the feedback remains positive.
In the case of a Quartz Crystal Oscillator circuit, the oscillator will produce oscillations at the fundamental parallel resonant frequency of the crystal, because the crystal naturally wants to oscillate when a voltage source is applied.
But there is more to it. It may be further possible for us to “tune” a crystal oscillator to any frequency, even at the harmonic of the fundamental frequency, such as the 2nd, 4th, or 8th harmonics. These type of crystal oscillators are known as Harmonic Oscillators.
On the other hand, we find that the Overtone Crystal Oscillators operate at odd multiples of the fundamental frequency, such as the 3rd, 5th, or 11th harmonics. Generally speaking, the crystal oscillators which can function at overtone frequencies operate by using their series resonant frequency.
Solving a Quart Crystal Oscillator Problem #2
Consider a precision-cut quartz crystal having a series resistance of Rs = 990 Ω, a series capacitance of Cs = 0.052pF, and a series inductance of Ls = 3.2 H.
The parallel capacitance across the terminals of the crystal is Cp =9.8 pF.
Let us calculate the series and parallel resonant frequencies of the crystal, which can be crucial for understanding its oscillation behavior across different circuits.
To calculate the series oscillating frequency we can use the following formula:
fs = 1/[2 * π *√(Ls * Cs)]
= 1/[2 * π *√(3.2 * 0.052 * 10-12)]
= 390160 = 390 kHz
∴ fs = 390 kHz
To calculate the parallel oscillating frequency we implement the following formula:
fp = 1/(2 * π * √Ls[(Cp * Cs)/(Cp + Cs)]
= 1/[2 * π * √3.2{((9.8 * 10-12) * (0.052 * 10-12))/((9.8 * 10-12) + (0.052 * 10-12))}]
= 1/(2 * π * √3.2((5.096e-25)/(9.852e-12))
= 1/(2 * π * √1.6552172e-13
= 1/(2 * π * 4.06843606e-7
= 391194 Hz or 391 kHz
∴ fp = 391 kHz
From the above calculations we can realize that the frequency of oscillation for the crystal will lie somewhere withing the range of 390 kHz and 391 kHz.
Understanding the Colpitts Quartz Crystal Oscillator
In crystal oscillator circuits, we normally make use of bipolar transistors (BJTs) or the Field-Effect Transistors (FETs) to drive the circuit.
This is because, although we can use the operational amplifiers (op-amps) perfectly in many low-frequency oscillator circuits (which may range upto around 100kHz), op-amps may lack the necessary bandwidth to handle the higher frequencies required for crystals operating above the 1MHz frequency range.
You will find that the structure of a Crystal Oscillator circuit is very much similar to the Colpitts Oscillator design that we previously studied.
The main difference can be actually seen in the feedback loop; here instead of the LC (inductor-capacitor) tank circuit which normally gives out the oscillations, we use a quartz crystal to create the feedback loop, in this case.
The quartz crystal here takes the place of the LC circuit, allowing the oscillator to operate with much higher precision and stability, as seen in the example below.
Circuit Working
The type of crystal oscillator circuit shown above is designed by using a common collector amplifier, which we also call as an emitter-follower configuration.
To break this down a bit more, the resistors R1 and R2 work together to set the DC bias level at the base of the transistor. In simple terms, the R1 and R2 make sure that the transistor is correctly powered and is ready to amplify the signals. The emitter resistor marked as RE, helps us to set the output voltage.
The resistor R2 is made to have a high value to avoid putting too much load on the crystal which is connected in parallel with it. This ensures that the crystal operates efficiently without the interference from the resistor.
In this design the transistor which is used is a BJT 2N4265, a general-purpose NPN transistor. This BJT can be seen connected in a common collector configuration, which means that it can handle signals that need to be switched at speeds over 100 MHz.
This is way much faster than the typical operating range of the quartz crystal, which usually oscillates between 1 MHz and 5 MHz.
Looking at the circuit diagram of this Colpitts Crystal Oscillator, you will see that two capacitors marked as C1 and C2, are placed to “shunt” or divert some of the signal from the output of the transistor.
These capacitors play a critical role because they are able to reduce the strength of the feedback signal going back to the transistor. But there is a catch here; the transistor’s gain (its ability to amplify) limits or inhibits how big the value of C1 and C2 can be.
If these capacitors are too large in their values then the transistor will not be able to amplify the signal properly.
In addition, we must keep the output signal at a modest amplitude to avoid stressing the crystal. If the input signal is too powerful, the crystal may vibrate excessively, causing it to overheat and potentially destroy itself.
The crystal is a sensitive component that relies on accurate vibration specifications, so limiting the output power is critical to keeping it running smoothly and avoiding damage.
Understanding the Pierce Quartz Crystal Oscillator
The Pierce Oscillator is another popular design for making the quartz crystal oscillator circuits. It is quite similar to the Colpitts Oscillator in terms of its overall structure but there are some key differences that make the Pierce Oscillator ideal for certain crystal oscillator applications.
Just like the Colpitts design, the Pierce oscillator also incorporates a quartz crystal into its feedback loop which makes it perfect for generating stable and accurate frequencies.
But, despite the similarities, the one major difference that we see is that the Pierce Oscillator operates as a series resonant circuit. Now this looks different from the Colpitts oscillator, in which there is a parallel resonant circuit.
The choice of the type of resonance configuration impacts how the circuit behaves, with series resonance being the main feature of the Pierce oscillator design.
In a typical Pierce oscillator circuit you may find that it uses a JFET (Junction Field Effect Transistor) as its main amplifying device.
The JFET appears to be a great choice for this type of oscillator because it has a very high input impedance. In simple words, this means that this configuration does not load down the crystal so that it allows the crystal to oscillate freely without interference from the transistor itself.
In the Pierce Oscillator circuit we find that the crystal is placed between the Drain and Gate terminals of the JFET, and this crystal is connected through a capacitor marked as C1.
This configuration guarantees that the crystal controls the oscillation frequency while the JFET amplifies the signal and keeps the circuit working smoothly.
Because of the way the components are configured in the Pierce Oscillator arrangement, this design has great frequency stability making it a popular choice for crystal oscillator circuits.
Circuit Working
In this straightforward Pierce Crystal Oscillator circuit, the crystal itself becomes responsible for determining the frequency of oscillations.
It operates at its series resonant frequency denoted as fs, and this gives rise to a low impedance path between the output and input terminals.
Because of this circuit arrangement, we are able to get a 180-degree phase shift right at the resonance point, causing the feedback loop to become positive; which simply reinforces the oscillations further.
The sine wave output generated from the circuit is limited in amplitude upto the maximum supply voltage range, at the Drain terminal, which ensures that the output stays within a controlled range.
The resistor R1 is critical in the circuit since it determines not only how much feedback is transmitted back into the system, but also controls the drive to the crystal.
Another important component of the design is the radio frequency choke (RFC) which guarantees that the voltage across it reverses with each cycle, keeping the oscillations flowing smoothly.
Pierce Oscillator circuits with their simple and efficient architecture, may be utilized in a variety of daily devices like as digital clocks, watches, and timers since they require few components to perform efficiently.
In addition to the transistors and the FETs, you can also create a basic parallel-resonant crystal oscillators that function similarly to the Pierce oscillator by using a CMOS inverter as the amplifying element.
The core of this simple quartz crystal oscillator consists of a single inverting Schmitt trigger logic gate such as the TTL 74HC19 or CMOS 40106/4049.
In this circuit setup, an inductive crystal and two capacitors form the most important components. These two capacitors are particularly important because they help to define the load capacitance of the crystal.
We can also see a series resistor in this circuit that limits the drive current through the crystal and also isolates the output of the inverter from the complex impedance created by the combination of the capacitors and the crystal.
Understanding a CMOS Crystal Oscillator Circuit
In the circuit shown above, the crystal oscillates at its series resonance frequency which is very crucial to obtain a stable operation of the circuit. The CMOS inverter which plays a central role in this circuit, is initially biased right into the middle of its operating region.
This happens because of the feedback resistor R1 which ensures that the inverter operates in a region where it has a high gain—essential for a stabilized oscillation. For this circuit we have used the resistor R1 with a value of 1MΩ is used.
However this 1M value is not supposed to be fixed, as long as this is more than 1MΩ, the circuit is going to work just fine. Additionally a second CMOS inverter is included to create a buffer stage for the output, making it sure that the oscillator can drive the connected load effectively without any causing any problems to the oscillations.
You will find it interesting the way in which the oscillator achieves the necessary 360-degree phase shift. The inverter stage itself provides 180 degrees of phase shift and then the crystal along with its capacitor network contributes the remaining 180 degrees required for the generation of the oscillations.
The advantage of this CMOS-based crystal oscillator is that it continuously and automatically adjusts itself to maintain this phase shift, ensuring that the circuit always stays oscillating without needing any manual adjustments.
One thing to note about the CMOS crystal oscillator is that, unlike the transistor based crystal oscillator circuits which generates a clean sinusoidal waveform output, this configuration produces a square wave output.
This is because the circuit uses digital logic gates (inverters) which are designed to naturally switch between HIGH and LOW logic states.
The frequency at which this square wave oscillates depends on the switching speed of the logic gate used. Meaning, the overall operating frequency of CMOS oscillators is determined by the characteristics of the CMOS inverter in the circuit.
Understanding Microprocessor Crystal Quartz Clocks
This tutorial cannot be ended until we fully understand the Quartz Crystal Oscillators and know their important role in microprocessor clocks. You might have seen that almost all microprocessors, microcontrollers, PICs, and CPUs incorporate a Quartz Crystal Oscillator which determine and fix their clock frequency.
The reason for this is simple; crystal oscillators provide a far superior accuracy and frequency stability compared to other types of oscillators like the RC resistor-capacitor or the LC inductor-capacitor oscillators, which is exactly what makes them the first preference for such applications.
The clock generated by the crystal is critical to how fast the processor can run and handle data. For instance, if a microprocessor or microcontroller has a clock speed of 1 MHz, it means it can process data a million times per second—essentially it performs one operation per clock cycle. The higher the clock speed, the faster the processor works.
Now, generating this clock waveform is not overly complicated. In fact, all you really need to get that clock signal for your microprocessor is a quartz crystal and a couple of ceramic capacitors.
Typically the values of these capacitors can range between 15 to 33 picofarads (pF) which are easy to get from the market and is widely used in such circuits.
This basic circuit helps the microprocessor to function at the desired frequency with extremely good precision and reliability which ensures a smooth and an efficient data processing.
Understanding Microprocessor Oscillators
Most of the microprocessors, microcontrollers, and PICs that we use today have two dedicated oscillator pins, which are normally labeled as OSC1 and OSC2.
You can connect these pins to an external quartz crystal circuit, a standard RC oscillator network, or even a ceramic resonator. In this design the quartz crystal oscillator generates a steady stream of square wave pulses.
The crystal itself controls the frequency of these pulses, ensuring that everything works consistently and with perfect accuracy.
What we need to understand is that, the fundamental frequency produced by the crystal regulates the delivery of the instructions that control the processor. In simple words, the frequency of the crystal controls how fast the microprocessor can operate, which in turn controls the key functions like the master clock and the system timing.
So you can think of it as the heartbeat of the system which keeps all the internal processes correctly synchronized. Whether you are working on a small microcontroller project or using a larger CPU, this crystal becomes the crucial element which ensures that everything runs smoothly and in time.
References: Crystal oscillator
How Does a Quartz Crystal Oscillator Work?