How to use a crystal

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 +----||----------+--/\\/\\---<

Reply to
Peter S. May
Loading thread data ...

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.

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.

Reply to
Anthony Fremont

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

Reply to
Peter S. May

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?

Cool. :-)

Reply to
Anthony Fremont

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

Reply to
Peter S. May

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

formatting link

Reply to
DJ Delorie

Eh, _the_ DJ Delorie? Ah, how I miss playing Merlin on the secondhand Agenda VR3 I had... :-)

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.

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.)

IIRC, the PIC's data sheet specifies that it can run several baud rates with a +0.16% error...sounds good.

I'll have to give that a look!

Thanks PSM

Reply to
Peter S. May

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.

You'll soon see how easy they are. I started on the 16F84 using only crystals. I really like the 8MHz INTOSC.

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. ;-)

Reply to
Anthony Fremont

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

Reply to
Rich Grise

Reply to
Bruce Varley

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

Reply to
mpm

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.