Oscillator issue - Page 1
Forum section: electronics / projects

author: mpicker21
author_rank: Contributor
timestamp: August 13, 2016, 12:15:11 am
content: I built a basic binary clock a while back that has a speeding issue. I did some testing and found that it gains a full 60 seconds every 4 hours and 15 minutes. I wasn't able to try to troubleshoot it until now as I just got a Rigol DS1054Z. I use a SN75HC4060 and a 32.768 kHz crystal as my time base. I assumed that the crystal was doing something weird but when I look at it in the scope it's not as bad as I suspected. With my math, based on the time gain, I am somehow getting a clock of 32.896 instead of 32.768. That's an extra 128 Hz. Looking at the output of the crystal on the scope I am seeing a pretty accurate 32.7671 kHz. Looking at my CLK pins though I'm 32.907ish (close to my calculation). I am seeing a strange overall oscillation on the crystal though that may account for the extra 128 Hz. I have attached screen grabs from the scope. Does anyone know what might be causing this? My hunch is noise on the power supply, which is a 5V wall wart but I'm not seeing any significant noise there. As a note, this is done up on vero board.

author: bobaruni
author_rank: Regular Contributor
timestamp: August 13, 2016, 01:32:11 am
content: Is it possible that while you measure the crystal with the probe, the extra capacitance makes the oscillator come good?Which exact chip did you use as you state SN75HC4060, but is it a 74HC?What passives did you use around the crystal, perhaps it's not being loaded correctly, if so the frequency and stability will be off?Did you use a cap close to the chip on the power rails?

author: StillTrying
author_rank: Super Contributor
timestamp: August 13, 2016, 02:01:19 am
content: As your clock is fast by 1 part in 256, I would think it's a digital problem rather than the clock frequency being out.As bobaruni said, HC4060's supply decoupled ?Are outputs QG or QH driving something.

author: rstofer
author_rank: Super Contributor
timestamp: August 13, 2016, 02:24:21 am
content: Is your scope probe on x10?A schematic would help greatly...

author: Audioguru
author_rank: Super Contributor
timestamp: August 13, 2016, 02:47:34 am
content: Is the circuit built on a solderless breadboard with messy "antenna" jumper wires all over the place?

