Maker Pro
Maker Pro

How to use a crystal

P

Peter S. May

Jan 1, 1970
0
I've never used a timing crystal before--awesome, right?--so I'm trying
to decode some information from the data sheet of my micro (PIC 16F88)
and the catalog page for the crystal (11.0592MHz, 32pF impedance) and
find that I don't know enough about the analog circuit to reconcile them.

The PIC sheet says that this is how to hook a crystal up to the PIC:

C1, ca. 15pF in . (inside PIC)
+----||----------+---------> >----+------+
| | . \ |
GND |--+ [=] XTAL . / Rf V inverter
| | out . \ o
+----||----------+--/\/\---< <----+------+
C2, ca. 15pF Rs .

The same sheet, however, is very careful not to actually commit to
anything, saying the the values for C1 and C2 may not be optimal, and
that Rs may or may not be necessary, but with no real guideline to
decide its value if it is. It defers to the specifications of the
crystal itself. The crystal's sheet contains no sample schematics, but
the catalog page does...but that looks like this:

XTAL C3, 32pF (match impedance of crystal)
+----[=]------||------+
| |
+--/\/\---------------+
| 2.2K |
| |
+----------+----->o---+---->o----> output
| | inv. | inv.
= C1, \ = C2,
| 150- / 4.7K | 220-820pF
| 470pF \ |
| | |
+----------+----------+---| GND

That's easy enough for me to understand if I'm trying to clock some
device with just a plain CLK pin, but I'm not sure how it translates to
the PIC's two oscillator pins, which seem to be intended to factor out a
few parts. (And even this schematic gives no guidance how to choose C1
or C2, but then they probably assume that buyers of crystals already
know what to do with them.)

Anyway, I could use some guidance: I have (or will be buying) a crystal
with 32pF impedance, and I want to hook it up to a PIC. How do I do it?

Thanks
PSM
 
A

Anthony Fremont

Jan 1, 1970
0
Peter said:
I've never used a timing crystal before--awesome, right?--so I'm
trying to decode some information from the data sheet of my micro
(PIC 16F88) and the catalog page for the crystal (11.0592MHz, 32pF
impedance) and find that I don't know enough about the analog circuit
to reconcile them.

The PIC sheet says that this is how to hook a crystal up to the PIC:

C1, ca. 15pF in . (inside PIC)
+----||----------+---------> >----+------+
| | . \ |
GND |--+ [=] XTAL . / Rf V inverter
| | out . \ o
+----||----------+--/\/\---< <----+------+
C2, ca. 15pF Rs .

The same sheet, however, is very careful not to actually commit to
anything, saying the the values for C1 and C2 may not be optimal, and
that Rs may or may not be necessary, but with no real guideline to
decide its value if it is. It defers to the specifications of the

That's because each situation is different. Stray capacitance matters, and
there is no way for the xtal manufacturer to know how much you have in your
circuit. The crystal manufacturer also doesn't know the absolute specifics
of the oscillator you will be using. Likewise, Microchip can't guess the
absolutes of your crystal. You do need to be using a parallel resonant
crystal though, or it will oscillate off frequency.
crystal itself. The crystal's sheet contains no sample schematics,
but the catalog page does...but that looks like this:

Anyway, I could use some guidance: I have (or will be buying) a
crystal with 32pF impedance, and I want to hook it up to a PIC. How
do I do it?

To start, do it the way the PIC datasheet shows, but leave out Rs. Start
with some 22 or 33 pf caps, and adjust as necessary to obtain the frequency
accuracy you need. Unless you are doing some extremely serious timing,
you'll be fine. You should be well within 100ppm without any further
tinkering. IOW, you're making this harder than it really is. ;-) Just
hook it up and go from there.
 
P

Peter S. May

Jan 1, 1970
0
Anthony said:
tinkering. IOW, you're making this harder than it really is. ;-) Just
hook it up and go from there.

I figured I was, but I haven't established a junk box of assorted
capacitors yet and, the RadioSnack (my local one in particular) just not
being what it once was, I need to know what I need to order from Jameco
in advance. All will be subject to experimentation, but I needed to
know what I needed to have on hand to experiment in the first place.

By the way, this helped. Thanks. :)
PSM
 
A

Anthony Fremont

Jan 1, 1970
0
Peter said:
I figured I was, but I haven't established a junk box of assorted
capacitors yet and, the RadioSnack (my local one in particular) just
not being what it once was, I need to know what I need to order from
Jameco in advance. All will be subject to experimentation, but I
needed to know what I needed to have on hand to experiment in the
first place.


Ceramic caps typically have allot of variation in their actual values vs.
marked values. It would be easier to give advice if I knew exactly how much
accuracy you need, and why you chose the 11.0592MHz xtal. If you are
worried about serial comm speed, then don't as you will be well within
working tollerances even if you used the INTOSC module. If you are trying
to obtain the accuracy of a quartz watch then you will need a trimmer cap to
tweak it by a few ppm. So, what are you building?
By the way, this helped

