Maker Pro
Maker Pro

32kHz crystal issues

D

DJ Delorie

James Arthur said:
Are the glitches synchronous with the oscillator's 32,768Hz output?
No.

If not, what are they synchronous with?

Digital transitions of the adjacent pin (a GPIO pin)
Do the glitches stop when you disable the main clock?

Er, yes, because the GPIO pin stops changing ;-)
Do you have a nice bypass cap directly *across* the PIC? (Or, even
better, directly bridging load and driver, i.e., the high current
paths, whatever they might be.)

As best as I can on a solderless breadboard.
 
J

James Arthur

Digital transitions of the adjacent pin (a GPIO pin)


Er, yes, because the GPIO pin stops changing ;-)


As best as I can on a solderless breadboard.

No, no! (I'm looking at the picture) For even a half-assed bypass you
need to insert one lead of the cap there directly next to pin 13
(Vdd), with the other lead to Vss. That makes a huge difference on a
solderless breadboard--I've seen it.

But, the GPIO pin is obviously the problem, coupling into that poor,
innocent oscillator's input.

You could consider a) reassigning that GPIO signal to another pin, b)
or slowing its slew rate with an R-C... {or c) air-wiring pin 11 and
seeing whether its coupling to pin 10 is still excessive}

Anyway, you've identified the problem, time now for the fix.

Cheers,
James Arthur
 
D

DJ Delorie

James Arthur said:
No, no! (I'm looking at the picture) For even a half-assed bypass
you need to insert one lead of the cap there directly next to pin 13
(Vdd), with the other lead to Vss. That makes a huge difference on
a solderless breadboard--I've seen it.

Didn't do anything to the signal. I tried a couple of different
things. Plus, the Vdd line doesn't show any glitches in sync with the
GPIO pin.
But, the GPIO pin is obviously the problem, coupling into that poor,
innocent oscillator's input.

Yeah, but... coupling how? Here's the scope:

http://www.delorie.com/electronics/alarmclock/20070712-32kscope.html

With the 10x, that's a 0.18v step for 7.6uS. It looks DC coupled.
Could the 32k xtal circuit be so high impedance that even a few pF
couples like that?

Those pins next to the 32k oscillator are also for the primary
oscillator (not used), I wonder if they have different coupling
characteristics within the chip?
 
J

James Arthur

Didn't do anything to the signal. I tried a couple of different
things. Plus, the Vdd line doesn't show any glitches in sync with the
GPIO pin.


Yeah, but... coupling how? Here's the scope:

http://www.delorie.com/electronics/alarmclock/20070712-32kscope.html

Capacitively, pin-to-pin, but principally via the breadboard I'd
assume.

Consider: that's a 50mV step into roughly 20pF. A stray of 20pF x
50mV/(3.3V logic swing) = roughly 0.3pF of cross-coupling needed to
produce that. You mentioned earlier that your solderless breadboard
supplies 2pF.

I s'pose 'tisn't usually a problem unless the GPIO transition comes
when the oscillator input's close to its threshold, and is of the
opposite polarity (same polarity just triggers the oscillator's output
edge early, while opposite polarity produce a glitch).
With the 10x, that's a 0.18v step for 7.6uS. It looks DC coupled.
Could the 32k xtal circuit be so high impedance that even a few pF
couples like that?

Absolutely yes! For example, a 10 megohm oscillator input Z (not
unusual) x 20pF yields a 200uS time constant ! (But *your* waveform
suggests about 4uS t/c, best I can tell, suggesting a Z near 200K.
Your earlier reports also indicate a low-ish input Z.)

Another possibility is d.c. coupling, leakage between the pins.
Again, that could be the solderless breadboard. A little dirt might
explain that.

But it's most likely breadboard capacitance, methinks.

Note that the breadboard shunt capacitance provides a pulse of
negative feedback from the oscillator's output pin immediately after
the oscillator's input pin crosses threshold--that's nasty too.
Those pins next to the 32k oscillator are also for the primary
oscillator (not used), I wonder if they have different coupling
characteristics within the chip?

Maybe. Dunno.

Cheers,
James Arthur
 
J

joseph2k

DJ said:
I'm working on a circuit with a RTC that uses the ubiquitous 32768 Hz
crystal. I'm assuming my problems at the moment are due to using a
solderless breadboard and not a properly laid out circuit board, but
just in case I'm missing something obvious...

My RTC is running a little fast (8%!). I'm pretty sure it's picking
up glitches from nearby wires (no ground ring, etc), and there are
some step pulses on the sine wave which confirm this. But could
someone verify the signals otherwise? The IC's drive signal is 1v
peak, but not a sine wave - it's clipped to ground for about 30% of
its phase, and has a faster drop than rise. The drive signal after
the 330K is a 0.8vpp (0v-0.8v) sine wave. The return signal is a
0.5vPP sine wave centered at 0.8v. Do these sound right? I'd rather
at least get this part right before having a board made.

The circuit is an ECS-1x5 crystal, 330K series R, 15pF caps, into a
microchip PIC24F (3.3v). The load's a little off (8.5 vs 8 pF) but
that's as close as I can get with the caps at hand.

Would a crystal that needs higher load caps be more noise-immune? I
seem to get that opinion from various readings.

Would adding 50R resistors to the pins near the crystal help any,
assuming I've done the usual ground ring and keepouts?

Thanks,
DJ
According to the microchip PIC24F datasheets i found, the pin termination
for sosco is 15 pF to Vss, and for sosci 50 pF to Vss and 464 ohms to Vdd/2
(say a pair of 910 of resistors to Vss and Vdd). Put what high value
resistor you want parllel to the Xtal. Putting 50 ohm resistors to any
other place will probably kill oscillation altogether.
 
D

DJ Delorie

James Arthur said:
But it's most likely breadboard capacitance, methinks.

Thanks for the details. I'll move that signal away from the OSC pins
and ground that pin, and do the usual EMI stuff on the final board,
once I'm done trying other resistor values to see if I can get the
signal tweaked toward center.
Note that the breadboard shunt capacitance provides a pulse of
negative feedback from the oscillator's output pin immediately after
the oscillator's input pin crosses threshold--that's nasty too.

Well, that's a coincidence. I just picked the pulse that showed up
best on the screen ;-)
 
C

colin

DJ Delorie said:
With the 10x, that's a 0.18v step for 7.6uS. It looks DC coupled.
Could the 32k xtal circuit be so high impedance that even a few pF
couples like that?

its a lot more than a few pf, I measured the capacitance once
it was between 10pf and 30pf depending on the type of breadboard.

wich realy is horrible for things like this.

I would stop the adjacent pins ineterfering anywich way you can
ie disable the output/lift the IC pin
and just see if the oscillator works properly then.
then go for the proper pcb.


Colin =^.^=
 
M

MooseFET

Crystals typically have spurious modes, and yours may be oscillating on one
of these. Try one of these : use a different brand of crystal, reduce the
gain, put a 32 KHz tuned circuit somewhere in the feedback loop.

Yes.

Sometimes increasing the drive resistor so that it interacts with the
capacitors making more phase shift than normal will stop a higher
spurious mode.

Also over driven crystals tend to shift up in frequency.
 
J

James Arthur

According to the microchip PIC24F datasheets i found, the pin termination
for sosco is 15 pF to Vss, and for sosci 50 pF to Vss and 464 ohms to Vdd/2
(say a pair of 910 of resistors to Vss and Vdd).


I can't find that--can you say where you found it?

Thanks,
James Arthur
 
J

James Arthur

Yes.

Sometimes increasing the drive resistor so that it interacts with the
capacitors making more phase shift than normal will stop a higher
spurious mode.

Also over driven crystals tend to shift up in frequency.


I think the crystal's on frequency, but his glitches are giving him
extra counts, i.e., on occasion a glitch produces two counts (instead
of one) per 32,768 cycle.

Cheers,
James Arthur
 
M

MooseFET

I think the crystal's on frequency, but his glitches are giving him
extra counts, i.e., on occasion a glitch produces two counts (instead
of one) per 32,768 cycle.

It could be. If he triggers his scope from a known good 32768Hz, he
could tell. He can trim the frequency to stop the waveform, and then
check the count he gets.
 
J

James Arthur

It could be. If he triggers his scope from a known good 32768Hz, he
could tell. He can trim the frequency to stop the waveform, and then
check the count he gets.

Good idea.

In this particular case he's located the glitch-source, so if he fixes
the glitches--which he has to do anyhow--the whole problem will likely
just go away.

But, in the general case your idea is a slick way to prove the
existence of glitches when you're getting extra counts, a way that
would be especially useful in situations where you can't see 'em.

Cheers,
James Arthur
 
J

john jardine

colin said:
its a lot more than a few pf, I measured the capacitance once
it was between 10pf and 30pf depending on the type of breadboard.

wich realy is horrible for things like this.

I would stop the adjacent pins ineterfering anywich way you can
ie disable the output/lift the IC pin
and just see if the oscillator works properly then.
then go for the proper pcb.


Colin =^.^=

For that breadboard the makers specify 0.8pF strip to strip. I've also
measured it at 0.8pF. Stray capacitance signal coupling on these breadboards
is minimal.
Most problems are due to the use of long jumper wires and high impedance
inputs.
 
J

joseph2k

James said:
I can't find that--can you say where you found it?

Thanks,
James Arthur
It was within 4 pages (40 items) of the initial search string "PIC24F". It
was a Microchip datasheet (AC characteristics section). QFP package if
that makes any difference. I might have misread it though.
 
D

DJ Delorie

Ok, I did some experimenting.

First off, I realized something important - the chip has an internal
2.5v regulator for it's core logic, so the DC offset isn't as suspect
as it could have been.

I swapped the GPIO next to the OSCI return with a different GPIO that
doesn't change once the system's running, and that got rid of the
interference. There doesn't seem to be interference from the next pin
over, which is the high speed OSCI, and which is also a GPIO with lots
of edges.

I replaced the 330k resistor with a 560k resistor. It didn't change
any of the DC offsets, but it did reduce the drive Vpp some (and
increased the startup time from 1s to 3s ;)

With either resistor, the drive phase and return phase are not 180
degrees out of phase. More like 120, as if the filter wasn't pushing
it around enough. However, the return peak corresponds to the first
part of where the drive signal hits gnd; maybe an even bigger
resistor? Nope, even 1M doesn't change the phase. I guess I'll have
to tune it once it's on the final PCB and the stray capacitance is
finalized, yes?

Meanwhile, I'm going to write some software to internally compare the
32k clock to the FRC clock so I can see what effect the scope probes
have.

DJ
 
G

Guy Macon

DJ said:
Meanwhile, I'm going to write some software to internally compare the
32k clock to the FRC clock so I can see what effect the scope probes
have.

If you need less disturbance from the probe and don't have a FET
probe at hand, you might try a 100:1 probe instead of the usual
10:1 probe. I have seen situations where the 100:1 probe disturbs
the working circuit less. Needless to say, this doesn't work
well with low-level signals.
 
D

DJ Delorie

Guy said:
If you need less disturbance from the probe and don't have a FET
probe at hand, you might try a 100:1 probe instead of the usual
10:1 probe. I have seen situations where the 100:1 probe disturbs
the working circuit less. Needless to say, this doesn't work
well with low-level signals.

My "scope" is a cheap parallel-port 32Ms scope. It's not sensitive
enough for a 100x probe.

Anyway, I relayed the RTC's 1s interrupt to a GPIO pin and measured it
with the logic analyzer (500Ms/s compressed :). Assuming the LA is
"perfect" (ha), the 32k crystal is fast by 36ppm at the moment (and
reasonably stable at that). That's 3 seconds/day, well within the
adjustability of the RTC, and probably something I can tune with
capacitors on the PCB later.

Anyway, I attached the scope probe and the RTC ran *way* slow
(relatively speaking, still ppm), so added capacitance will definitely
slow the clock. Unfortunately, the spec sheet for the crystal doesn't
have a cap/freq curve, so it will be trial and error.

Of course, I'll have to compare it to a more precise time standard at
that point.
 
J

James Arthur

It was within 4 pages (40 items) of the initial search string "PIC24F". It
was a Microchip datasheet (AC characteristics section). QFP package if
that makes any difference. I might have misread it though.

Thanks for your reply. I scanned the PIC24FJ64GA004 datasheet and the
PIC24 Family Reference Manual's oscillator chapter with no luck. 464
ohms sounds super-heavy, so I suspect that must be a misprint, but I
couldn't find it anywhere. Luckily DJ's in clover now, so no worries.

Cheers,
James Arthur
 
J

James Arthur

My "scope" is a cheap parallel-port 32Ms scope. It's not sensitive
enough for a 100x probe.

Anyway, I relayed the RTC's 1s interrupt to a GPIO pin and measured it
with the logic analyzer (500Ms/s compressed :). Assuming the LA is
"perfect" (ha), the 32k crystal is fast by 36ppm at the moment (and
reasonably stable at that). That's 3 seconds/day, well within the
adjustability of the RTC, and probably something I can tune with
capacitors on the PCB later.

Good--glitch problem solved.
Anyway, I attached the scope probe and the RTC ran *way* slow
(relatively speaking, still ppm), so added capacitance will definitely
slow the clock. Unfortunately, the spec sheet for the crystal doesn't
have a cap/freq curve, so it will be trial and error.


Not that you need it, but here's a poor man's low-frequency FET probe
you can kludge together just in case...

|\ FET-input op-amp.
| \ LF356, TL082 etc.
--o--------|+ \
| | >---o------->
| .-|- / |
R1 [10M] | | / |
| | |/ |
| C1 | |
| 100n | |
o--||--o---------'
|
|
R2 [10M]
|
===
GND

Run it on +/- 12v. It's simple, not great, but way better than your
'scope for probing that 32KHz clock.

Cheers,
James Arthur
 
D

DJ Delorie

James Arthur said:
Not that you need it, but here's a poor man's low-frequency FET probe
you can kludge together just in case...

I was wondering how to do that. Thanks!
 
Top