Author Topic: How to get a clock signal from a crystal oscillator  (Read 3949 times)

0 Members and 1 Guest are viewing this topic.

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
How to get a clock signal from a crystal oscillator
« on: September 12, 2017, 02:04:07 am »
Hi all,

How can I generate a stable clock signal (say, 5V square wave) from a simple Crystal oscillator (e.g. those metallic HC-49 package kind)?
Specifically I'm looking at 1 to 2MHz range, but a more general answer will be appreciated too  :)

I'm asking this because I have this IC which has a clock-in pin, and I have these crystals, and I want to make them work together...
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4367
  • Country: au
  • Question Everything... Except This Statement
Re: How to get a clock signal from a crystal oscillator
« Reply #1 on: September 12, 2017, 02:08:17 am »
I would say use 2 inverters, 1 is the main oscialltor, 1 is the buffer to reduce loading effects.

The main inverter has a series resistor if lets say 1K for that frequency, going to one of the crystals pins, you have your loading capacitors of roughly equal to your crystals capacitance, then the other end of the crystal feeding the inverter input, you would also want to place a 1M resistor across the output and input of this inverter to make sure it starts up reliably.

The second inverter would take the same input as the first and is acting as a buffer.
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2172
  • Country: au
Re: How to get a clock signal from a crystal oscillator
« Reply #2 on: September 12, 2017, 02:10:30 am »
I would say use 2 inverters, 1 is the main oscialltor, 1 is the buffer to reduce loading effects.

The main inverter has a series resistor if lets say 1K for that frequency, going to one of the crystals pins, you have your loading capacitors of roughly equal to your crystals capacitance, then the other end of the crystal feeding the inverter input, you would also want to place a 1M resistor across the output and input of this inverter to make sure it starts up reliably.

The second inverter would take the same input as the first and is acting as a buffer.

The capacitors are supposed to be equal to the load capacitance (maybe x2 or /2) states in the datasheet, right? Something like 18 pF often. Seems like assuming that it's equal to the measured capacitance of the crystal is asking for trouble?
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4367
  • Country: au
  • Question Everything... Except This Statement
Re: How to get a clock signal from a crystal oscillator
« Reply #3 on: September 12, 2017, 02:13:58 am »
It will get it going, it may not be 100% stable, but it will oscillate at roughly that frequency, At the same time i am ballparking the series resistance for the crystal, and my advice could be massively overdriving the thing, but it should get it going.
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2172
  • Country: au
Re: How to get a clock signal from a crystal oscillator
« Reply #4 on: September 12, 2017, 02:21:58 am »
Fair enough, it just seemed a bit odd to give such definitive-sounding advice when that's not the nominal value at all. Point granted that it'll probably oscillate, albeit not at the right frequency.

Anyway, if one wants to nerd out and get an accurate frequency, this advice seems helpful.
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: How to get a clock signal from a crystal oscillator
« Reply #5 on: September 12, 2017, 02:30:04 am »
I would say use 2 inverters, 1 is the main oscialltor, 1 is the buffer to reduce loading effects.

The main inverter has a series resistor if lets say 1K for that frequency, going to one of the crystals pins, you have your loading capacitors of roughly equal to your crystals capacitance, then the other end of the crystal feeding the inverter input, you would also want to place a 1M resistor across the output and input of this inverter to make sure it starts up reliably.

The second inverter would take the same input as the first and is acting as a buffer.

Ok, a bit slower please...  ;)
Inverter - would that be a NOT gate, like those Logic ICs?
1K resistor - How did you decide on that value?
Loading capacitors - Those between the crystal's pins and GND?
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4367
  • Country: au
  • Question Everything... Except This Statement
Re: How to get a clock signal from a crystal oscillator
« Reply #6 on: September 12, 2017, 04:56:52 am »
Yes a not gate. The series resistance i chose as 12MHz is 200 ohms, and a 32k is a few K. This is to limit the amount of heat on the crystal. You want it strong enough to be stable. But not so much that the crystal begins deforming.

