Author Topic: Crystal Oscilator Circuit Problems  (Read 7658 times)

0 Members and 1 Guest are viewing this topic.

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Crystal Oscilator Circuit Problems
« on: October 26, 2021, 10:46:56 pm »
I'm a total newb trying my hand at EE stuff. I built a circuit with the goal of producing a near 1Hz signal. I cribbed a design off a bunch of websites for doing this but the damn thing just acts strangely. Sometimes it won't oscillate at all, sometimes it oscillates at the wrong frequency (sometimes double or half the intended) and sometimes it's all over the place. I even found that how far my fingers are from the board greatly impacts the frequency (if it's going to be that sensitive I figure I'm doomed).

Here's my schematic from KiCad which I think just implements a pierce oscillator using the CD4060BPWR:

1307936-0

Note that it really is designed to output 2Hz at the slowest. I figured I'd run it off of my rpi at 3.3V or 5V (though it only seems to run at all at 3.3V). It pulls <1mA at 3.3V.

I basically copied the schematic from the CD4060BM document: see https://www.ti.com/lit/ds/symlink/cd4060b.pdf

Here's a picture of one of the two ones I tried (for fun I got 5 fabricated from jlcpcb):

1307942-1

The crystal I'm using in it is https://datasheet.lcsc.com/lcsc/1811151451_Seiko-SC-20S,32.768kHz,20PPM,7pF_C97602.pdf

I can share the gerbers if that would be helpful.

Thanks for any suggestions! I asked some friends and they just told me to use a micro but the whole point is I'm trying to learn (I already know software).

I hope this is an appropriate place to post this. Sorry if not I'm new.
« Last Edit: October 26, 2021, 10:53:33 pm by brokensegue »
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5867
  • Country: de
Re: Crystal Oscilator Circuit Problems
« Reply #1 on: October 26, 2021, 11:14:28 pm »
I'm not surprised it doesn't work. Please read and understand datasheets before sending off orders to JLCPCB.
Crystal datasheet:
Drive level: 0.1 uW typ.
Absolute Max. Drive level: 0.5  uW
That's microwatts, not milliwatts (and even there you'd be over the limit). You're slamming it with 3.3 and 5 volts directly.

It's like nailing a pin into a wall with a 20-pound sledge hammer. I think you can order new crystals at this point.

Here's a better document than the decades-old 4060 data sheet. Check page 3 and pay attention to RS:
https://www.nxp.com/docs/en/application-note/AN2606.pdf

Good Luck.
« Last Edit: October 27, 2021, 10:03:28 am by Benta »
 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #2 on: October 26, 2021, 11:48:16 pm »
Thanks for the reply and the pdf link.

