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

0 Members and 1 Guest are viewing this topic.

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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...

#### Rerouter

• Super Contributor
• Posts: 4643
• Country:
• 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.

#### rs20

• Super Contributor
• Posts: 2194
• Country:
##### 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?

#### Rerouter

• Super Contributor
• Posts: 4643
• Country:
• 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.

#### rs20

• Super Contributor
• Posts: 2194
• Country:
##### 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.

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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.

Inverter - would that be a NOT gate, like those Logic ICs?
1K resistor - How did you decide on that value?

#### Rerouter

• Super Contributor
• Posts: 4643
• Country:
• 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

#### Ice-Tea

• Super Contributor
• Posts: 1994
• Country:
##### 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...

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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!

#### rs20

• Super Contributor
• Posts: 2194
• Country:
##### 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.

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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.

#### David Hess

• Super Contributor
• Posts: 11753
• Country:
• 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

• Super Contributor
• Posts: 1875
• Country:
• 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

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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.

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

Yes, I definitely should have thought of that

#### Ian.M

• Super Contributor
• Posts: 9099
##### 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

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.

#### Zero999

• Super Contributor
• Posts: 14501
• Country:
• 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.

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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!
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!

#### CD4007UB

• Contributor
• Posts: 41
• Country:
##### 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 .

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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...

#### Ian.M

• Super Contributor
• Posts: 9099
##### 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

#### PA0PBZ

• Super Contributor
• Posts: 4415
• Country:
##### 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.

#### Ian.M

• Super Contributor
• Posts: 9099
##### 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 »

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### 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

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).

#### Rerouter

• Super Contributor
• Posts: 4643
• Country:
• 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,

#### Ian.M

• Super Contributor
• Posts: 9099
##### 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 »

#### igendel

• Frequent Contributor
• Posts: 303
• Country:
##### Re: How to get a clock signal from a crystal oscillator
« Reply #25 on: November 17, 2017, 12:09:45 pm »
If your happy with your probing technique, try upping that drive strength resistor to 4.7K,

No good - the ringing was a bit more pronounced with 4.7K than with 1K.

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*!

Now where do I get that kind of pulse generator in a short notice?

Soldering an SMD cap on that chip would be quite a challenge now... I'll give it a try later today. Thanks!

#### StillTrying

• Super Contributor
• Posts: 2591
• Country:
• Country: Broken Britain
##### Re: How to get a clock signal from a crystal oscillator
« Reply #26 on: November 17, 2017, 12:30:06 pm »
the scope couldn't even find an alignment by itself, thought it was 30MHz or something

At least you now know the frequency of the ringing.
Why are you viewing a 5V signal on 5V/div. If you used the next sensitivity up 2V/div. you'd see more detail, triggering would be easier/more stable, and the Auto Max. Min. and Vpp numbers would be more accurate.
CML+  That took much longer than I thought it would.

#### Ian.M

• Super Contributor
• Posts: 9099
##### Re: How to get a clock signal from a crystal oscillator
« Reply #27 on: November 17, 2017, 12:57:40 pm »
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.
Now where do I get that kind of pulse generator in a short notice?
Build it Manhatten style on a scrap of copper clad FR4 - the 90V supply can be done with 10x really cheap zinc carbon PP3 batteries from the market, so you can discard the PSU circuit (the 10Meg-24K divider chain + everything to the left of it).   For the 50R emitter resistor, its best to use two 100R SMD resistors upside down either side of the output pad to minimise inductance.    Breadboard the circuit with 100pF for C2 and if you cant easily source a few 2N2369 transistors to try, try different low Vceo, high Ft transistors till you find one that pulses reliably.  RF transistors are more likely to avalanche than most switching transistors.  If you are using a through hole transistor, its probably best to drill a hole in the PCB and mount it up-side down for minimum lead length.  Caution: metal can transistors usually have the can connected to the collector  - you'll need to countersink the hole slightly to remove a ring of copper to avoid shorting it out.

See AN47, appendix D, page 93 of http://www.linear.com/docs/4138

Also note that C2 can be replaced by a long length of coax for a flat(ish) topped pulse.  10m of 66% velocity factor coax will give you a pulse duration of about 50ns,  which will resemble a half cycle of a 10MHz squarewave.

Smf