Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Time drift between 16F628A and 16F876

Status
Not open for further replies.

SPDCHK

Member
I use Timer1 on 500ms interrupt routine to run code for a real time clock.

On the PIC16F628A the time is quite accurate (about 1sec drift per day). On the 16F876 it's much worse, (about 15 seconds to the hour).

Both designs are the same as far as decoupling cap on the power supplies, 4MHZ Xtal with 33pf decoupling caps.

Can anyone shed some light on why there's such a big difference between these two models of PIC? BTW, It has happened now in two applications, so it's not some random thing. With both applications where I use the 16F876 the time just "runs away"

Thanks.
 
I'm using 10mS interrupts & generating the seconds within ISR for 4Mhz crystals.

I'm using TMR1 as an external cloock, using a 32khz crystal would perfectly do the job.

I haven't caught any inaccurate results.So no need to do an error correction within the software.

The below clock of mine works fine for long time, I just used a 4Mhz crystal.
 

Attachments

  • ALClock.JPG
    ALClock.JPG
    61 KB · Views: 1,020
Last edited:
SPDCHK said:
Both designs are the same as far as decoupling cap on the power supplies, 4MHZ Xtal with 33pf decoupling caps.

33pf capacitors are at the high end of the microchip recommended range of values for that frequency crystal.
Try using lower value capacitors such as 22pf which usually works very well with 4Mhz crystals.
Also see this piclist info:
 
For better results PCB is fine, some breadboards worst accuracy.

Hint! you can ground the metal on the crystal & see.I do this when I make them on a PCB for final product.
Nice clock design Gayan.
Thanks blueroomelectronics.Ya I like the messy wiring with a hardest code:D
 
Last edited:
gramo said:
You will always get drift because of temperature deviations and circuit anomalies, but the slower the xtal, generally the better the accuracy.

I've also used the 32Khz Xtals with great accuracy

I feel the same way, I've had great luck with watch crystals but the faster the crystal the more they seem to drift. I recall another thread where I was told this is a misconception.
 
So, the accuracy of the crystal has nothing to do with the oscillation frequency? Any proof saying that the slower the crystal, the better accuracy it has?
 
Well if a crystals quality is measured in PPM (parts per million) then a slower crystal with the same PPM would be more accurate.
You can usually tune a crystal by adding a trimcap to one of its legs.
 
blueroomelectronics said:
Well if a crystals quality is measured in PPM (parts per million) then a slower crystal with the same PPM would be more accurate.

I would like to point out that you missed out the smilie. This was tongue in cheek wasn't it? Or did I miss something?

Mike.
 
blueroomelectronics said:
Well if a crystals quality is measured in PPM (parts per million) then a slower crystal with the same PPM would be more accurate.
This is one of those things that you really need to think about Bill (grin)...
 
SPDCHK said:
With both applications where I use the 16F876 the time just "runs away"
Assuming there are no software issues:
Have you tried changing the oscillator mode in CONFIG. ie: XT vs HS mode?
As mentioned above, 15-22pf caps are the ones that MicroChip recommends for a 4 Mhz xtal.
Are you using an A-T cut crystal?
 
Pommie said:
I would like to point out that you missed out the smilie. This was tongue in cheek wasn't it? Or did I miss something?

Mike.

OK, I slipped up :) but I still say the slower crystals seem to keep time better.
 
Thanks for all the replies.

kchriste said:
15-22pf caps are the ones that MicroChip recommends
Oops, my mistake. I only looked on table 14.1, where they show ranges tested, and not on the table on the next page Table 14-2, Capacitor selection :eek:

kchriste said:
Are you using an A-T cut crystal?
I don't know? As a hobbyist I salvage crystals from old PCB's. To be honest, in the current application I used one of those crystals with the three pins, that already has the capacitors included, but in my previous application, I used a metal case crystal with the caps as mentioned. BUT, in both applications (with the 16F876) the time was drifting.

kchriste said:
Have you tried changing the oscillator mode in CONFIG. ie: XT vs HS mode?
No. Both applications are set for XT. That might be worth a try. Thanks.
 
SPDCHK said:
I don't know? As a hobbyist I salvage crystals from old PCB's. To be honest, in the current application I used one of those crystals with the three pins, that already has the capacitors included, but in my previous application, I used a metal case crystal with the caps as mentioned. BUT, in both applications (with the 16F876) the time was drifting.



The crystal with 3 pins is a ceramic resonator, in order of least to best accuracy;


RC (Resistor & Capacitor)
Ceramic Resonator
Crystal Oscillator (Metal cases)
 
blueroomelectronics said:
OK, I slipped up :) but I still say the slower crystals seem to keep time better.

The 32KHz crystals are specifically designed for clock use, so probably have better long term stability, as it's important for that use.
 
Gayan Soyza said:
I'm using 10mS interrupts & generating the seconds within ISR for 4Mhz crystals.

I'm using TMR1 as an external cloock, using a 32khz crystal would perfectly do the job.

I haven't caught any inaccurate results.So no need to do an error correction within the software.

The below clock of mine works fine for long time, I just used a 4Mhz crystal.
Gayan plz send me that code,
i m also having problem with timer ....
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top