PIC Internal Clock -- How accurate?

Can I trust a PIC's 4Mhz internal clock to keep accurate time over days of use? Or will I need an external crystal. I'm vary weary of that, as I'm going for a compact design. Thanks for the help.

sort by: active | newest | oldest
1-10 of 19Next »
zachninme (author) 9 years ago
I just realized. I'm keeping 4 of these guys together, and they all have to be +/-0.0012% of each other, so they'll all be at the same temperature, so is temperature the only major factor? If it is I should be set.

I'm also thinking of using an Atiny (the number escapes me right now, but the 8-pin).
westfw9 years ago
It's in the spec sheet; on the order of 2%, IIRC. Nowhere NEAR 0.0012% or 30s/month accurate, but (just barely) accurate enough to do serial comm, if you're lucky.
zachninme (author)  westfw9 years ago
Hrm... Do resonators tend to be less accurate than crystals? I'm thinking about those since their size is what I need.
Traditionally, clocks use 32.768kHz "watch crystals", which are available in quite tiny packages (there is probably one inside your watch!)
VIRON westfw9 years ago
PICs can use watch crystals, even though they are really slow compared to 4Mhz, they can be used to make a PIC clock, and may run over a year because PICs use very little power when they are run at 32768 hz. They probably would be just as accurate as a quartz watch then.
zachninme (author)  VIRON9 years ago
Speed doesn't matter, its for a clock, so I could technically use a 1Hz crystal -- if it existed.
Hey. I've done a few microcontroller clock projects too - accurate timing is always the hardest/most annoying part. The major problem I've found with using an internal clock is not the accuracy - it's easy to compute a correction factor, but the problem is that it is highly temperature dependant, so your correction factor goes out the window. Using a watch crystal is a good solution - it's a little bit of work to get it running, but it's a good cheap and low power solution. Another solution is a DS1307 chip - it can be used a 1Hz source without using it's complicated RTC funtions. You can therefore link the 1Hz output to an interrupt pin. Or if you are up for some i2c coding you can use the RTC clock function. Let us know how you go.
Most of the somewhat larger PICs have both the CPU oscillator, which can be internal at about 4MHz, AND a timer that can be set up to use an external 32kHz watch crystal, AND a sleep mode that lets the timer run along on its 32kHz crystal (at very low power) while the main CPU oscillator is turned off. This lets you have low average power with crystal timing accuracy, while still letting you do more complex CPU calculations when you need to. A bunch of other chips (TI's MSP430 comes to mind. Maybe some of the newer PICs?) derive the CPU clock from a 32kHz crystal using PLL clock multipliers, so you have the high accuracy timebase AND a high-speed CPU clock of reasonable accuracy. (Sometimes, however, relatively high "jitter." Our Network Time Protocol folk were cursing out the 68331 cpu that did this at one time...)
gmoon VIRON9 years ago
The 32.768K xtal value is easily dividable to obtain a precise 1Hz value, hence their use in clocks. I'm sure, as you say, the lower power consumption of the slow clock speed is a useful byproduct. With AVRs, no loading caps are needed with the clock xtals, also (maybe PICs, too?)
westfw westfw9 years ago
(and to answer your question, I think resonators tend to be about 100 times more accurate better than RC circuits (like the internal oscillator), and crystals about 100 times better than resonators.) Keep in mind that some of the accuracy of cheap digital watches comes from the fact that they're kept at a pretty constant temperature by body heat...
1-10 of 19Next »