Yeah you seem to be right. I did read the crystal datasheet and was worried about the drive level (that's why I stuck that DNP resistor in). But I couldn't find any place explain how to compute the current/wattage through the crystal. Like I need to know the current through the crystal which requires me to know the resistance? Don't think it lists the crystal's resistance.

 I mean I assume I should just go with a resistor of like 33M ohm to get V/R to around 0.1 microamp? (And so VI=0.5 microwatt?) That seems crazy high though (bigger than my R_f even)
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #3 on: October 27, 2021, 12:09:30 am »
It's probably too late but I would have used a crystal oscillator.  All of the stuff required to get a logic level output is included in the device.  No resistors, no capacitors, just provide Vcc and Gnd and you wind up with an output.

Like:

https://datasheets.maximintegrated.com/en/ds/DS32kHz.pdf

At various suppliers, the search term is 'crystal oscillator'.  PDIP packages seem to be getting scarce but SMD are all over the place.

Like:

https://www.digikey.com/en/products/detail/w%C3%BCrth-elektronik/830207390509/13900442


I would put a ground pin or two alongside the output pins.  But that's just me...

« Last Edit: October 27, 2021, 12:23:15 am by rstofer »
 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #4 on: October 27, 2021, 12:52:46 am »
Yeah I considered using oscillator packages but it was a little tricky finding the right frequency package and I wanted to learn how crystals work anyways. If I can't fix this I'll switch. Thanks.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #5 on: October 27, 2021, 02:29:53 am »
There's a very similar circuit here.

https://www.electroschematics.com/1hz-generator-and-2hertz-oscillator/

Notice the resistor is around an order of magnitude higher value.
 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #6 on: October 28, 2021, 11:21:49 pm »
I removed the 20k ohm resistor and replaced it with both a 100k and 240k and in neither case did it work. Maybe I'll give up and try an oscillator package.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #7 on: October 29, 2021, 01:36:46 am »
Did you try a new crystal? It's likely you damaged the one you were using by grossly overdriving it.
 

Offline sarahMCML

  • Regular Contributor
  • *
  • Posts: 71
  • Country: gb
Re: Crystal Oscilator Circuit Problems
« Reply #8 on: October 29, 2021, 01:39:30 am »
Try around 12 to 15 pf each for C3 and C4, and possibly a little higher for R2, if the xtal is the 7.5pf load type.
 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #9 on: October 29, 2021, 02:52:03 am »
Yeah I used fresh boards/crystals assuming the first was killed. I calculated the capacitance based on the data sheet from the crystal. I don't think I have other sized capacitors to try at the moment.
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3381
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #10 on: October 29, 2021, 03:30:32 am »
CD4000 logic doesn't work very well at 3.3V.  Try a 5V supply.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5867
  • Country: de
Re: Crystal Oscilator Circuit Problems
« Reply #11 on: October 29, 2021, 11:13:42 am »
The circuits I've usually use 680k...1M for the series resistor.

 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #12 on: October 29, 2021, 05:01:02 pm »
I tried going to 1M for the series resistor and bumped to 5V. Doesn't oscillate at all.

Oddly when I turn the power supply off as the bulk decoupling cap discharges it oscillates at a perfect 2Hz for a few seconds. But sweeping the power supply voltage from 3 to 5 doesn't find a point where it'll reproduce that. Is the my series resistor still undersized? Maybe I need to use another fresh crystal? Unsure.

Edit: I also tried 10M series resistor on a totally fresh boards/crystal. The thing behaves identically down to the oscillating correctly as it discharges. Edit2: oh actually with this resistor it works at around 3.3V... so odd
« Last Edit: October 29, 2021, 05:44:33 pm by brokensegue »
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3381
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #13 on: October 29, 2021, 05:23:00 pm »
1. It's better to put the bias resistor R1 across the 4060 oscillator pins, not the crystal

2. 1M for R2 is pretty high, I would try 100K-300K

3. You can leave off C3 and C4 for now, they are not required for oscillation

4. Make sure you don't have the 4060 oscillator pins wired backward - I'd suggest rebuilding the circuit on a breadboard

5. You spelled oscillator wrong  :)
 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscillator Circuit Problems
« Reply #14 on: October 29, 2021, 05:55:12 pm »
1. The datasheet suggests putting R1 across the crystal though I'm not sure what the difference would be here? I think I've built it both ways with similar results.

2. Yeah I thought >1M was silly but I was just trying anything. Oddly the circuit with the 10M resistor has performed the best.

4. I actually thought two 4060 oscillator pins were effectively interchangeable but I guess you're right they are not. That said what I did matches the data sheet with the series resistor coming off pin 10.

5. oops. :<
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5867
  • Country: de
Re: Crystal Oscilator Circuit Problems
« Reply #15 on: October 29, 2021, 06:35:03 pm »
I've never had problems getting this circuit to work, both at 5 V and 12 V. 3.3 V might be marginal for 4000-series CMOS, try with 470k for the series resistor in that case.

« Last Edit: October 29, 2021, 07:41:06 pm by Benta »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #16 on: October 29, 2021, 07:18:28 pm »
This should be trivial to make work, is it possible the IC was damaged by static? The old 4000 series CMOS stuff was pretty fragile, I assume modern production is more robust but I don't really know. Is it possible the capacitors are the wrong value? What value did you use?
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 6956
  • Country: ca