The capacitors i mentioned are the 2 to ground. With this gain limited oscilattor you should be able to use calculators like those for an arduino328p.

The 1M resistor across the inverter is what makes it gain limited.
 
The following users thanked this post: igendel

Offline Ice-Tea

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: be
    • Freelance Hardware Engineer
Re: How to get a clock signal from a crystal oscillator
« Reply #7 on: September 12, 2017, 06:55:39 am »
Just to be clear: you can get the wholde deal, with a nice logic clock signal out, in a single package as well...
eBay shop with all the gear you need!
FS: Agilent 54825A, R&S CMU200, CRTU, SMIQ06L, Marconi 6201B, Lecroy WP 950, 9354TM, 9354M, 9374L LC584A, Tek THS720P, TDS7154B, Anritsu MG3671A 2.75G I/Q RF gen, Keithley 238 SMU, HP 8642B, 8903A, 8110A, 8156A
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: How to get a clock signal from a crystal oscillator
« Reply #8 on: September 12, 2017, 07:39:14 am »
Yes a not gate. The series resistance i chose as 12MHz is 200 ohms, and a 32k is a few K. This is to limit the amount of heat on the crystal. You want it strong enough to be stable. But not so much that the crystal begins deforming.

The capacitors i mentioned are the 2 to ground. With this gain limited oscilattor you should be able to use calculators like those for an arduino328p.

The 1M resistor across the inverter is what makes it gain limited.

Great, thanks - I'll give it a try as soon as I can.


Just to be clear: you can get the wholde deal, with a nice logic clock signal out, in a single package as well...

I've been looking for something like this too, but couldn't find an exact match - the closest thing was PLL clock multipliers. Can you please tell me the name of a specific component? Thanks!
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2172
  • Country: au
Re: How to get a clock signal from a crystal oscillator
« Reply #9 on: September 12, 2017, 07:52:35 am »
I've been looking for something like this too, but couldn't find an exact match - the closest thing was PLL clock multipliers. Can you please tell me the name of a specific component? Thanks!

Digikey.com.il oscillators between 1 and 2 MHz.
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: How to get a clock signal from a crystal oscillator
« Reply #10 on: September 12, 2017, 08:32:06 am »
Digikey.com.il oscillators between 1 and 2 MHz.

Oh, I thought you meant an IC that takes a passive crystal and outputs a clock signal. I already have the crystals.
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 9907
  • Country: us
  • DavidH
Re: How to get a clock signal from a crystal oscillator
« Reply #11 on: September 12, 2017, 09:52:31 am »
How can I generate a stable clock signal (say, 5V square wave) from a simple Crystal oscillator (e.g. those metallic HC-49 package kind)?

AN12 - Circuit Techniques for Clock Sources - Linear Technology

Single transistor crystal oscillators are more reliable than gate oscillators but gate oscillators are usually good enough.
 
The following users thanked this post: igendel

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: How to get a clock signal from a crystal oscillator
« Reply #12 on: September 12, 2017, 10:36:00 am »
Google "crystal oscillators application note", lots of hits, on design
considerations.

https://1drv.ms/f/s!Al2JgiX7_qf0iw6V0-oqd0dY7YPd

Regards, Dana.
« Last Edit: September 12, 2017, 10:11:48 pm by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: How to get a clock signal from a crystal oscillator
« Reply #13 on: September 12, 2017, 11:04:20 am »
AN12 - Circuit Techniques for Clock Sources - Linear Technology
Single transistor crystal oscillators are more reliable than gate oscillators but gate oscillators are usually good enough.

Thanks, I'll read that.

Google "crystal oscillators application note", lots of hits, on design considerations.

Yes, I definitely should have thought of that  :)
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 8051
Re: How to get a clock signal from a crystal oscillator
« Reply #14 on: September 12, 2017, 03:56:20 pm »
If you want to use the crystal in a Pierce oscillator using a logic gate, read T.I's Use of the CMOS Unbuffered Inverter in Oscillator Circuits