author: mpicker21
author_rank: Contributor
timestamp: August 13, 2016, 04:47:56 am
content: Quote from: Audioguru on August 13, 2016, 02:47:34 amThis is on stripboard. I tried to avoid traces longer than they had to be. I did the best I could without getting a PCB done. (I like the home gamer look.) Pictures attached.Quote from: rstofer on August 13, 2016, 02:24:21 amThe probe is on x10 and so is the scope. I tried x1 and I think it actually made the crystal unstable. (I'm still new to this thing.) A schematic for the portion of the circuit in question is attached. I initially had just the 22pF caps in the circuit as that seemed to work on the solderless breadboard but when I put it on the stripboard I needed more capacitance (14pF per side).Quote from: bobaruni on August 13, 2016, 01:32:11 amYou made a good point so I went back to the scope and probed both pins at the same time but got the same results. Screen grabs attached. One interesting thing is that the duty cycle on the CLK pins changed in this configuration but I get the same frequencies.Quote from: StillTrying on August 13, 2016, 02:01:19 amI have a bulk capacitor, 100uF, where the power comes into the board and another .01uF on the Vcc pin. The bulk cap is very close to the chip as well. I'm using the fast pulse from Qh to drive all the latches on the 3 counting chips. It's late and my mind is getting fuzzy but it seems to me that since I'm not latching the count to the output of the counters, and triggering the reset pin and next counter, until that pin pulses that I'd actually be slightly slow rather than slightly fast, right? Unless I've got some crossed trace somewhere that is causing that pin to pulse my clock as well... I think you are on to something. Oh and it is an SN74HC4060N from TI.It's late and I'm struggling to wrap my mind around what I did with this circuit. I really should have done the full up schematic back then. Documentation, or lack thereof, will screw you every time. I'll track down Qh tomorrow and try to post an update.

author: bobaruni
author_rank: Regular Contributor
timestamp: August 13, 2016, 07:18:49 am
content: Way too much current on the XTAL, try raising the 24R resistor to a few K.Or you can calculate the resistor as R = 1/(2*PI*F*C)Where F = 32768 and C = the load capacitor in Farads (in your case 36p) Which gives you R = 134KMaybe try 100k and see how you go.

author: joeqsmith
author_rank: Super Contributor
timestamp: August 13, 2016, 02:49:31 pm
content: Good looking workmanship.

author: mikerj
author_rank: Super Contributor
timestamp: August 13, 2016, 04:22:41 pm
content: As said you are significantly overdriving the crystal. As well as making the frequency inaccurate, this can actually fracture the crystal by exceeding the elastic limits of the material.

author: Zero999
author_rank: Super Contributor
timestamp: August 13, 2016, 04:23:11 pm
content: Quote from: mpicker21 on August 13, 2016, 12:15:11 amA x10 probe has some capacitance and the frequency decreases when the 'scope probe is attached so more capacitance may help. Try adding an extra 10pF, where ever you had your 'scope probe on the crystal.

author: StillTrying
author_rank: Super Contributor
timestamp: August 13, 2016, 05:28:07 pm
content: Sticking with the fast by 1 part in 256...If you zoom in closer to the disturbances from QH shown in DS1Z_QuickPrint4.png, you might find one of them is big enough to count as the extra clock cycle, which would give you the extra 1 clock in 256.Your oscillator shows disturbances from all of the switching/counting. So I'd bet on it being the 0.01uF not being big enough, especially with the capacitance that QH has to drive. Changing the 0.01uF to 0.1uF or 0.22uF will fix it.I don't know enough about 32K XTAL circuits to know if the values there are bad or not.

author: mpicker21
author_rank: Contributor
timestamp: August 13, 2016, 08:41:17 pm
content: Thanks for the recommendations. I was thinking more about how that Qh pin could be acting as an antenna as that trace runs the length of the board. I was going to probe that pin and the crystal to see if that odd shape correlates. I'm willing to bet that it's a direct correlation. To those mentioning overdriving the crystal, I am pretty sure that is true too. When I was reverse engineering my board last night I actually did a doubletake on that resistor because it seemed low. I am willing to bet that I grabbed the wrong multiplier out of my bin.Right now the crystal is oscillating at 50ish MHz so I may have finally borked the crystal. I will be replacing that resistor and adding more capacitance to the IC. If I am lucky I can salvage this crystal. If not I will have to order a new one.Thanks everyone again for the help. I learn a lot from you guys. I'll post an update when I get the soldering iron out and make the changes.

author: danadak
author_rank: Super Contributor
timestamp: August 14, 2016, 12:00:59 am
content: This might help, attached.Regards, Dana.

author: bobaruni
author_rank: Regular Contributor
timestamp: August 14, 2016, 12:54:31 am
content: You can only solve one problem at a time, start with the oscillator then see where that takes you.Just replacing the crystal (If it's now broken) and changing the 24R will (should) solve your problem, adding more capacitance around the crystal oscillator will de-tune the frequency.Don't just add capacitance to the crystal as trial and error.Use the crystal manufacturers specifications for load capacitance then calculate the series resistance based on the formula previously posted.Looking at your oscilloscope trace shows that the oscillator wants to break out into overtone harmonics and it's very jittery.A crystal oscillator should be a perfect sine wave without any visible jitter or noise.The switching spikes seen in the trace should not effect the oscillator if it's oscillating properly, CMOS IC's have a fairy high immunity to noise on the rails.

author: mpicker21
author_rank: Contributor
timestamp: August 14, 2016, 03:03:20 am
content: Danadak: Thanks for the guide. I did a bunch of reading on this topic back when I built this clock. I did some number crunching too but don't have the figures. I didn't have the appropriate tools back then to troubleshoot. I will have to do some math. I think I inadvertantly put that small resistor in there though.Bobaruni: I didn't plan on doing both at once. Also, the capacitance I was going to put in was going to be on the power input side, not the crystal. In hindsight, the reason that it worked on the breadboard but not the stripboard, before adding extra crystal capacitance, may have been that I slipped that wrong resistor in during the transition. That was 6 months or so ago. I'm always learning from mistakes.

author: bobaruni
author_rank: Regular Contributor
timestamp: August 14, 2016, 04:27:48 am
content: Nothing to feel bad about, we are all still learning as electronics is forever evolving and often the best lessons are through mistakes.At least you are giving it a go and you should feel good about that as many people get scared an that's what stops them from learning and achieving.

author: mpicker21
author_rank: Contributor
timestamp: August 14, 2016, 05:30:36 am
content: The bad news: Apparently I'm resistor band dyslexic.The good news: I wasn't over driving the crystal as bad as we thought. I did, in fact, have a 100k resistor in where I thought I had the 24 ohms.More good news: I get a beautiful looking sin wave right now out of my crystal.More bad news: The frequency of the crystal is now 50MHz or so.I'll have to get a new crystal. I may have accidentally created a short and fried it. I've abused it pretty badly mucking around with it like this. Unfortunately I don't have a nice store I can run off to to get a crystal so I'll have to get it from Mouser. I may as well get a few and try to get as many parts as I can for that power supply project I have started planning. It's frustrating paying 5 bucks in shipping for a part that costs less than 1 dollar.