PDA

View Full Version : Crystal oscillator variability between PICs?



achilles03
- 1st May 2021, 20:17
I have a timing critical application and am running an 8Mhz xtal with a 16F628a. When I program chip 1 with given HEX code (compiled with PBP), it runs roughly 23 ppm slow. I programmed a different 16F628a with the exact same code (same xtal and osc caps, same board, same ambient temperature, same spot on the table), and it runs about 800 ppm slow. What could explain this much variation between PICs with the same external crystal oscillator? Could some threshold or internal capacitance be slightly different between the two chips to affect oscillator freq that much? Everything's soldered on the board except the chip, which uses a socket.

Also here's the obligatory monkey wrench: chip 1 seemed to run just fine with an 8Mhz crystal with the XT osc setting, so I am using the XT osc setting for both chips. Could that have something to do with it? When I have a chance to get back to the workbench, I plan on changing to HS to see if that does anything to either chip, but wanted to see if anyone had any experience with something like this.

Thanks in advance!
Dave

pedja089
- 2nd May 2021, 00:42
You should be using HS. Try it...

achilles03
- 2nd May 2021, 23:55
Yeah, that was it. After switching to HS it went from about 800ppm slower than I wanted to about 125ppm faster. The first chip also went from 23ppm slower to roughly 125ppm faster. For clarity, being 125ppm faster doesn't mean the crystal is off by 125ppm, it just means I need to add some pauseus statements to get my code spot-on.

Thanks,
Dave

mpgmike
- 3rd May 2021, 00:19
You got me thinking; you are using an old PIC. The PIC itself has a part in driving the oscillator crystal. Would a newer PIC, with "better" technology be more accurate than 125 ppm?? I have a time-critical project I'm using a PIC18F27Q43 with a 16 MHz crystal to generate a 64 MHz Fosc (w/PLL). It seems to be as accurate as my scope can show. Just thinking out loud.

rocket_troy
- 4th May 2021, 23:43
Yeah, I've read somewhere the new internal oscillators are supposed to be better than the old PICs.

Some things to also keep in mind for really time critical applications - temperature of the oscillator which is manageable, but also acceleration if the oscillator is used in a dynamic environment. This includes substantial vibration. It has been suggested by some that this is the primary reason why all off-the-shelf GPS/GNSS modules are nominally limited to 4g acceleration before losing positional lock.

Troy

Ioannis
- 7th May 2021, 11:42
By internal oscillator you mean the RC internal oscillator, that has nothing to do with eternal Xtal oscillator.

The RC will always be off because of tolerances and temperatures.

Now, regarding the Xtal itself, will be off a bit by construction. But little and well defined on the datasheet. The most important factor though, for the precision of the frequency is the loading of the xtal (some are loaded in series, most are parallel loaded). User have to read the datasheet and see what capacitance needs the Xtal so it operates as expected. Too much or too little loading may result in slower or no oscillation. One of the loading capacitors may be a trimmer cap and be adjusted to obtain precise frequency.

Ioannis

Acetronics2
- 7th May 2021, 12:43
If you need high precision timing ... just do use external oscillators like those : https://www.mouser.fr/datasheet/2/96/CTS_11052019_008-0258-0_I_MXO45_MXO45HS-1665263.pdf

just my two cents ... :rolleyes:

poor man will add a trimmer capacitor in the Xtal circuit, but to be trimmed for each chip ...

Other cheap solution is to turn to a 16F88 or 87 ( pin compatible ) and play with the OSCTUNE register ...

Alain

Ioannis
- 8th May 2021, 20:58
Once again I do not receive notifications of new post. Does anyone else have the same problem?

Ioannis

peterdeco1
- 10th May 2021, 15:12
Yes same problem here. I used to but not anymore.

Ioannis
- 13th May 2021, 11:25
Lester has taken care of this and hopefully we do receive replies now.

Please post to test others.

Ioannis

peterdeco1
- 13th May 2021, 14:34
Well I didn't receive a notification that this thread was replied to. I guess it's still not working.

Ioannis
- 14th May 2021, 20:25
I am sure it does work. Check it please.

Ioannis

Acetronics2
- 15th May 2021, 08:26
Hi, Ioannis

I didn't receive any notification nor for posts 8 to 11 ... just for the last one ( Yours )

Best Regards
Alain

peterdeco1
- 15th May 2021, 08:47
It's working for me now.

Ioannis
- 15th May 2021, 12:53
Alain, about the time I posted Lester resolved the problem.

It should be OK now.

Ioannis