EmbeddedRelated.com
Forums

Real Time Clock Code (RTC) for PIC family

Started by tomcee November 17, 2010
On Nov 17, 12:50=A0pm, John Devereux <j...@devereux.me.uk> wrote:
> Jim Stewart <jstew...@jkmicro.com> writes: > > Rob Gaddi wrote: > > >> Way too expensive. Just plug into the mains and learn to count to 60 o=
r
> >> 50 as the case may be. Doing so without electrocution is left as an > >> exercise for the reader. > > > Have you ever successfully done this? =A0I 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?
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.
On 18-Nov-10 2: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
This may give you something to ponder: http://www.dontronics.com/rtc.html Cheers Don... ======================== -- Don McKenzie Site Map: http://www.dontronics.com/sitemap E-Mail Contact Page: http://www.dontronics.com/email Web Camera Page: http://www.dontronics.com/webcam No More Damn Spam: http://www.dontronics.com/spam USB Isolator 1000VDC For Protecting Your PC OR Laptop http://www.dontronics-shop.com/usb-iso-low-full-speed-usb-isolator.html These products will reduce in price by 5% every month: http://www.dontronics-shop.com/minus-5-every-month.html
On 17.11.2010 18:40, Jan Panteltje wrote:

> Using a LCD conflicts with 'low power', as a small LCDs often already used a 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.
Hans-Bernhard Br&#4294967295;ker wrote:
> > On 17.11.2010 18:40, Jan Panteltje wrote: > > > Using a LCD conflicts with 'low power', as a small LCDs often already used a 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.
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!!!
On Nov 17, 7:24=A0pm, "robertwess...@yahoo.com"
<robertwess...@yahoo.com> wrote:
> On Nov 17, 12:50=A0pm, John Devereux <j...@devereux.me.uk> wrote: > > > Jim Stewart <jstew...@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? =A0I 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? > > 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. =A0Each powerplant is a (very) > large AC generator. =A0They 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. =A0Moving power between > grids is trickier, simply because they are not synchronized. =A0High > 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.
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).
Jim Stewart wrote:
> > 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.
True - you need counters, too. ;-) Cheers! Rich
On 17/11/2010 19:41, Hans-Bernhard Br&#4294967295;ker wrote:
> On 17.11.2010 18:40, Jan Panteltje wrote: > >> Using a LCD conflicts with 'low power', as a small LCDs often already >> used a 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.
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.
> > 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.
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
On a sunny day (Wed, 17 Nov 2010 20:41:10 +0100) it happened
=?ISO-8859-1?Q?Hans-Bernhard_Br=F6ker?= <HBBroeker@t-online.de> wrote in
<ic1b4k$kjj$03$1@news.t-online.com>:

>On 17.11.2010 18:40, Jan Panteltje wrote: > >> Using a LCD conflicts with 'low power', as a small LCDs often already used a 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.
I just soldered in a 16 x 2 character LCD (Hitachi controller), and WITHOUT backlight it is almost 2mA. WITH backlight much much more.
On 17.11.2010 21:06, Michael A. Terrell wrote:
> Hans-Bernhard Br&#4294967295;ker wrote:
>> 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.
> Then they can't be 'No power'. Some is used each time you change a > digit.
So what exactly did you think I wrote about a "rather reasonable approximation" for?
Hans-Bernhard Br&#4294967295;ker wrote:
> > On 17.11.2010 21:06, Michael A. Terrell wrote: > > Hans-Bernhard Br&#4294967295;ker wrote: > > >> 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. > > > Then they can't be 'No power'. Some is used each time you change a > > digit. > > So what exactly did you think I wrote about a "rather reasonable > approximation" for?
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!!!