Hello everyone. I hope you can offer me some advice on my goals:
I would like to make a very simple circuit that would keep track of time with the biggest interval being about 30 days. This circuit would be similar to the Brita pitchers or Timestrips that would
have a custom time interval
take extremely small/no power
be resettable
Ideally it would run off a single coin cell or AA since I have many spare rechargable AA NiMh Eneloops. It would output the "time elapsed" over 8 LEDs, similar to the Macbook battery meters. (http://dl.dropbox.com/u/147939/MacbookBatteryMeter.AVI) I would attach this to my recycling bin or maybe even my clothes hangars to tell how long it has been since I wore them.
Now, why would I want to do this? My main purpose is to practice with "embedded" programming. So far, all I have done is "tethered to the wall" programming. I want to try using an appropriate microcontroller (ATTiny8?) since all I need to do is blink some LEDs and keep track of time, and would like to eventually produce...10-20 or so very small boards with SMD components.
Which microcontroller do I use, where should I order boards so I can panelize them, and where should I start?
Basically you have to sleep the controller as long as possible. A library to do this is narcoleptic Google Code Archive - Long-term storage for Google Code Project Hosting.. However if you really want to learn how to do this you should read through the datasheet and Atmel application notes.
The key is to completely stop anything that is not really needed. Thus:
Stop the ADC, the serial communication, the main oscillator (!!!).
Sleep the processor and make it wakeup from interrupt.
While you are running keep power consumption as low as possible, thus run at low voltage and do NOT use a crystal osciallator. Use the internal 8MHz RC oscillator and divide it by 8 (thus running at 8Mhz). Go back to sleep as fast as possible (thus do NOT divide the clock further).
This leaves the interesting question on how to keep accurate timing. The only reasonable way to keep accurate time at low power is to buy this off the shelf. That is: use a RTC for timekeeping. This in turn will require i2c or twi communication.
Keep in mind that you must have no floating pins and that you must not have LEDs that light up all the time. A LED will draw current in the order of magnitude of 0.1mA to 20mA. A low power design that sleeps most of the time will draw current in the order of some 100nA -10 000nA depending on what exactly you are doing.