Real Time Clock Code (RTC) for PIC family

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

Reply to
tomcee
Loading thread data ...

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:

formatting link

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
Reply to
hamilton

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.

Reply to
Spehro Pefhany

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
Reply to
Rob Gaddi

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.

Reply to
Jim Stewart

On a sunny day (Wed, 17 Nov 2010 07:56:13 -0800 (PST)) it happened tomcee wrote in :

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:

formatting link
Have a look at the code. This one also drives an LCD display, the clock interrupt code is the same as above:
formatting link

Reply to
Jan Panteltje

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.

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

Reply to
Martin Brown

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
Reply to
John Devereux

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.

Reply to
Jim Stewart

real life.

As do app notes from many other companies.

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
 Click to see the full signature
Reply to
Tim Wescott

r

Of course they do, although the reason the power networks are so carefully synchronized has little to do with the power companies=92 interest in the accuracy of your clocks. Each powerplant is a (very) large AC generator. They basically just wire up all the power plants in a single grid in parallel - if the phases were not precisely synchronized it wouldn't work any better than a device in which you inserted some of the batteries upside down. Moving power between grids is trickier, simply because they are not synchronized. High voltage DC is somewhat popular for that task, and people still use motor/generator sets.

Some electromechanical clocks take advantage of the same by using synchronous motors to drive the clock mechanism.

But there is a ton of noise on the mains, which requires some care if you want to get a good 60Hz (or 50Hz) pulse.

Reply to
robertwessel2

This may give you something to ponder:

formatting link

Cheers Don...

========================

--
Don McKenzie

Site Map:            http://www.dontronics.com/sitemap
 Click to see the full signature
Reply to
Don McKenzie

few mA,

You seem to have an entirely different meaning for the term "LCD" in mind than --- well, pretty much everybody else. To a rather reasonable approximation, LCDs consume no power whatsoever. They're just a capacitor that you charge once, and then you top up that charge every once in a long while.

Unless you happen to be in the enormously lucky position of having e-ink displays at your disposal, or don't want to show what your device is doing at all, there's just about no way you'll beat a simple LCD on power consumption.

Reply to
=?ISO-8859-1?Q?Hans-Bernhard_B

or

You can either low pass the mains signal scaled down, or square up the mains signal using a schmitt inverter, and then use a monostable counter set to just lower than the required frequency and ignore any state changes for one counter period. Another option is to scale down the mains and compare the half wave rectifications of the positive and negative by a potential divider and a neutral comparator... BE CAREFUL and maintain any NEEDED isolation.

Or use a highly tuned atomic time signal receiver, or use a known AM carrier signal (can be acurate depending on station).

Reply to
jacko

few mA,

Then they can't be 'No power'. Some is used each time you change a digit.

--
For the last time:  I am not a mad scientist!  I m just a very ticked
off scientist!!!
Reply to
Michael A. Terrell

True - you need counters, too. ;-)

Cheers! Rich

Reply to
Rich Grise

This is incorrect. An LCD will fade out in a couple of seconds if you apply DC and may suffer permanent damage if left DC polarised for a long time. The dark state is when AC is applied to the segment - though a relatively slow AC signal is enough to do it and power consumption for a bare metal 4 digit LCD driver is tiny. But you have to use the right low power driver chipset.

Jan is thinking of the matrix LCD displays commonly used with PICs that have an "intelligent" controller and take commands off a 4 or 8 line bus. They do tend to draw a few mA but are much simpler to control.

A bare LCD is very low current consumption, but you have to generate the waveforms to drive it directly. It only gets hairy when you want to multiplex a displays off the rather finite number of IO pins on a PIC.

Regards, Martin Brown

Reply to
Martin Brown

On a sunny day (Wed, 17 Nov 2010 20:41:10 +0100) it happened =?ISO-8859-1?Q?Hans-Bernhard_Br=F6ker?= wrote in :

few mA,

I just soldered in a 16 x 2 character LCD (Hitachi controller), and WITHOUT backlight it is almost 2mA. WITH backlight much much more.

Reply to
Jan Panteltje

So what exactly did you think I wrote about a "rather reasonable approximation" for?

Reply to
=?ISO-8859-1?Q?Hans-Bernhard_B

Wht do you consider reasonable? I've used equipment that required a

500KW backup gnerator, and things that ran on a single lithium battery for over a decade.
--
For the last time:  I am not a mad scientist!  I m just a very ticked
off scientist!!!
Reply to
Michael A. Terrell

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.