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\$
  • \$\begingroup\$ The title of your question is about consumption, but content of your question is about accuracy. So something should be fixed. \$\endgroup\$ – Chupacabras Aug 14 '17 at 22:59
  • \$\begingroup\$ @chupacabras Yup, fixed \$\endgroup\$ – Kyle Hunter Aug 15 '17 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 Aug 15 '17 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 Aug 15 '17 at 12:50
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.

| improve this answer | |
\$\endgroup\$
  • \$\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\$ – Kyle Hunter Aug 14 '17 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 Aug 14 '17 at 23:05
  • 1
    \$\begingroup\$ To be more specific: the datasheet says "7.3 - 8.1 MHz". It's a pretty wide range. \$\endgroup\$ – duskwuff -inactive- Aug 15 '17 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 Aug 15 '17 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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