Cool. :)
 
P

Peter S. May

Jan 1, 1970
0
Anthony said:
Ceramic caps typically have allot of variation in their actual values vs.
marked values. It would be easier to give advice if I knew exactly how much
accuracy you need, and why you chose the 11.0592MHz xtal. If you are
worried about serial comm speed, then don't as you will be well within
working tollerances even if you used the INTOSC module. If you are trying
to obtain the accuracy of a quartz watch then you will need a trimmer cap to
tweak it by a few ppm. So, what are you building?

Good call--the 11.0592MHz is for running an RS-232 interface to operate
what amounts to a large LED display with the possibility of adding
pushbutton on rotary encoder inputs later (other recent posts of mine
describe it ad nauseam). From just reading the data sheet of the PIC I
figured that the internal RC would be sufficient for serial (they seem
to think it is), but one or two comments in my threads have been saying
that the error would be too great and that I should go with something
more precise.

In any case, I want to know how to use a crystal anyway in case some
other project I do uses a device with no internal clock (e.g., one
cheaper PIC16 has 22 I/O pins but no internal clock).

The RS-232 interface is the only part that really requires any degree of
timing precision, because the human interface tolerances are bounded on
outputs by persistence of vision (60Hz refresh of 128 output bits) and
on inputs by how fast a human being can repeatedly press a button or
spin a wheel without the aid of a motor (20kHz sample rate of 16 to 32
input bits, as a safe overkill margin). I'd like to run the RS-232 at
faster than 9600bps if possible, but I figured that I could start low
and step up incrementally by changing software settings on both the PC
and the PIC.

Thanks
PSM
 
D

DJ Delorie

Jan 1, 1970
0
Having just gone through this myself...

The "load capacitance" is the total capacitance the filter sees.
Thus, you start with this number, subtract any stray capacitance (the
crystal itself has a pF or two, read the spec), and multiply by two
(you have two caps in series as far as the filter sees, because of the
crystal between them). Thus, for 32pF load, you're going to want two
64pF caps, or so. This is for series resonant crystals, at least.

The Rs is needed if the total gain of the circuit is too high. The
output of the chip should be a sine wave, not clipped. Adding Rs
keeps it from clipping. The faster the crytal, the less Rs you need.

RS232 doesn't have to be that precise, so as long as the clock is
within a percent or two, you'll be fine. It will probably be off by a
few orders of magnitude LESS than that, if it's running at all.

As for spares kits, I got mine from www.vakits.com.
 
P

Peter S. May

Jan 1, 1970
0
DJ said:
Having just gone through this myself...

Eh, _the_ DJ Delorie? Ah, how I miss playing Merlin on the secondhand
Agenda VR3 I had... :)
The "load capacitance" is the total capacitance the filter sees.
Thus, you start with this number, subtract any stray capacitance (the
crystal itself has a pF or two, read the spec), and multiply by two
(you have two caps in series as far as the filter sees, because of the
crystal between them). Thus, for 32pF load, you're going to want two
64pF caps, or so. This is for series resonant crystals, at least.

The data sheet says specifically to avoid series crystals for this
application, so I'm looking at one not listed as "series" but with an
impedance of 32pF (that's gotta be short for something, right? Isn't
impedance proper measured in ohms?). I gather that different rules apply.
The Rs is needed if the total gain of the circuit is too high. The
output of the chip should be a sine wave, not clipped. Adding Rs
keeps it from clipping. The faster the crytal, the less Rs you need.

It did say it was speed dependent, and/or based on use of an "AT strip
cut crystal". (Haven't yet looked up what that means, but I figure the
catalog page would have mentioned it if it applied.)
RS232 doesn't have to be that precise, so as long as the clock is
within a percent or two, you'll be fine. It will probably be off by a
few orders of magnitude LESS than that, if it's running at all.

IIRC, the PIC's data sheet specifies that it can run several baud rates
with a +0.16% error...sounds good.
As for spares kits, I got mine from www.vakits.com.

I'll have to give that a look!

Thanks
PSM
 
A

Anthony Fremont

Jan 1, 1970
0
Peter said:
Good call--the 11.0592MHz is for running an RS-232 interface to
operate what amounts to a large LED display with the possibility of
adding pushbutton on rotary encoder inputs later (other recent posts
of mine describe it ad nauseam). From just reading the data sheet of
the PIC I figured that the internal RC would be sufficient for serial
(they seem to think it is), but one or two comments in my threads
have been saying that the error would be too great and that I should
go with something more precise.

It depends. The error at moderate temperatures is less than 1% and less
than 2% over the entire range, IIRC. As long as you pick a baud rate with a
small divisor error, you will likely have no trouble communicating with
other devices.
In any case, I want to know how to use a crystal anyway in case some
other project I do uses a device with no internal clock (e.g., one
cheaper PIC16 has 22 I/O pins but no internal clock).