The various crystal manufacturers Pierce oscillator notes are often also worth a read. e.g. http://www.rakon.com/component/docman/doc_download/223-ic-crystal-oscillator-circuits?Itemid=

Its worth noting that probing such an oscillator with a x1 scope probe at the inverter input side of the crystal will almost certainly stop it and even a x10 probe will disturb its operation either side of the crystal and may cause a marginal oscillator to either start working or fail when probed.  If you *really* need the waveform and don't have a low capacitance active probe, you need to replace the load capacitance with the probe + a much larger series capacitor to block DC e.g. 1.5nF, with a shunt trimmer adjusted so the capacitance 'seen' by the crystal is the same as the removed load capacitor.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 13110
  • Country: gb
  • 0999
Re: How to get a clock signal from a crystal oscillator
« Reply #15 on: September 12, 2017, 06:28:57 pm »
As mentioned above, you need to use an unbuffered logic gate. I like the 74LVC1GX04 because it's compact, but the 74LVC1404 should be better, because it has a Schmitt trigger buffer and a disable option to save power, when it's not needed.
http://www.ti.com/lit/ds/symlink/sn74lvc1gx04-ep.pdf
http://www.ti.com/lit/ds/symlink/sn74lvc1404.pdf
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: How to get a clock signal from a crystal oscillator
« Reply #16 on: September 13, 2017, 12:06:30 am »
Its worth noting that probing such an oscillator with a x1 scope probe at the inverter input side of the crystal will almost certainly stop it and even a x10 probe will disturb its operation either side of the crystal and may cause a marginal oscillator to either start working or fail when probed.

Hmmm... a serious trap for young players!  :D
Thanks for the warning. I'll probably test the square wave by feeding it as an external clock for a little MCU and watching the Clock Out signal.

Thanks again everyone for the valuable information!
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline CD4007UB

  • Contributor
  • Posts: 41
  • Country: gb
Re: How to get a clock signal from a crystal oscillator
« Reply #17 on: September 13, 2017, 01:04:55 am »
For a 1 or 2 MHz clock, you could use an old-fashioned CD4007 chip - cheap, versatile, and still available in a through-hole package (rather than SMD), which makes it easy to use on solderless breadboard. Some of our students have fun building a quartz oscillator as a project.

For a simple introduction, see Ray Marston's article at http://www.nutsvolts.com/magazine/article/fet_principles_and_circuits_part_3 .
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: How to get a clock signal from a crystal oscillator
« Reply #18 on: November 17, 2017, 10:15:04 am »
So it's been a while... I had some delays because of the crystals I thought I had, eBay sellers etc., but I finally got to doing this.

Here's what's on the improvised circuit:
- NOT gate by TI (SN74AHC1G04)
- 1.8432MHz crystal with 18pF load capacitors (I guessed the value - the crystals came with no datasheet)
- 1M resistor between inverter input and output.
- 1K resistor in series from inverter output to crystal input. It's small but it's there  :)

I started by giving it 5V and measuring the output with the scope (Keeping in mind the warning about this), x10 probe.
The frequency looks very good (well, for a nameless crystal anyway), but the ringing is crazy - the resulting signal is 9V peak-to-peak!

Now, what are the odds that the ringing is just an artifact from the probe? I wouldn't want to feed these extremes into the clock pin of an MCU...

Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 8051
Re: How to get a clock signal from a crystal oscillator
« Reply #19 on: November 17, 2017, 10:30:26 am »
74AHC without a ground plane and local decoupling right next to the gate's Vcc pin is asking for trouble.  I don't see any decoupling on that board at all.   If you think the ringing may be a probe artefact due to excessive ground lead length, remove the probe ground clip and tip spring hook, stretch some bare wire and wind it around a suitable former to form a three turn coil that fits snugly on the probe ground ring, bend the end at rightangles to lie parallel with the probe tip, cut it to a point the same length as the probe tip, and probe directly at the IC pins.  The rightangle bend *MUST* be touching the ground ring.
 
