Author Topic: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators  (Read 5407 times)

0 Members and 1 Guest are viewing this topic.

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 38722
  • Country: au
    • EEVblog
EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« on: May 11, 2024, 01:06:59 am »
You can easily replace any chip crystal circuit with a dedicated external crystal oscillator. Reducing your BOM count, and making your design easier, smaller, and potentially more robust.

Cyber City Circuits: https://www.youtube.com/@cybercitycircuits
https://twitter.com/MakeAugusta/status/1788651197055827992

 
The following users thanked this post: SeanB

Online westfw

  • Super Contributor
  • ***
  • Posts: 4316
  • Country: us
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #1 on: May 11, 2024, 08:19:02 am »
One of the things I've noticed, if you're thinking of using an oscillator with a microcontroller, is that oscillators have pretty high current consumption, compared to modern microcontrollers.  And it won't get shut off during the fancy low-power modes, either :-(
 
The following users thanked this post: nctnico

Online nali

  • Frequent Contributor
  • **
  • Posts: 714
  • Country: gb
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #2 on: May 11, 2024, 08:29:03 am »
What would be nice is something covering how to correctly calculate the loading caps for a MCU crystal. I don't think it's uncommon to think I have a 12pF xtal so I'll use 12pF capacitors, or tha app note shows 22pF caps so I need a 22pF xtal etc.

For a lot of MCUs it's close-ish and Just Works, though for radio MCUs (WiFi Bluetooth etc) it can make a difference.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4778
  • Country: dk
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #3 on: May 11, 2024, 11:23:56 am »
I'm pretty certain that I've seen some datasheets that tell you to feed an external clock into X2
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6984
  • Country: fi
    • My home page and email address
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #4 on: May 11, 2024, 09:49:51 pm »
Yep; the i.MX RT1060 Processor Reference Manual (as used in Teensy 4.x) describes three different ways of replacing the 24MHz crystal with an external source, with the suggested one being driving XTALI at nominal 1.1V and leaving XTALO externally floating.  (The other two are overdriving both differentially, or overdriving XTALO and capacitively loading XTALI, which also happen to work because it uses a differential amplifier to detect oscillation internally.)

Even old ATmega32U4 (older AVR) datasheet explicitly mentions that you can leave XTAL2 floating and drive XTAL1 with a clock source (with less than 2% variation between consecutive clock cycle durations), although the CLKSEL fuses need to be programmed to a dedicated value (0000) in that case.

I too would prefer good advice on calculating/choosing proper loading caps, though.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14865
  • Country: de
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #5 on: May 12, 2024, 05:18:06 am »
The AVRs have extra fuse settings for external clock and crystal only. However the µC also works with the setting for just the crystal and using the external clock.  An external cock is a typical method to recover a chip with somehow wrong fuse settings for the clock.
For the AVRs in 32 kHz mode, the is a common errata that effects most (if not all of them): at least the older version supposedly had optional internal capacitors to activate, but these usually don't work.


The load capacitors for the crystals are not that obvious. The value given in the datasheet is usually the one effectively parallel to the cystall and the 2 caps in the circuit are effectively in series for the RF part.  So if the datasheet calls for 10 pF one would want 2 x 20 pF. In addition there is some parasitic capacitance from the PCB and the oscillator itself. So the suitable cap size is something like 2 x load cap specs minus some 2-3 pF.

The small size oscillator chips are usually only for 3.3 V , but rarely for 5 V supply.  The older style large cans are for 5 V, but they tend to use quite some power and obvous space. This may be more than a lower power µC needs.
A positive side of an external oscillator is that they are better shielded. Just the crystal at a µC can be effected by ground bounce, neighboring pins and µC internal signals - it is not a super stable clock.
 

Online Dr. Frank

  • Super Contributor
  • ***
  • Posts: 2425
  • Country: de
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #6 on: May 12, 2024, 06:41:35 pm »
Copying my comment from YT:

For stable and safe operation of an XTAL oscillator, especially in a mass production and in a wider environmental temperature range, those standard 10, 20pF capacitors are undesirable, especially when built in a (digital type) oscillator circuit.
"Analogue oscillators" are preferable, but digital design engineers usually don't have that knowledge any more. It's too costly, as well, to mix analogue and digital on a chip.
We usually send our new oscillator circuits (inside an embedded controller) to our XTAL manufacturers, like NDK, Kyocera, murata, former Tele Quartz, now AXTAL, etc., requesting a specific center frequency and XTAL type / case.
They then determine their manufacturing parameters (cutting, trimming, blank type) and determine the optimum C1, C2 values, including layout pattern. That gives optimum start-up time and best "oscillation margin". C1, C2 should always be external.

Please search for documentation on "XTAL oscillation margin" for more details, as well, how one can measure these parameters on his own.

Attached are a few nice photos of a fused silica / quartz bar, 20cm x 2cm, artificially drawn in an autoclave.
The crystal blanks are cut out of such bars.

Frank

https://www.ndk.com/en/products/crystal/ultimate/
« Last Edit: May 12, 2024, 06:47:03 pm by Dr. Frank »
 
The following users thanked this post: EEVblog, SeanB, Whales

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15444
  • Country: fr
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #7 on: May 12, 2024, 10:32:22 pm »
What would be nice is something covering how to correctly calculate the loading caps for a MCU crystal. I don't think it's uncommon to think I have a 12pF xtal so I'll use 12pF capacitors, or tha app note shows 22pF caps so I need a 22pF xtal etc.

For a lot of MCUs it's close-ish and Just Works, though for radio MCUs (WiFi Bluetooth etc) it can make a difference.

The problem is that when just a few pF of difference matter in some specific application (which is rarely the case for "MCU oscillators", but could be in some other cases), parasitic capacitance from a variety of sources (from the PCB to even the relative humidity, to component packages, capacitor tolerance and trace length...) will matter and if you can't take these into account, you can calculate to your heart's content, it won't get you very far. You may need expensive simulation tools with the knowledge to use them.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15444
  • Country: fr
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #8 on: May 12, 2024, 10:50:33 pm »
One of the things I've noticed, if you're thinking of using an oscillator with a microcontroller, is that oscillators have pretty high current consumption, compared to modern microcontrollers.  And it won't get shut off during the fancy low-power modes, either :-(

Yep. That's two points making it a good reason to avoid using external oscillators if low-power is a concern.
 

Online westfw

  • Super Contributor
  • ***
  • Posts: 4316
  • Country: us
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #9 on: May 13, 2024, 06:35:28 am »
Quote
how one can measure these parameters on his own.
Is determining the "correct" capacitance(s) for an external crystal feasible for an amateur with cheap equipment?  Even if you carefully follow instructions, you usually hit a spot that reads "now make a wild guess at the stray capacitance of your chip packages and PCB."

Sure, I guess I could connect a frequency counter (or scope with freq counting ability) to some clocked pin and try "tuning" the crystals, but having a freq counter that is more accurate than the crystal is supposed to be seems ... somewhat unlikely.
 

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 38722
  • Country: au
    • EEVblog
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #10 on: May 13, 2024, 08:18:12 am »
Quote
how one can measure these parameters on his own.
Is determining the "correct" capacitance(s) for an external crystal feasible for an amateur with cheap equipment?  Even if you carefully follow instructions, you usually hit a spot that reads "now make a wild guess at the stray capacitance of your chip packages and PCB."

Most people and projects don't care about the absolute frequency of the crystal, if you did you generally be using a high precision TCXO or at the very least have an adjustable cap to trim it manually.
So as long as your oscillator isn't completely chucking a wobbly, you'll be fine with just the typical datasheet example values.
 

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 38722
  • Country: au
    • EEVblog
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #11 on: May 13, 2024, 08:21:05 am »
I'm pretty certain that I've seen some datasheets that tell you to feed an external clock into X2

Some chips might tri-state the internal inverter output, otherwise that's not going to work unless X2 is the input.
 

Online Dr. Frank

  • Super Contributor
  • ***
  • Posts: 2425
  • Country: de
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #12 on: May 13, 2024, 10:10:33 am »
Quote
how one can measure these parameters on his own.
Is determining the "correct" capacitance(s) for an external crystal feasible for an amateur with cheap equipment?  Even if you carefully follow instructions, you usually hit a spot that reads "now make a wild guess at the stray capacitance of your chip packages and PCB."

