Crystal Oscilator Circuit Problems - Page 1
Forum section: electronics / projects

author: brokensegue
author_rank: Contributor
timestamp: October 26, 2021, 10:46:56 pm
content: 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: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: seehttps://www.ti.com/lit/ds/symlink/cd4060b.pdfHere's a picture of one of the two ones I tried (for fun I got 5 fabricated from jlcpcb):The crystal I'm using in it ishttps://datasheet.lcsc.com/lcsc/1811151451_Seiko-SC-20S,32.768kHz,20PPM,7pF_C97602.pdfI 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.

author: Benta
author_rank: Super Contributor
timestamp: October 26, 2021, 11:14:28 pm
content: 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 uWThat'smicrowatts, 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.pdfGood Luck.

author: brokensegue
author_rank: Contributor
timestamp: October 26, 2021, 11:48:16 pm
content: 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)

author: rstofer
author_rank: Super Contributor
timestamp: October 27, 2021, 12:09:30 am
content: 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.pdfAt 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/13900442I would put a ground pin or two alongside the output pins. But that's just me...

author: brokensegue
author_rank: Contributor
timestamp: October 27, 2021, 12:52:46 am
content: 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.

author: james_s
author_rank: Super Contributor
timestamp: October 27, 2021, 02:29:53 am
content: 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.

author: brokensegue
author_rank: Contributor
timestamp: October 28, 2021, 11:21:49 pm
content: 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.

author: james_s
author_rank: Super Contributor
timestamp: October 29, 2021, 01:36:46 am
content: Did you try a new crystal? It's likely you damaged the one you were using by grossly overdriving it.

author: sarahMCML
author_rank: Regular Contributor
timestamp: October 29, 2021, 01:39:30 am
content: 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.

author: brokensegue
author_rank: Contributor
timestamp: October 29, 2021, 02:52:03 am
content: 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.

author: edavid
author_rank: Super Contributor
timestamp: October 29, 2021, 03:30:32 am
content: CD4000 logic doesn't work very well at 3.3V. Try a 5V supply.

author: Benta
author_rank: Super Contributor
timestamp: October 29, 2021, 11:13:42 am
content: The circuits I've usually use 680k...1M for the series resistor.

author: brokensegue
author_rank: Contributor
timestamp: October 29, 2021, 05:01:02 pm
content: 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

author: edavid
author_rank: Super Contributor
timestamp: October 29, 2021, 05:23:00 pm
content: 1. It's better to put the bias resistor R1 across the 4060 oscillator pins, not the crystal2. 1M for R2 is pretty high, I would try 100K-300K3. You can leave off C3 and C4 for now, they are not required for oscillation4. Make sure you don't have the 4060 oscillator pins wired backward - I'd suggest rebuilding the circuit on a breadboard5. You spelled oscillator wrong

author: brokensegue
author_rank: Contributor
timestamp: October 29, 2021, 05:55:12 pm
content: 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. :<

author: Benta
author_rank: Super Contributor
timestamp: October 29, 2021, 06:35:03 pm
content: 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.

author: james_s
author_rank: Super Contributor
timestamp: October 29, 2021, 07:18:28 pm
content: 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?

author: floobydust
author_rank: Super Contributor
timestamp: October 29, 2021, 08:18:24 pm
content: Seiko does givecircuit valuesfor 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.

author: Benta
author_rank: Super Contributor
timestamp: October 29, 2021, 08:47:49 pm
content: Quote from: floobydust on October 29, 2021, 08:18:24 pmThis 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).

author: brokensegue
author_rank: Contributor
timestamp: October 29, 2021, 09:04:07 pm
content: 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...

author: edavid
author_rank: Super Contributor
timestamp: October 29, 2021, 09:42:21 pm
content: Put your PCBs aside and build the circuit from scratch.If possible, get it working with a 4069UB first.Do you have an oscilloscope?

author: Benta
author_rank: Super Contributor
timestamp: October 29, 2021, 09:48:46 pm
content: Quote from: brokensegue on October 29, 2021, 09:04:07 pmRelax. 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.