The following users thanked this post: igendel

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 4134
  • Country: nl
Re: How to get a clock signal from a crystal oscillator
« Reply #20 on: November 17, 2017, 10:36:40 am »
If you think the ringing may be a probe artefact due to excessive ground lead length, remove the probe ground clip and tip spring hook, stretch some bare wire and wind it around a suitable former to form a three turn coil that fits snugly on the probe ground ring, bend the end at rightangles to lie parallel with the probe tip, cut it to a point the same length as the probe tip, and probe directly at the IC pins.  The rightangle bend *MUST* be touching the ground ring.

Or, without so many words:

Keyboard error: Press F1 to continue.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 8051
Re: How to get a clock signal from a crystal oscillator
« Reply #21 on: November 17, 2017, 10:48:04 am »
Nice picture of the commercial offering, but with the rightangle away from the ground ring, its got more self-inductance than if its right up against it, and you need springy brass wire as copper wire of that diameter will be too floppy at that length side-arm, so it isn't ideal for DIY.  Either will be vastly preferable to a 4" ground lead.

Another approach is to form a single turn ground spring from copper plated steel wire (e.g. MIG wire) with the leg at rightangles to the coil, and solder the leg direct to the nearest ground point, bending it so the probe tip will be right on the signal to be tested.  With care, and a helping hands supporting the probe body, that can let you do hands-free measurements.
« Last Edit: November 17, 2017, 10:50:07 am by Ian.M »
 

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: How to get a clock signal from a crystal oscillator
« Reply #22 on: November 17, 2017, 11:19:09 am »
With all the excitement I forgot to decouple the inverter  :D

I added a 0.1uF ceramic (THT) to the inverter Vcc now, It actually made the output messier (because there's no proper ground plane?), the scope couldn't even find an alignment by itself, thought it was 30MHz or something.

Removed the decoupling cap, tried to probe without the long ground wire (I don't have a suitable brass wire so I improvised something similar). The ringing got better, especially the undershoot, but still significant (see image).



Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4367
  • Country: au
  • Question Everything... Except This Statement
Re: How to get a clock signal from a crystal oscillator
« Reply #23 on: November 17, 2017, 11:30:55 am »
If your happy with your probing technique, try upping that drive strength resistor to 4.7K,

It is likely not so much a ground plane (your distances are way smaller than tranmission line theory), but where the 2 capacitors meet with ground, ideally they would be directly at the inverters GND pin, this way you close the loop to being as small as possible, reducing inductance,

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 8051
Re: How to get a clock signal from a crystal oscillator
« Reply #24 on: November 17, 2017, 11:51:51 am »
74AHC outputs typically have a slew rate of approx 0.5V/ns.   For a transition between 0 and 3.3V that will give approx 6ns risetime unloaded.   That transition 'looks' like a 1/4 cycle of a >600MHz sinewave, so if the scope and active probe bandwidth is under 500MHz you haven't got a hope in hell of seeing what's actually going on, and you really need 1GHz bandwidth to be certain.   During the risetime, the gate pulls a current pulse from its supply, which can be approximated as a half cycle at >1200 MHz.  That would be above the self resonant frequency of a 100nF leaded cap.  Fortunately the situation will be a bit better as soon as the gate is loaded, but the transition is still likely to have HF components >100MHz.

Hook up your probe to a Jim Williams pulse generator (see https://www.eevblog.com/forum/blog/eevblog-306-jim-williams-pulse-generator/) and see what the ringing looks like.  If its period is similar to that you are observing in your oscillator circuit, odds are, its a probe artefact.

For decoupling, try 1nF ceramic in a small SMD package, glued directly on top of the chip, and wired as directly as possible to its power and ground pins.   Put the 0.1uF leaded ceramic across the power input to the breakout board, and *PRAY*! 
« Last Edit: November 17, 2017, 11:54:34 am by Ian.M »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf