Well... this is a LED pocket watch, not a mechanical pocket watch... so start off with designing the circuit. The problem we are trying to solve is "how to light up 132 LEDs in a way that indicates time?"
I am using CadSoft EAGLE 6.2
to draw the circuit schematic and lay out the PCB design.
Starting off, the simplest way to do this is with a microcontroller of some sort, we'll worry about which one soon.
The challenge lies within the number 132. One option is to select a microcontroller with 132 pins, simple, right? But the microcontroller will be gigantic, and the design will look bad.
The solution is to group the LEDs so I can multiplex them
. My design arranges the LED in a 30 anodes by 5 cathodes (I may refer to these as "rings") "matrix". This means I need 35 pins to drive 132 LEDs.
(click on the LED matrix image above, it is an animation that shows you how my LED matrix works)
I also need 5 resistors (R1, R2, R3, R4, R5) to limit the current to the LEDs, so they operate within their ratings and not burn out. It's important to notice that different color LEDs have different voltage drops and have different maximum safe current specifications, and also the battery voltage will vary over time (exceeding its nominal voltage during and immediately after recharging). I've selected a common 330 ohm resistor for this job. Taking the worst case scenario, which is 0 voltage drop across the LED, and a battery at 4.2V, Ohm's law says the current will be 12.7mA. This is safe for almost all small LEDs and safe for the GPIO of the microcontroller.
I need at least 2 buttons, which means two more pins are required on the microcontroller. It will be ideal if these pins supported some form of interrupt to detect the button presses even during sleep mode. It will also be ideal if these pins featured internal pull-up resistors, so external pull-up resistors are not required.
So my minimum pin requirement right now is 37. I did some searching for a microcontroller that meet this requirement, and decided on an ATmega645P
(or something similar with less memory, memory requirements for this project is actually very small).
It features 54 free pins. Comes in a TQFP package so I can solder it without needing hot air (I can do QFN but I'd rather avoid it, especially for an Instructables project where people's skills vary). It operates down to 1.8V so it's easiy to use with a coin cell battery. It has a hardware RTC which I can use to keep track of time, even in sleep mode. The picoPower version states that it has some insanely low power usage, which helps with battery life. As a bonus, I am a fan of the AVR family.
So knowing the operating voltage of the microcontroller is between 1.8V and 5.5V, I know that I can safely power the circuit using a rechargable lithium ion coin cell battery (nominal voltage is 3.7V, maximum is 4.2V) without using a voltage regulator at all.
The charging circuitry is extremely simple to design, the charger chip is a MCP73831
and the datasheet has example application circuitry, which I've adapted. Unless otherwise stated by the manufacture, it is safe to assume that the battery can be recharged at a rate of 1C, which means 1 multiplied by it's capacity (in AH or mAH). Since my battery has a capcity of 150mAH, I can safely recharge the battery at 150mA. Using the calculations from the datasheet, this means I have to use a 15 kilo ohm resistor to set the charging current.
The hardware RTC (timer 2 in asychronous mode) within the microcontroller requires a 32.768 KHz crystal to keep track of time. The crystal needs loading capcitors
on each pin, or else the crystal will show large frequency instability and the time won't be accurate.
The microcontroller shall operate using its 8 MHz internal RC oscillator (saves space and money by avoiding another crystal), and that frequency will be divided internally by 8 to conserve power.
The microcontroller needs one decoupling capacitor
for every VCC
pin, this is a general rule-of-thumb I've adapted, the purposes is to filter out fine noise from the power bus.
The ATmega645P features internal pull-up resistors (I have previously mentioned that it'll be nice to have these), so the buttons do not require external pull-up resistors.
The AVR microcontroller needs a ISP (in-circuit serial programming) connection so I can program its firmware, this means connecting the reset and SPI bus pins, plus providing a ground and power connection.
The low battery detection is a simple voltage detector (the TC54
, configured for 2.7V) that will drive a pin low when the battery is below 2.7V.
In the end, there was space and free pins left over so I added a buzzer and a vibration motor. The motor is driven by a MOSFET. The MOSFET has a pull-down resistor (R8) on the gate so it doesn't go crazy when the microcontroller isn't controlling it. There is a resistor (R9) to the MOSFET's gate to protect the microcontroller pin from a brief current spike during switching. The diode is there to protect the circuit from back EMF
from the motor (this diode is known as a flyback diode