5
\$\begingroup\$

I'm working on a project that uses a Atmega329 with a 2 digit lcd 7 segment display. It needs to keep track of days, using a small coin cell battery.

I originally planned on using the on board clock, as the accuracy doesn't have to be great, I'm fine with a couple hours each month off.

Doing some testing, I noticed that it is off by up to a few seconds every minute (this is used in varying temperatures). So I need an external clock source.

Should I use a higher frequency crystal and clock it down internally? Example: 16Mhz crystal, using a clock speed of 8 or 4 mhz to save battery life. Or should I use a 8Mhz crystal and keep it at that speed?

Would a ceramic oscillator have enough accuracy and temperature stability to use? I'll be going from 0c to 25c

Thanks

\$\endgroup\$
4
  • \$\begingroup\$ The title of your question is about consumption, but content of your question is about accuracy. So something should be fixed. \$\endgroup\$ Commented Aug 14, 2017 at 22:59
  • \$\begingroup\$ @chupacabras Yup, fixed \$\endgroup\$ Commented Aug 15, 2017 at 1:12
  • \$\begingroup\$ "Example: 16Mhz crystal, using a clock speed of 8 or 4 mhz to save battery life." - In another question, someone here found that 16MHz + clock divider uses more power than using a lower speed crystal without divider. And intuitively it makes sense this way too. \$\endgroup\$
    – JimmyB
    Commented Aug 15, 2017 at 12:48
  • \$\begingroup\$ "I noticed that it is off by up to a few seconds every minute" - You should be able to calibrate the RC oscillator to better accuracy than that. \$\endgroup\$
    – JimmyB
    Commented Aug 15, 2017 at 12:50

1 Answer 1

9
\$\begingroup\$

Use a 32.768kHz crystal or tuning fork. It can run asynchronously and you'll save as much power as you can while still having a clock. The system clock will still use the internal RC oscillator.

\$\endgroup\$
4
  • \$\begingroup\$ OK that sounds like a plan. So the only time the external oscillator is really needed is when you need to increase clock speed or run at an odd frequency? \$\endgroup\$ Commented Aug 14, 2017 at 22:58
  • 2
    \$\begingroup\$ Yes. Higher frequency, or a specific frequency. The internal oscillator runs at "about" 8MHz. That's often not good enough for some applications, but crystals can do much, much better. \$\endgroup\$
    – uhours
    Commented Aug 14, 2017 at 23:05
  • 1
    \$\begingroup\$ To be more specific: the datasheet says "7.3 - 8.1 MHz". It's a pretty wide range. \$\endgroup\$
    – user39382
    Commented Aug 15, 2017 at 0:29
  • 2
    \$\begingroup\$ Add to this: while you can use the separately-clocked counter on the microcontroller as a real time clock, if you're running for a long time on battery sources it would be much more efficient to use a dedicated clock controller chip (e.g. a DS1307) and only power the microcontroller when you actually need it. DS1307s are available for pennies and using one could make your battery last much longer. \$\endgroup\$
    – Jules
    Commented Aug 15, 2017 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.