author: brokensegue
author_rank: Contributor
timestamp: October 29, 2021, 10:54:03 pm
content: 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.

author: floobydust
author_rank: Super Contributor
timestamp: October 29, 2021, 10:56:39 pm
content: Quote from: Benta on October 29, 2021, 08:47:49 pmI would say good luck getting it to start with the series resistance value you recommend 1MEGNever 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 AN3208Making Your Oscillator Work Microchip AN949

author: edavid
author_rank: Super Contributor
timestamp: October 29, 2021, 11:19:03 pm
content: Quote from: brokensegue on October 29, 2021, 10:54:03 pmSolder 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.

author: floobydust
author_rank: Super Contributor
timestamp: October 30, 2021, 02:57:57 am
content: It's misleading that it worked on a breadboard with different (through-hole) parts - the IC, crystal, caps. Everything has been changed, so back to square #1.Maybe post pics of your PCB layout we can look for issues there.A breadboard's parasitic capacitance, I measure 3pF between two strips and higher if mounted on a metal plate or workbench. Also the high hum and noise, common-mode depending on if the power supply was earth-grounded, can help a weak oscillator start up. Physically smaller crystals have higher ESR as well.StrangeHEF4060B datasheet,it doesn't have Q14 on pin 3, or the tri-state on the gate. Sometimes SMT packaged IC's are different than their through-hole version.Lots of posts on the web using CD4060 for nixie clocks and suchhttps://www.eevblog.com/forum/beginners/32-768khz-pierce-crystal-oscillator-for-nixie-clock/as well.

author: james_s
author_rank: Super Contributor
timestamp: October 30, 2021, 04:14:29 am
content: The capacitors could easily be off by an order of magnitude or more and still be well below what you can measure with something like a multimeter. It's not unheard of for something like that to happen, last year I had to debug some prototypes built by a company and I found several capacitors that were way off, like 1uF where it should have had 15pf caps on the clock crystal.

author: sarahMCML
author_rank: Regular Contributor
timestamp: October 31, 2021, 01:52:37 am
content: For some strange reason, the HEF4060B datasheet mark's each flipflop's output 1 less than than the value of the latch it's actually connected to. Weird!

author: james_s
author_rank: Super Contributor
timestamp: October 31, 2021, 02:07:21 am
content: The flipflops are numbered starting from 1. The outputs are numbered starting from 0, as is convention.

author: floobydust
author_rank: Super Contributor
timestamp: October 31, 2021, 03:07:34 am
content: CD4060BTI/RCA/Harris and NS datasheet Q4-Q10, Q12-Q14.NXP HEF4060B datasheet Q3-Q9, Q11-Q13. Just pointing out the different numbering convention, which is annoying.NXP also includes this graph for the osc. amp transconductance, VDD affects it almost 3:1.

author: bson
author_rank: Unknown
timestamp: October 31, 2021, 09:23:36 pm
content: One thing to keep in mind with small, extremely low-power SMD crystals is that flux bridges between the pads can be source of trouble.Don't ask how I know.

author: Benta
author_rank: Super Contributor
timestamp: October 31, 2021, 10:16:37 pm
content: Quote from: floobydust on October 29, 2021, 10:56:39 pmHow about grabbing a simple calculator and compute what 0.1 uW results in as series resistance at the voltages involved? THEN you can come back with your smirking "smiley".You've obviously never worked with these kind of crystals before.

author: floobydust
author_rank: Super Contributor
timestamp: November 01, 2021, 12:18:06 am
content: Sorry we're not all masters like yourself. 1MEG with say 10pF load seems excessiveover industrial temperatures it would have to be a precise design.Majority of these oscillators are datasheet copies, to dig in is very difficult. I have designed these oscillators too but the problem as I have mentioned the Observer effect makes measurements nearly impossible, unless a low cap JFET probe or inductive pickup which watchmakers use to calibrate frequency. LT Spice simulations are not useful either because the parasitic capacitances are not really known nor the crystal's SPICE model. There is always empirical work I find, and I run out of project time and patience.One product's 32kHz oscillator refused to startup around 5°C but colder or warmer by a few degrees it would reliably start, it was awful.