Daniel wrote: > I am looking for code (or PIC programming help) for a clock with > calendar and one channel controller. > > I am considering using a DS1307 RTC and 16F84 PIC or similar. It will > be used outdoors, battery powered with no mains reference. The > accuracy needs to be as accurate as possible but no more than 1 2 > minutes per month. If you've already got a PIC in there, why not just connect a 32KHz watch crystal to timer 1? 2min/month is about 45ppm. These crystals are cheap and readily available to 20ppm (< 1min/month). It sounds like this PIC will spend most of its time asleep, so that also provides an easy way for it to wake up periodically. The WWVB signal is a relatively simple way to automatically ensure long term accuracy. Activating the receiver once a day then free running from the watch crystal in between should keep you within 2 seconds at all times assuming a 20ppm crystal. If you want to get really clever, you can use the WWVB signal to compensate for the initial accuracy and long term drift of the crystal. That should keep you to well within a second at all times. > I need to switch at specific times on certain days, plus it needs > compensation / adjustment for daylight saving times. > > I can find plenty of code examples for regular clocks but not with > dates (calendar). > > Does anyone have any guidance for this? I had to write some time/date handling code a bunch of years ago. The Naval Observatory in Washington DC had useful information and publications about issues with time zones, leap years, leap seconds, daylight savings time, etc. You don't need code samples. That's easy once you've got a good spec. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.