Sure, I guess I could connect a frequency counter (or scope with freq counting ability) to some clocked pin and try "tuning" the crystals, but having a freq counter that is more accurate than the crystal is supposed to be seems ... somewhat unlikely.

It's easy to determine the "oscillation margin" on your own, see e.g. description and YT videos by murata. 
If this O.M. is > 3 the chosen capacitors in conjunction with the given inverter work reasonable safe for commercial applications with low requirements.
That means, your choice of C1, C2 is "correct".
For Automotive application, i.e. more demanding requirements, you need an O.M. > 10.

You need to know the ESR of the XTAL from the datasheet to calculate this O.M.
Serious suppliers like NDK will have this already, others won't have it, so you would need access to an Impedance / Gain Phase Analyser, like the old HP 4194A (see HP AN 339-9).
Otherwise, you have to make some trial-and-error approaches to change C1,C2 until you achieve O.M. >3, >10.

I don't remember how NDK did the job, and which equipment they use. I guess they have an S-parameter analyzer for that and a dedicated test setup.

Edit: One important criterion was, to limit the power dissipation for the XTAL to <1mW, even for those simple inverter oscillators, by e.g. adding a serial resistor.

Frank
« Last Edit: May 13, 2024, 10:34:21 am by Dr. Frank »
 
The following users thanked this post: EEVblog

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4778
  • Country: dk
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #13 on: May 13, 2024, 11:37:31 am »
I'm pretty certain that I've seen some datasheets that tell you to feed an external clock into X2

Some chips might tri-state the internal inverter output, otherwise that's not going to work unless X2 is the input.

depends on how wimpy the X2 output driver is
 

Offline RLP

  • Contributor
  • Posts: 22
  • Country: nz
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #14 on: May 14, 2024, 08:26:02 am »
I once had a WiFi router which would connect to some ethernet devices at gigabit, some at 100Mbps, and some not at all. Amazon, who I bought it from, refunded me but didn't ask for it back (they'd have just binned it anyway after all). Years later, I opened it up, and found a missing load capacitor on an internal crystal, which was presumably throwing off the timing of the ethernet signals. I bodged on a through hole cap of approximately 20pF as a guess, in place of the missing 0402 SMD part, and it's worked perfectly since :-DD one would think the inductance of the long leads might be a problem but :-//. These things seem forgiving until you need precision, I guess.
« Last Edit: May 14, 2024, 08:29:21 am by RLP »
 

Offline shapirus

  • Super Contributor
  • ***
  • Posts: 1627
  • Country: ua
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #15 on: May 14, 2024, 08:47:39 am »
I bodged on a through hole cap of approximately 20pF as a guess, in place of the missing 0402 SMD part, and it's worked perfectly since :-DD one would think the inductance of the long leads might be a problem but :-//. These things seem forgiving until you need precision, I guess.
Yeah, it works fine even on a test board like this, at least up to 16 MHz:



There's apparently a lot of tolerance margin.
 

Offline jnissen

  • Regular Contributor
  • *
  • Posts: 66
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #16 on: May 14, 2024, 03:13:11 pm »
Reminds me of the XTAL oscillator I designed into a implantable medical instrument. Extremely low crystal speeds were required to provide both stability and low power. The issue in this case was not only calculating the proper capacitance to hang off the crystal but how much gain to put into the amplifier driving the thing. Thankfully there are some fairly good crystal oscillator simulation settings in Cadence Virtuoso to help out a designer.  Wasn't always the case. In the above situation we calculated that a startup and stable operation could take as long as 2 seconds. This is an eternity in simulation land and running all possible corners was problematic with limited compute resources. I had to old school it and shotgun the worst case corners and rely upon some analytical techniques of the data to fill in the gaps. 