You'll soon see how easy they are. I started on the 16F84 using only
crystals. I really like the 8MHz INTOSC.
The RS-232 interface is the only part that really requires any degree
of timing precision, because the human interface tolerances are
bounded on outputs by persistence of vision (60Hz refresh of 128
output bits) and on inputs by how fast a human being can repeatedly
press a button or spin a wheel without the aid of a motor (20kHz
sample rate of 16 to 32 input bits, as a safe overkill margin). I'd
like to run the RS-232 at faster than 9600bps if possible, but I
figured that I could start low and step up incrementally by changing
software settings on both the PC and the PIC.

You don't really have to use a 11.0592MHz crystal unless you want zero error
on all baud rates. You can get .16% accuracy with 4MHz or 8MHz crystals on
baud rates of 19,200 or less. In my experience 19,200 has worked fine with
everything I've tried talking to, using only the INTOSC module as the clock.
The bonus is that the datasheet tells you what to load into SPBRG without
having to do any math. ;-)
 
R

Rich Grise

Jan 1, 1970
0
It did say it was speed dependent, and/or based on use of an "AT strip
cut crystal". (Haven't yet looked up what that means, but I figure the
catalog page would have mentioned it if it applied.)

You're making mountains out of molehills here - the cap values aren't
critical at all, unless you're looking for an atomic-grade real-time
clock. You could even use a couple of "gimmicks". You'll have to look
it up; I don't want to make this too easy for you. ;-)

But the point is, I've used just the crystal, and two "small" caps,
like 22 or 33 pF, and always had oscillators oscillate.

Sometimes they vary the ratio, to twiddle with the drive levels, but
unfortunately, I either drank or slept my way through the class where
they teach how to figure out the values. ;-)

Cheers!
Rich
 
B

Bruce Varley

Jan 1, 1970
0
Peter S. May said:
I've never used a timing crystal before--awesome, right?--so I'm trying
to decode some information from the data sheet of my micro (PIC 16F88)
and the catalog page for the crystal (11.0592MHz, 32pF impedance) and
find that I don't know enough about the analog circuit to reconcile them.

The PIC sheet says that this is how to hook a crystal up to the PIC:

C1, ca. 15pF in . (inside PIC)
+----||----------+---------> >----+------+
| | . \ |
GND |--+ [=] XTAL . / Rf V inverter
| | out . \ o
+----||----------+--/\/\---< <----+------+
C2, ca. 15pF Rs .

The same sheet, however, is very careful not to actually commit to
anything, saying the the values for C1 and C2 may not be optimal, and
that Rs may or may not be necessary, but with no real guideline to
decide its value if it is. It defers to the specifications of the
crystal itself. The crystal's sheet contains no sample schematics, but
the catalog page does...but that looks like this:

XTAL C3, 32pF (match impedance of crystal)
+----[=]------||------+
| |
+--/\/\---------------+
| 2.2K |
| |
+----------+----->o---+---->o----> output
| | inv. | inv.
= C1, \ = C2,
| 150- / 4.7K | 220-820pF
| 470pF \ |
| | |
+----------+----------+---| GND

That's easy enough for me to understand if I'm trying to clock some
device with just a plain CLK pin, but I'm not sure how it translates to
the PIC's two oscillator pins, which seem to be intended to factor out a
few parts. (And even this schematic gives no guidance how to choose C1
or C2, but then they probably assume that buyers of crystals already
know what to do with them.)

Anyway, I could use some guidance: I have (or will be buying) a crystal
with 32pF impedance, and I want to hook it up to a PIC. How do I do it?

Thanks
PSM
 
M

mpm

Jan 1, 1970
0
You're making mountains out of molehills here - the cap values aren't
critical at all, unless you're looking for an atomic-grade real-time
clock. You could even use a couple of "gimmicks". You'll have to look
it up; I don't want to make this too easy for you. ;-)

But the point is, I've used just the crystal, and two "small" caps,
like 22 or 33 pF, and always had oscillators oscillate.

Sometimes they vary the ratio, to twiddle with the drive levels, but
unfortunately, I either drank or slept my way through the class where
they teach how to figure out the values. ;-)

Cheers!
Rich

No, that is not (always) true.
At least, not in the general sense.
The caps do serve to load and warp the frequency, but they are also
there (or not there!) to guarantee the oscillator startup time.!!

I can tell you with great certainty that the AT89S8253 will NOT work @
11MHz with too much capacitance on the XTAL pins. (say 12pF). But
it will work just fine with 5pF, or even with no caps.

Atmel finally revised their Datasheet to reflect this. (Originally,
it suggested 33pF.)

If I am envisioning the curve correctly in my mind, crystal loading as
it relates to guaranteed startup (in fact, startup at all...), is more
a concern for lower xtal frequencies.

Also, I suspect the datasheet may also be considering the use of
resonators, which would explain the reluctance to set a specific
crystal cap value in stone.(?)

-mpm
 
Top