RTC (Real Time Clock) - External or programmed?

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey guys! I'm building an alarm clock of sorts, but I am thinking about if I should use an external RTC or do one in software on my Atmega48 that I'm going to use..!

I have some DS1307 RTCs and some others laying around, but it will take up a little more space a thing which I will not have a lot of! Though something as small as a DS1307 will not be a problem, but the backup-battery (which is optional though) might be a bit of a problem...

Programming a RTC in software will take up a bit more program code and more time to implement, but I don't really mind spending the extra time and 4K flash should be more than enough I am fairly certain.
(Things I will be using on the mega48 is; character LCD, 3 buttons, one PWM channel)

So basically what I'm asking is, what would you do, and why? Pros and cons?

- Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd use the Maxim-Dallas: Likely more accurate and likely easier to isolate power usage (you can even have its alarm interrupt the AVR to wake it up). If you go with AVR+watch crystal how will you handle battery backup if you want to use that?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
If you go with AVR+watch crystal how will you handle battery backup if you want to use that?

I have this sketch in my vaults from an earlier discussion here at AVRfreaks:

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The accuracy of the RTC will depend on the watch crystal whether you use a DS1307 or AVR.

The battery backup is simpler and easier with a a coin cell and DS1307.
However good you are at sending the AVR to sleep, I doubt you will compete with the DS1307. So you probably need more than a coin cell for backup.

If you never lose power, both solutions are ok.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the accuracy I would use the DS1307, but I could not find anything about accuracy using the AVR, shouldn't it be the same if I'm using the same 32KHz crystal for either?

With regards to battery backup, this is just a hobby project and is only ever going to be used by me, and where I live there is rarely a power outage! Actually I can't recall the last time, I think it is probably less than once a year on average. So I can manage without.

JohanEkdahl: Are those diodes Schottkys? Anyway I think this extra circuitry will probably take up as much space as the DS1307 and 2 pull-up resistors for I2C! :)

- Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunately Atmel didn't include a separate power pin for timer 2; the NXP LPC213x/214x do have a real RTC onboard with separate power pin.

A seperate RTC will be easier on power, always. You don't have to run a MCU core with ten thousands of transistors while a RTC only has a few to increment a few counters.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How much board space do you have for the backup battery? And how long do you want the backup to last? One option would be a supercap. Typical coin-cell supercaps (e.g. taiyo yuden PAS series or panasonic EP series) take about 5mm x 4mm of board space. You will also need to add a charging circuit (maybe a linear regulator + diode). The DS1307 claims a load of 500nA using the backup battery. With around 60mF of capacitance, and a discharge voltage delta of 1V, you can easily get a day or more of backup out of those supercaps.

- S

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay so I have found a pretty small rechargeable battery that I could use... (MS series)
http://www.abcde.de/data/seiko-microbatteries.pdf

But as I read the datasheet the battery should not drop below 2V. Does anyone one know how the DS1307 acts when voltage drops below 2V, which is the minimum for Vbat? Does it turn off or will it try to keep running thus draining and potentially ruining the battery?

I could also use a regular non-rechargeable lithium, but this is going in a pretty small box which will be a pain to disassemble hence my reluctance to use batteries in the first place! (Size and trouble replacing it)

- Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
For the accuracy I would use the DS1307
Accuracy does NOT depend on the chip but the accuracy of the clock used. If you have an accurate clock then even simple shift registers would be accurate.

Something like a DS32KHz driving a DS1307 would be pretty accurate (I have used that combination) but more expensive than a DS3231 with evrything built in.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mnehpets wrote:
How much board space do you have for the backup battery? And how long do you want the backup to last? One option would be a supercap. Typical coin-cell supercaps (e.g. taiyo yuden PAS series or panasonic EP series) take about 5mm x 4mm of board space. You will also need to add a charging circuit (maybe a linear regulator + diode). The DS1307 claims a load of 500nA using the backup battery. With around 60mF of capacitance, and a discharge voltage delta of 1V, you can easily get a day or more of backup out of those supercaps.

- S

My box is 110*65*24mm (4.3"*2.6"*0.9") and the box leaves room for a PCB of approximately 105*60mm and components up to 15mm height on top side or 4mm on bottom side.

But then the LCD takes up a lot of space so I think I can only fit a PCB of 30*60mm! It is going to be double layer though. Maybe I can do something beneath the LCD but it would have to be components with very small height though (or mounted on bottom side which has 4mm room)

Maybe I should look at a super-cap? 24 hours of backup should be plenty and I don't have to worry about too deep discharge with a super cap, and I will never have to change it! 24 hours of backup time should be plenty!

- Brian