Society of Robots - Robot Forum

Software => Software => Topic started by: silo_xtreme on December 14, 2009, 09:24:33 PM

Title: Timer vs Real Time counter
Post by: silo_xtreme on December 14, 2009, 09:24:33 PM
Hey All,

I'm just wondering if anyone uses the RTC on an AVR chip?  I'm wondering if the RTC is really "that much more accurate" than a typically 16 bit timer. 

Any thoughts?

Mike
Title: Re: Timer vs Real Time counter
Post by: hopslink on December 15, 2009, 07:32:20 AM
The quick answer is that the RTC will be no more accurate than a 16 bit timer(assuming both are run from a clock source with identical accuracy). The main reason for using the RTC inputs would be for simple (and accurate) seconds-based timing. 

In terms of accuracy, much of the time the internal oscillator is accurate enough and offers the bonus of extra IO pins and circuit simplicity. If you need very accurate timing from a microcontroller system you would run it from an external Xtal (crystal) oscillator not the internal RC (Resistor Capacitor) oscillator. Xtal oscillators typically have much tighter frequency tolerances and suffer less frequency drift with temperature.   

You would use the RTC inputs and an external watch Xtal (typically oscillating at 32768Hz) if you wanted to have time (seconds, minutes, hours...) functionality in your system. The benefit comes from the integer power of 2 division of the clock frequency to the exact time base you want. Alternatively if you do not need high processing throughput you could use a watch Xtal for the main system clock to get the same effect.

Similar examples where you might use a specific frequency for the system clock include serial comms and video applications (just two common ones off the top of my head, there are probably loads more).
Title: Re: Timer vs Real Time counter
Post by: silo_xtreme on December 15, 2009, 07:48:17 AM
Thanks Hopslink! :)