EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Real Time Clock Code (RTC) for PIC family

Started by tomcee November 17, 2010
Hello:

What is the latest RTC code anyone could recommend for the PIC (16f)
family?

My requirements are simplicity and low power, with LCD display and
perhaps RS232 interface.

Is the Microchip AN582 as good as it gets?

Thanks,
TomC
On 11/17/2010 8:56 AM, tomcee wrote:
> Hello: > > What is the latest RTC code anyone could recommend for the PIC (16f) > family? > > My requirements are simplicity and low power, with LCD display and > perhaps RS232 interface. > > Is the Microchip AN582 as good as it gets? > > Thanks, > TomC
The problem with this type of RTC is drift. As the temp changes the clock may run fast or slow. Even chips like the DS1307 can run fast: http://www.sparkfun.com/products/99 Clean power and low temp drive will help, but .... As far as "as good as it gets" tells me you want something for nothing. Well, you get what you pay for. :-/ h
On Wed, 17 Nov 2010 09:25:37 -0700, hamilton <hamilton@nothere.com>
wrote:

>On 11/17/2010 8:56 AM, tomcee wrote: >> Hello: >> >> What is the latest RTC code anyone could recommend for the PIC (16f) >> family? >> >> My requirements are simplicity and low power, with LCD display and >> perhaps RS232 interface. >> >> Is the Microchip AN582 as good as it gets? >> >> Thanks, >> TomC >The problem with this type of RTC is drift. > >As the temp changes the clock may run fast or slow. > >Even chips like the DS1307 can run fast: http://www.sparkfun.com/products/99 > >Clean power and low temp drive will help, but .... > >As far as "as good as it gets" tells me you want something for nothing. > >Well, you get what you pay for. :-/ > >h
I guess if you have double-digit watts, space and money to spare, you can use a rubidium reference and get pretty decent drift over temperature & time. Or, cheaper, and lower power, use GPS (or GLONASS or Galileo or Baidu etc. when/where possible), but the signal may not always be available.
On 11/17/2010 9:05 AM, Spehro Pefhany wrote:
> On Wed, 17 Nov 2010 09:25:37 -0700, hamilton<hamilton@nothere.com> > wrote: > >> On 11/17/2010 8:56 AM, tomcee wrote: >>> Hello: >>> >>> What is the latest RTC code anyone could recommend for the PIC (16f) >>> family? >>> >>> My requirements are simplicity and low power, with LCD display and >>> perhaps RS232 interface. >>> >>> Is the Microchip AN582 as good as it gets? >>> >>> Thanks, >>> TomC >> The problem with this type of RTC is drift. >> >> As the temp changes the clock may run fast or slow. >> >> Even chips like the DS1307 can run fast: http://www.sparkfun.com/products/99 >> >> Clean power and low temp drive will help, but .... >> >> As far as "as good as it gets" tells me you want something for nothing. >> >> Well, you get what you pay for. :-/ >> >> h > > I guess if you have double-digit watts, space and money to spare, you > can use a rubidium reference and get pretty decent drift over > temperature& time. Or, cheaper, and lower power, use GPS (or GLONASS > or Galileo or Baidu etc. when/where possible), but the signal may not > always be available. >
Way too expensive. Just plug into the mains and learn to count to 60 or 50 as the case may be. Doing so without electrocution is left as an exercise for the reader. -- Rob Gaddi, Highland Technology Email address is currently out of order
Rob Gaddi wrote:

> Way too expensive. Just plug into the mains and learn to count to 60 or > 50 as the case may be. Doing so without electrocution is left as an > exercise for the reader.
Have you ever successfully done this? I ask because I've never seen an implementation that was more accurate than a $2 crystal and clock chip.
On a sunny day (Wed, 17 Nov 2010 07:56:13 -0800 (PST)) it happened tomcee
<tomcees_pc@yahoo.com> wrote in
<e83dfb22-5c13-4ab0-8aa8-cc5915cfca55@o14g2000yqe.googlegroups.com>:

>Hello: > >What is the latest RTC code anyone could recommend for the PIC (16f) >family? > >My requirements are simplicity and low power, with LCD display and >perhaps RS232 interface. > >Is the Microchip AN582 as good as it gets? > >Thanks, >TomC
First Microchip application notes often contain errors, to the point where example code is simply wrong and obviously never tested in real life. Using a LCD conflicts with 'low power', as a small LCDs often already used a few mA, and much more if backlight is used.RS232 also conflict will ow power, if you want to use a MAX232 or something, but RS232 could be powered from the serial port control lines with the right software on the PC side. If you want the clock to keep anywhere near correct time over longer periods you will need a crystal oscillator, and some calibration feature. You can also get withing a few seconds per day using the internal oscillator and software calibration, say via RS232, if the temperature stays constant (say indoors). That is what I do here for example: http://panteltje.com/panteltje/pic/col_pic/ Have a look at the code. This one also drives an LCD display, the clock interrupt code is the same as above: http://panteltje.com/panteltje/pic/swr_pic/
On 17/11/2010 15:56, tomcee wrote:
> Hello: > > What is the latest RTC code anyone could recommend for the PIC (16f) > family? > > My requirements are simplicity and low power, with LCD display and > perhaps RS232 interface.
The venerable 16F877 has just about enough legs to direct drive a 4 digit LCD and will draw about 15uA doing it off 3v. Hardware is the PIC and a watch crystal. I did this once because I wanted a low power sidereal rate clock and the price for a custom crystal was outrageous. Hard to get a simpler hardware solution than making the PIC do it.
> Is the Microchip AN582 as good as it gets?
Remember to load the crystal correctly and trim it and the result is likely to be OK. Miss out the trimmer and you can easily end up with something that drifts 15s/month or so. Some older amateur telescope drives have this problem and the makers fixed it by adding a GPS feature! Regards, Martin Brown
Jim Stewart <jstewart@jkmicro.com> writes:

> Rob Gaddi wrote: > >> Way too expensive. Just plug into the mains and learn to count to 60 or >> 50 as the case may be. Doing so without electrocution is left as an >> exercise for the reader. > > Have you ever successfully done this? I ask > because I've never seen an implementation that > was more accurate than a $2 crystal and clock > chip.
Don't 90% of the worlds digital alarm clocks work like this? I thought "they" precisely controlled the long term cumulative frequency error of the mains for this very reason? -- John Devereux
John Devereux wrote:
> Jim Stewart<jstewart@jkmicro.com> writes: > >> Rob Gaddi wrote: >> >>> Way too expensive. Just plug into the mains and learn to count to 60 or >>> 50 as the case may be. Doing so without electrocution is left as an >>> exercise for the reader. >> >> Have you ever successfully done this? I ask >> because I've never seen an implementation that >> was more accurate than a $2 crystal and clock >> chip. > > Don't 90% of the worlds digital alarm clocks work like this? I thought > "they" precisely controlled the long term cumulative frequency error of > the mains for this very reason?
I don't know how 90% of the world's digital alarm clocks work. I just know that I've seen several 60hz-derived clocks over the years and they all suffered from erratically gaining time from noise on the line. I'm sure that a reliable mains-frequency clock can be designed. I'm also pretty sure that you can't do it with a comparator and a few resistors.
On 11/17/2010 09:40 AM, Jan Panteltje wrote:
> On a sunny day (Wed, 17 Nov 2010 07:56:13 -0800 (PST)) it happened tomcee > <tomcees_pc@yahoo.com> wrote in > <e83dfb22-5c13-4ab0-8aa8-cc5915cfca55@o14g2000yqe.googlegroups.com>: > >> Hello: >> >> What is the latest RTC code anyone could recommend for the PIC (16f) >> family? >> >> My requirements are simplicity and low power, with LCD display and >> perhaps RS232 interface. >> >> Is the Microchip AN582 as good as it gets? >> >> Thanks, >> TomC > > First Microchip application notes often contain errors, > to the point where example code is simply wrong and obviously never tested in real life.
As do app notes from many other companies.
> Using a LCD conflicts with 'low power', as a small LCDs often already used a few mA,
A module perhaps, but just an LCD display, properly driven, is exceedingly low power -- or haven't you noticed what digital watches use, and how long their batteries last? -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

The 2024 Embedded Online Conference