Re: Crystal Oscilator Circuit Problems
« Reply #17 on: October 29, 2021, 08:18:24 pm »
Seiko does give circuit values for the SC-20S when used with microcontrollers, as a ballpark for your circuit. It's closer to reality than some values people are putting out here.
R2 max. around 70k, and C3, C4 ~10pF with 2.7-5.5V power. 12/15pF with 3V high drive MCU's.
No pulsing PCB traces run under the xtal or near its traces/pins. Clean any flux off too.  Also ensure the 10M really is 10M because they are hard to get in small SMT.
I would use 68k for R2 and go up to 10pF for the loading caps and see what happens.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5867
  • Country: de
Re: Crystal Oscilator Circuit Problems
« Reply #18 on: October 29, 2021, 08:47:49 pm »
Seiko does give circuit values for the SC-20S when used with microcontrollers, as a ballpark for your circuit. It's closer to reality than some values people are putting out here.
R2 max. around 70k, and C3, C4 ~10pF with 2.7-5.5V power. 12/15pF with 3V high drive MCU's.
No pulsing PCB traces run under the xtal or near its traces/pins. Clean any flux off too.  Also ensure the 10M really is 10M because they are hard to get in small SMT.
I would use 68k for R2 and go up to 10pF for the loading caps and see what happens.

This is total nonsense.
I've looked at the documents on the Seiko site, and they give recommendations for MCUs having 32 kHz oscillator circuits. Those oscillator circuits are already power-limited on-chip.
Your total confusion about "Motional Resistance" (which is the ESR of the crystal = 70 kohm) and drive level is glaring.
And why would the load capacitors be supply voltage dependent?

Apparently, you've never built a 32 kHz oscillator using standard logic from scratch.

My original value for the series resistor of 680k...1M stands. I've built this so often, and it always ran (with the caveat that I've only used the small tubular crystals, not the SMD ones).
« Last Edit: October 29, 2021, 08:56:37 pm by Benta »
 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #19 on: October 29, 2021, 09:04:07 pm »
I verified the 10M is ~10M with my DMM.

I doubt static is the issue as I've used multiple boards with different chips on them (not just new crystal but new everything). I used JLPCB for both assembly/fab. No idea what the odds are they'd ESD all of the chips (low I assume). I can't verify the capacitance of C3/C4 as my DMM isn't good enough (reads zero).

I'm not too worried about C3/C4 since based on my reading they wouldn't be causing these kinds of issues (just a few percent errors at most). I ordered 2.7pF which I'm hearing is too low. Though now I'm confused because I didn't think it varied with voltage.

I must be doing something wrong because I've tried everyone's advice and it only ever seems to work when I unplug it...

 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3381
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #20 on: October 29, 2021, 09:42:21 pm »
Put your PCBs aside and build the circuit from scratch.

If possible, get it working with a 4069UB first.

Do you have an oscilloscope?

 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5867
  • Country: de
Re: Crystal Oscilator Circuit Problems
« Reply #21 on: October 29, 2021, 09:48:46 pm »
I verified the 10M is ~10M with my DMM.

I doubt static is the issue as I've used multiple boards with different chips on them (not just new crystal but new everything). I used JLPCB for both assembly/fab. No idea what the odds are they'd ESD all of the chips (low I assume). I can't verify the capacitance of C3/C4 as my DMM isn't good enough (reads zero).

I'm not too worried about C3/C4 since based on my reading they wouldn't be causing these kinds of issues (just a few percent errors at most). I ordered 2.7pF which I'm hearing is too low. Though now I'm confused because I didn't think it varied with voltage.

I must be doing something wrong because I've tried everyone's advice and it only ever seems to work when I unplug it...

Relax. Nothing varies with voltage in this case.

But frankly, your original schematic was not good, and I urge you to redo it, and show it here. You're welcome to copy it from mine in post #15.

Concerning Pierce oscillators: basically a linear inverting amplifier with a 180 degrees feedback element (the crystal).
The amplifier: a CMOS inverter biased to linear operation with a feedback resistor (5...10 Mohm).
The crystal: placed between input and output of the amplifier.
Drive level for the crystal: dependent on the type of crystal, limited by a series resistor when needed.
Load capacitance: the two load capacitors provide this as required in the crystal data sheet. It's the series capacitance of the two load capacitors. So for a crystal needing a load capacitance of 7.5 pF, two 15 pF capacitors are right.
Except they aren't . Capacitance at the IC needs to be included. For the 4069U (in post #15) it's 5 pF at the input, which will be in parallel to the real load capacitor. The output can be ignored, as the power limiting resistor effectively blocks any influence there.


« Last Edit: October 29, 2021, 09:53:19 pm by Benta »
 

Offline brokensegueTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #22 on: October 29, 2021, 10:54:03 pm »
To be clear I did build it on a breadboard first and it seemed to be working. That said I used a different version of the CD4060 and a different crystal (since I moved to surface mount parts).

I have access to a scope but it's not readily at hand.

I'll need to order a 4069UB.

Thanks for the help.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 6956
  • Country: ca
Re: Crystal Oscilator Circuit Problems
« Reply #23 on: October 29, 2021, 10:56:39 pm »
Seiko does give circuit values for the SC-20S when used with microcontrollers, as a ballpark for your circuit. It's closer to reality than some values people are putting out here.
R2 max. around 70k, and C3, C4 ~10pF with 2.7-5.5V power. 12/15pF with 3V high drive MCU's.
No pulsing PCB traces run under the xtal or near its traces/pins. Clean any flux off too.  Also ensure the 10M really is 10M because they are hard to get in small SMT.
I would use 68k for R2 and go up to 10pF for the loading caps and see what happens.

This is total nonsense.
I've looked at the documents on the Seiko site, and they give recommendations for MCUs having 32 kHz oscillator circuits. Those oscillator circuits are already power-limited on-chip.
Your total confusion about "Motional Resistance" (which is the ESR of the crystal = 70 kohm) and drive level is glaring.
And why would the load capacitors be supply voltage dependent?

Apparently, you've never built a 32 kHz oscillator using standard logic from scratch.

My original value for the series resistor of 680k...1M stands. I've built this so often, and it always ran (with the caveat that I've only used the small tubular crystals, not the SMD ones).

I would say good luck getting it to start with the series resistance value you recommend 1MEG  :-//
Never seen it out in the wild, maybe tell us more why you went with quite a large value, even the RC phase-shift alone seems large with 10pF/1MEG.
I've used 100k-330k over the years, depending on the crystal's drive specs and the IC. Seiko recommending "R1 max. 70k" with the MCU examples, it's ESR spec? - my mistake then and no series resistor at all, they go with zero ohms.

I don't think OP's circuit is that finicky, lots of nixie clocks using the same circuit. I would put in ballpark values and then troubleshoot. CMOS inverter's gain is dependent on VDD, so changing the supply voltage (and switching power off/on) is something to try as well.
I find you can't really engineer LF crystal oscillators because any test equipment probing affects things, as well as the unknowns with stray capacitance.

Tons of troubleshooting advice in these app notes:
Crystal Oscillator Troubleshooting Guide NXP AN3208
Making Your Oscillator Work Microchip AN949
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3381
  • Country: us
Re: Crystal Oscilator Circuit Problems
« Reply #24 on: October 29, 2021, 11:19:03 pm »
To be clear I did build it on a breadboard first and it seemed to be working. That said I used a different version of the CD4060 and a different crystal (since I moved to surface mount parts).

Solder leads on the surface mount crystal and test it on the breadboard.

If that works, throw away your PCBs.

If not, throw away the surface mount crystals.
« Last Edit: October 30, 2021, 12:22:44 am by edavid »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf