## EEVblog 1614 - Circuit Design TIP: Crystal Oscillators https://youtu.be/kjOAkHqlQw0 ### General When designing clock systems: Individual Crystal OR External Crystal Oscillator HC49 is the package type. ![[hc49us-component-package-dimensions-land-pattern.DIeXnBME.png]] Requires 2 Load Capacitors on the X1 and X2 pins. Old school crystal circuitry would also sometimes have a 10MΩ bridging the X1 and X2 pins. Manufacturing Variations within individual crystal specimens may result in inconsistencies in your circuits. The crystals usually have larger footprint capacitors. ### Calculating Load Capacitors You can't just put whatever value you want. You need to pick the values carefully based on the crystal and the stray PCB capacitance. ![[Pasted image 20241213224047.png]] Important Distinctions - The Load Capacitance is specified in the datasheet for the crystal. - The listed Load Capacitance is NOT the capacitor you put on the board. - The Load Capacitance is the NET capacitance after considering the stray PCB trace capacitances as well as any external capacitances. - Nevertheless, those external components still end up getting called the "Load Capacitors" even though they don't perfectly correspond to the "Load Capacitance" listed on datasheets. Really you start with the spec's Load Capacitance, estimate the stray capacitance, and then solve for the external capacitor's value. How to calculate C1 and C2: ``` The following formula may be used to calculate a parallel resonant crystal's external load capacitors: CL = ((CX1 x CX2) / (CX1 + CX2)) + Cstray where: CL = the crystal load capacitance Cstray = the stray capacitance in the oscillator circuit, which will normally be in the 2pF to 5pF range. Assuming that CX1=CX2 then the equation becomes: CL = ((CX1 x CX1) / (2 x CX1)) + Cstray CL = (CX1 / 2) + Cstray Rearranging the equation, we can find the external load capacitor value: CX1 = 2(CL - Cstray) For example, if the crystal load capacitance is 15pF, and assuming Cstray=2pF, then: CX1 = CX2 = 2(15pF - 2pF) = 26pF It is difficult to know exactly what the stray capacitance is, but if you find the oscillation frequency is too high, the load capacitor values can be increased. If the frequency is too low, the load capacitors can be decreased. The device data sheet may also define a maximum crystal series resistance Rs. ``` ### Scope Probe Load Capacitance Oscilloscope X1 probe on the crystal will actually add additional load capacitance, which then throws off the timing of the crystal's oscillations: ``` ### [@Xaelloss](https://www.youtube.com/@Xaelloss) [7 months ago (edited)](https://www.youtube.com/watch?v=kjOAkHqlQw0&lc=UgxOLaIRoZ2sGEhYNNB4AaABAg) Suggestion to probe the crystal with a x1 probe reminded me of a story when a bloke had his ATMega 169 device RTC drift at least 1 hour per year with a precision 32 kHz crystal but when he probed it, he would see nothing wrong. Ultimately this was solved by adding some extra caps, against the actual datasheet. Turned out his oscilloscope probe would introduce just enough stray capacitance into the oscillator to stabilize and show correct frequency! Atmel would later confirm that to have been a hardware bug. ``` ### HF Leakage Concern Since it's a high-frequency, high-impedance circuit, it has special needs. You can't just run high-frequency signals nearby the crystal since they might leak into the crystal and interfere with it. On option is a ground-connected Guard Trace circuit wrapping around the crystal subsystem like a fence. [[Additional Approaches to Ensuring Crystal Stability]] **GPT on Guard Traces:** ``` Purpose A ground-connected guard trace functions as an isolating boundary that can help to shield sensitive circuit elements from interference such as crosstalk. Implementation Place a continuous guard trace surrounding the oscillator's traces and connected to the ground plane. This creates an electric potential barrier. Effectiveness The guard trace absorbs and shunts away leaking high-frequency signals to the ground, reducing the interaction with the oscillator and maintaining signal integrity. ``` ### Crystal Flexibility Any chip that demands a crystal oscillator and has the X1/X2 pins, doesn't necessarily need a crystal. You can use an external crystal oscillator package, or even just a synthetic frequency. Part Example: SG2016CAN (2.0x1.6mm) HT9200A DTMF Generators ![[Pasted image 20241213224617.png]] X1 can be considered a `Digital Input` X2 can be considered a `Digital Output` EN will short X1 to ground. So you can tap off X2 if you need a !CLK signal. It can't drive much, but it can do something. Some chips have the load capacitors built in, and you don't need them externally. 32.768Hz for Real Time Clocks 3.579545MHz for "Color Burst" Frequency or DTMF Decoding [[NTSC Color Burst and DTMF]]