Once the silicon got back we tested a variety of crystals across the IC and the startup behavior matched almost identically. If we sized the load caps incorrectly we could get situations where the startup failed to occur at all or took in excess of a few seconds. Obviously not a good situation if this happened in the OR and a persons body is open and ready to implant the thing! Needless to say we tested this thing every which way possible and across every split of silicon we could get from the FAB. IN our final design review with the customer they were extremely pleased as the prior art would often have chaotic startup and inconsistent power numbers. Bottom line there is a lot of engineering that goes into the crystal amplifier circuit for specialized crystal operation. 
 
The following users thanked this post: thm_w

Offline NaDobraNich

  • Regular Contributor
  • *
  • Posts: 89
  • Country: ca
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #17 on: May 15, 2024, 04:28:47 pm »
I do like little circuit tips like this.

Questions though,

1. What would I do if X1 and X2 aren't the labels? I have a module with an mcu on it, it wants OSC-IN and OSC-OUT. I assume based on this guide that OSC-IN, I would connect to my clock's output, seems reasonable. And what about MCU OSC-OUT? Just leave it floating?

2. If I have the RTC / 32khz clock next to my main micro, and I want to get this output to my module that is 15mm away. Is there any serious concerns here? Impedance match? Keep on the top layer microstrip or move to a stripline even though its going to have two vias? There is a bluetooth radio on board so I am included to use a stripline.

3. Can I just tap off the OSC-OUT on my oscillator? I guess I could use a CLOCK-OUT signal from my micro to the module, but then I'm not sure I would have that in all power modes and conditions of my MCU. How would I go about figuring out what two micros need to be run off the same clock?
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7236
  • Country: ca
  • Non-expert
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #18 on: May 15, 2024, 09:02:05 pm »
1. What would I do if X1 and X2 aren't the labels? I have a module with an mcu on it, it wants OSC-IN and OSC-OUT. I assume based on this guide that OSC-IN, I would connect to my clock's output, seems reasonable. And what about MCU OSC-OUT? Just leave it floating?

Yes, in is input, out is output left floating, I'm sure its in the datasheet.

Quote
2. If I have the RTC / 32khz clock next to my main micro, and I want to get this output to my module that is 15mm away. Is there any serious concerns here? Impedance match? Keep on the top layer microstrip or move to a stripline even though its going to have two vias? There is a bluetooth radio on board so I am included to use a stripline.

Its 32kHz, you don't need a transmission line.
Question is if the signal will be loaded too much, or noise injected, timing acceptable, which is up to you to verify. Probably not worth the 3 cents you would save.

Quote
3. Can I just tap off the OSC-OUT on my oscillator? I guess I could use a CLOCK-OUT signal from my micro to the module, but then I'm not sure I would have that in all power modes and conditions of my MCU. How would I go about figuring out what two micros need to be run off the same clock?

Again loading etc which is mentioned in the video. Using clock out means its buffered and you don't have to worry much about loading.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline NaDobraNich

  • Regular Contributor
  • *
  • Posts: 89
  • Country: ca
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #19 on: May 16, 2024, 10:43:05 pm »
Probably not worth the 3 cents you would save.

I don't get it?? You aren't suggesting that adding another time source for that module would be 3 cents right? It costs me more than 3 cents to pick and place any part. What is 3 cents?
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7236
  • Country: ca
  • Non-expert
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #20 on: May 16, 2024, 11:04:07 pm »
Probably not worth the 3 cents you would save.

I don't get it?? You aren't suggesting that adding another time source for that module would be 3 cents right? It costs me more than 3 cents to pick and place any part. What is 3 cents?

3.5 cents: https://www.lcsc.com/product-detail/Crystals_huaxindianzi-DP2032K76812001_C17702403.html
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 38722
  • Country: au
    • EEVblog
Re: EEVblog 1614 - Circuit Design TIP: Crystal Oscillators
« Reply #21 on: May 17, 2024, 03:47:58 am »
Probably not worth the 3 cents you would save.

I don't get it?? You aren't suggesting that adding another time source for that module would be 3 cents right? It costs me more than 3 cents to pick and place any part. What is 3 cents?

3.5 cents: https://www.lcsc.com/product-detail/Crystals_huaxindianzi-DP2032K76812001_C17702403.html

You can get a microcontroller for 3 cents:


How about a 1 cent regulator
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf