View previous topic :: View next topic |
Author |
Message |
Guest
|
RTC using 18F4550 |
Posted: Wed Oct 21, 2009 11:16 am |
|
|
Hello all,
I'm considering rolling my own RTC function using the "secondary" (TIMER 0) oscillator that is built into the 18F4550. According the the datasheet, this oscillator is often used with a 32.768 kHz watch crystal. Seems like a "nearly free" way to implement an RTC without using a dedicated clock chip (DS1307, DS1340, etc). I only need to have a fairly accurate clock/calender with the most basic functions. The challenge might be in the life of the backup battery as the PIC draws somewhere between about 2 and 35 uA while running off the 32 kHz oscillator. This is much higher than that required by a DS1307 for example.
Any thoughts or experiences are greatly appreciated. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed Oct 21, 2009 12:23 pm |
|
|
Consider using the 18FxxJ11 series that have built in RTC's and can do your time keeping function for you with that same 32kHz source.
I'd have to check, but I think the powerdown current is lower too because in the case of the J11's the CPU can shut down while the clock keeps running whereas the 18F4450 cannot.
Just a thought.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 21, 2009 12:47 pm |
|
|
Quote: |
I'm considering rolling my own RTC function using the "secondary"
(TIMER 0) oscillator that is built into the 18F4550. According the the
datasheet, this oscillator is often used with a 32.768 kHz watch crystal. |
Actually it's Timer1 that can do this.
To find threads on this topic, use the forum's search engine to search for
these keywords, and set it to search for all terms:
Quote: |
rtc #int_timer1
x Search for all terms
|
http://www.ccsinfo.com/forum/search.php |
|
|
Guest
|
|
Posted: Wed Oct 21, 2009 1:04 pm |
|
|
Thanks PCM. You're correct - it is Timer 1, not Timer 0. I'm familiar with the basics of an RTC implementation, however have not had any experience with trying to get a PIC (that has the secondary oscillator capability) to run at a low enough current to come close to rivaling a "real" stand-alone RTC chip. In order to do this, the PIC would have to be able to run 24/7 - even during a power loss. My application is not battery-powered which is a plus. I think the question comes down to being able to power the PIC from a coin cell when my board gets powered-down or loses power. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: RTC using 18F4550 |
Posted: Thu Oct 22, 2009 3:07 am |
|
|
Anonymous wrote: | ... the PIC draws somewhere between about 2 and 35 uA while running off the 32 kHz oscillator. This is much higher than that required by a DS1307 for example. | The Maxim datasheet for the DS1307 mentions 200uA standby current. Seems like the PIC is not so bad at all...
Only thing from other threads in this forum is that I understand it is not so easy to actually get the PIC down to a few uA. Things like poor board layout, open input pins, programming mistakes, inefficient power supply, etc. cause the PIC to consume much higher currents. In my low volume designs we considered the costs for getting the software to run correctly much higher than the price for an additional hardware RTC.
In case you consider adding a hardware RTC than have a look at NXP, Seiko and TI for newer RTC designs at lower costs with less power consumption. Some of these chips have the crystal embedded in the same housing for a lower price than the crystal costs when you buy it seperate. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Oct 22, 2009 10:50 am |
|
|
Interesting.
The PIC18FxxJ11 (I was looking) shows a spec of 850nA for running the RTC and another 1uA for timer1's oscillator (needed for running the clock - if I'm reading that right)
That's not bad at all.
And yes, software can make a lot of boo-boo's that up that consumption.
but at least they don't need cut-patch repairs to a PCB. :D
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 22, 2009 11:37 am |
|
|
Actually it says the ds1307 battery backup current is 300 na typical:
Code: |
VBAT Current (OSC ON); 300 typ 500 max na
SQW/OUT OFF
|
Look at the table on the bottom of page 2 in the data sheet:
http://datasheets.maxim-ic.com/en/ds/DS1307.pdf |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Oct 22, 2009 1:12 pm |
|
|
While 500 nA of DS1307 is a max value over the full temperature range, you have to consider worst case values of about 5 uA with "nanoWatt XLP" PIC18FxxJ11. DS1307 easily achieves 5 or 10 years operation with the smallest available coin cell, I'm not aware yet of any processor that can compete in this regard.
As an additional point, a separate RTC allows easy specific battery backup, much more auxilary circuitry is involved with battery supply of the processor. A suitable integrated RTC hardware would preferably provide a dedicated Vbat pin. |
|
|
|