RTC's and do I need one with the ATmega 0 series - Page 1
Forum section: electronics / general

author: Simon
author_rank: Unknown
timestamp: March 23, 2019, 10:46:12 am
content: I have a project where I am required to keep the time for data logging purposes. So I have not really looked into this yet but i am aware that there are RTC chips that will keep time and the new ATmega 0 series micro controllers have a dedicated counter and watch crystal driver for time keeping but I which can require several seconds between interupting the CPU to update a time count.I'm wondering what people suggest as options?

author: Psi
author_rank: Super Contributor
timestamp: March 23, 2019, 11:48:56 am
content: You will want to store UTC to avoid having to deal with timezones. Adjust for timezone on PC when data is extracted.The most common way to store time on MCU is a HW counter that can store a number of seconds since some fixed date.You will want a 32 bit hardware timer that can be clocked by the 32khz xtal while the mcu is in sleep mode.Avoid any mcu that only has 16/24bit timers.(You can link timers together to clock each other but its annoying and may need to wakeup the cpu to do itSo a 32bit counter clocked by 32khz xtal makes things much easier.).You may want a mcu that has a reset/WDR interrupt vector.If you code it carefully you can save the timer value before WDR/user reset by using the reset interrupt. Then load it back in at boot up to avoid losing the time from a WDR or user reset. A POR reset should be allowed to clear the counter.If you need full day/date/month info on the mcu i would highly recommend a MCU that has a RTC with full calendar support built in. Read the RTC info carefully and do a google search for problems people have with it before making your final choice. I've heard stories about some mcus having RTC calendar modules that are shit while others work fine.

author: 2N3055
author_rank: Super Contributor
timestamp: March 23, 2019, 12:53:20 pm
content: Quote from: Simon on March 23, 2019, 10:46:12 amHi Simon,Atmel AVR134 AN explains it a bit. Basically MCU will have to wake up to keep time.. External RTC will keep time independently.. So if you need to wake often for logging (like, every sec) you can keep RTC with AVR and loose nothing. If you need to wake up only every 10 min. than using external RTC might be the way to go..An engineering trade-off as allways...Regards,

author: Simon
author_rank: Unknown
timestamp: March 23, 2019, 01:14:27 pm
content: I'd only need to log when the unit is active so it's just power required to keep the time.

author: 2N3055
author_rank: Super Contributor
timestamp: March 23, 2019, 02:08:06 pm
content: I'd use external RTC in that case...

author: westfw
author_rank: Super Contributor
timestamp: March 23, 2019, 11:53:37 pm
content: An external rtc can be essentially be set and forgotten, while the mega0 rtc is much more primitive and requires a fair amount of initialization and care. For loggers, I think I’d definitely prefer the external rtc.

author: blacksheeplogic
author_rank: Frequent Contributor
timestamp: March 24, 2019, 12:46:16 am
content: Not familiar with the MCU you are using but I've had problems in the past with using HW counters for time keeping as accuracy often is +/- Seconds per day. Also the other irritation I've run into with HW counters is needing to wait for the clock to stabilize after boot.

author: Simon
author_rank: Unknown
timestamp: March 24, 2019, 08:36:58 am
content: Yes an external RTC sounds like the most painless option. I have been trawling through the datasheet for the ATmega3208 and i can't say for certain what the power draw would be for the chip running on just the 32KHz crystal counting time. At least with a dedicated chip it can sit and run from a seperate power source.

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: March 24, 2019, 09:35:07 am
content: One of the main sources of error is frequency drift due to temperature. MCUs with an RTC and an external 32kHz don't have that, so won't be accurate.Personally, I just use a Maxim (formerly Dallas) Dallas DS3231 and that gives the most accurate clock for a reasonable price.