The battery is a rechargable lithium ion coin cell battery and it is charged from a micro USB connector. The battery life depends on how heavily the pocket watch is used, but if you leave it alone, it is estimated to last several months. There is a low battery indication feature. This pocket watch also feature a buzzer and a vibration motor, which are used for the alarm feature, and the motor causes a short "tick" as each second passes by. The pocket watch is constructed of a PCB, two pieces of laser cut clear acrylic plastic, and a 3D printed casing.
All the files are also available from my Github (there is a single ZIP download option on that page). This will include the microcontroller source code, circuit schematic, PCB layout, laser cutting vector file, and 3D models. Everything is open source, and also ready to be sent out for fabrication.
Step 1: Inspiration and Design
The top three goals are to look good, user friendly, long lasting.
It is very common to see LED pocket watches that do not have all 60 LEDs for the minute "hand", some have only 12. I really want a clear indication of the current minute with no guessing or estimation involved. So I decided to use 60 LEDs.
I want 60 LEDs for the second "hand", and some of the other designs do not feature a second "hand" at all. As the seconds change, it creates motion, which gives the viewer a feeling of confidence and pace. You will feel confident that the watch is working, because you can visually see each second tick away. Plus, it will look prettier.
There are 12 LEDs for the hour "hand", not 60. Although following the behaviour of an analog clock might sound good, it makes it a bit slower to visually interpolate the current hour.
I explicitly chose not to use bicolor or tricolor LEDs. I want three rings because the different radiuses helps me distinguish between the different "hands" faster.
Right now I check the time using my phone, I'm sure a lot of you do too. So I decided I wanted it to have the size that fits comfortably in my hand, just like my phone, and I wanted a single button to activate it, just like my phone.
I wanted this to be something I use daily, it must be durable. Most of the time it will be in my pocket. A casing is required to protect the circuitry from junk inside my pocket. The casing also has a hole, so I can attach it to a chain.
Nobody likes replacing batteries, especially when it is stuck inside a case. So I decided to use a rechargable battery. The easiest battery charging method today is probably by using USB, all you need is a cord and a USB port.
The buzzer and motor feature are basically just fancy additions because I can do it. I'm not limited on cost, and they will physically fit in the design, so why not?
I made one that is black and green because green is the cheapest PCB color and I have a preference for black. The purple edition is because OSH Park makes purple PCBs, I wanted a case to match the color, why not make two and see if I like it.
As I am coming up with my goals, I also have to consider the materials and equipment I have access to. PCB, laser cutting, and 3D printing services can be found online and I am already very familiar with all three of these techniques.
Step 2: Circuit Design
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).
Step 3: PCB Layout
(the above image is an animation, it is a large file hosted on my own server, click on it to see large version)
I started off by picking a diameter I am happy with (like I taked about in my design goals). I used some reference lines, and eventually made a pocket watch dimension outline that I am happy with. I know the PCB services I use does milling for any shape so a round shape is OK. (some fabricators only do rectangles, avoid them)
You might think perfectly arranging 132 LEDs is a pain in the ass, it's not, if you know how to do it. I used a spreadsheet to calculate the coordinates and angle of each LED, and then used the spreadsheet to generate a EAGLE script (it was just a bunch of move and rotate commands, see EAGLE's help file, I also have a screenshot above). I ran the script in EAGLE and it did the arrangement instantly.
The ISP connector has a special "zig-zag" shape. The holes are offset slightly, so when I plug in a standard 3 x 2 ISP header, the holes will make contact with the pins because of the extra friction and tension. This means I don't have to solder in a header, which would look ugly and stick out vertically.
The button and USB connector are the two most abused components so I selected through-hole versions of these. They won't break off the PCB as easily as SMD components.
Unused microcontroller pins are grounded to conserve power, lower noise, disspate heat.
The animation is made by just deleting stuff from the finished design, it doesn't actually represent the huge amount of attention to detail I've put in. Almost all the footprints are custom. I try my best to make things aligned, evently spaced, and symmetrical. A fair bit of time is spent actually typing in calculated coordinates to achieve this. The actual layout will take several days or weeks.
Some components are placed on the back, some on the front. I avoided having too much silk screen on the front, so it won't look ugly.
There's a CAM file I provided. EAGLE's CAM processor can use the rules from the CAM file to generate the Gerber files that you need to send to the PCB fabricator.
Remember to print out your design onto paper and test fit your components first (see picture above).
By the way, some PCB fabricators will place a identifier on your board to help them track it. I suggest you flip your entire design over before sending it to them. This way, they'll actually print the identifier on the back instead of the front. (I've already done this step for you).
Step 4: Laser Cut Front Face
There needs to be two layers since the electrical components take some height. I have two designs for the middle layer, one that is just a empty circle, and one that has a "slot" for each LED. I was not sure which one would look better so I decided to try both. The top layer is very simple, but it has some holes over where the buzzer is to let the sound out.
I usually use Ponoko to do the laser cutting. The plastic shall be 2mm thick clear acrylic (I personally think anything thinner is too weak, and also more expensive at Ponoko).
Ponoko offers templates for Adobe Illustrator, or CorelDRAW, or Inkscape. I actually used SolidWorks to start the design, and then saved the 2D drawing as an Adobe Illustrator file (*.ai file), then copied that file to the Ponoko template. The template has some rules which simply involve setting the right colors and thickness for all the lines.
Actually, I lied, it's more complicated than that. When you save a *.ai file using SolidWorks, the circles in your design become sort of rough. This is because SolidWorks saves your curves as many lines instead of just saying "this is a curve". I had to use Adobe Illustrator to replace all the rough curves with perfectly smooth curves. It makes a huge difference in the end product, I know from experience.
Step 5: 3D Printed Case
The design process is basically make one tall solid shape first, and then cut away areas. The other way is to do it layer by layer from the bottom up.
(below is an animation, it is a large file, let it load, click on it to see the full sized version)
One design challenge is to hold everything together without using screws (screws look ugly, stick out, require holes and threading, yada yada yada). I decided to give my 3D case some locking tabs to hold the acrylic face plate in.
Remember that the PCB is 1.6 mm thick, which is standard. The plastic is 2 mm thick.
But wait! Did you know that if you order 2 mm thick acrylic plastic, it's actually not exactly 2 mm thick? Trust me, mine are around 2.4 mm thick per layer, and they change from batch to batch. It's actually challenging to create perfectly clear and smooth plastic sheets to exact thicknesses. What does this mean? When you design the 3D model, you should already have the plastic sheets so you can measure them, and design using the measured thickness, not the estimated/specified thickness.
Some fillets and chamfers are a good idea because they make corners stronger, and smoother.
I decided to also design the button pieces. This means parts that need to slide around, you don't want friction between the parts, so keep a gap when designing these pieces. Also keep in mind the 3D printer's tolerences, just because the 3D model says you'll have a gap, doesn't mean the actual pieces will, so leave some more room than you need.
Follow Shapeway's instructions on exporting the file. Basically, setup the coordinate system to have the correct vertical axis, and export a *.STL file. You should have the case and both buttons in one assembly before saving, or else Shapeways will charge you for 3 parts instead of 1 part. You can turn up the level of detail, but more detail means bigger file size and more polygons, eventually Shapeway's server will reject your file.
Step 6: Soldering
Buy all the parts you need:
|Qty||Name||Value||Package||Notes||Sch Name||Mfg||Mfg Part #|
time and charging indicator,|
your own colour choice
|6||Resistor||330 ohm||0603||LED current limiting||
R1, R2, R3, R4,|
R5, R7, R9
|1||Resistor||100 kilo ohm||0603||pull-down for MOSFET||R8||Panasonic||ERJ-3GEYJ104V|
|1||Resistor||15 K ohm||0603||sets charging current for U2||R6||Panasonic||ERJ-3GEYJ153V|
|2||Ceramic Capacitor||0.1 uF||0603||MCU decoupling||C1, C2||AVX Corporation||0603YC104KAT2A|
|2||Ceramic Capacitor||25 pF||0603||for XTAL load capacitance||C3, C4||Murata Electronics||GRM1885C1H240JA01D|
|2||Tantalum Capacitor||4.7 uF||1206||
|C5, C6||AVX Corporation||TAJA475K006RNJ|
|1||Crystal||32.768 KHz||2-SMD, 4.90 x 1.80 mm||clock source||Q1||Abracon||ABS10-32.768KHZ-1-T|
|1||Battery Charger IC||MCP73831T||SOT-23-5||charger for battery||U2||Microchip||MCP73831T-2ACI/OT|
|1||Low Voltage Detector||TC54VC2702ECB713||SOT-23-3||low battery detection||U3||Microchip||TC54VC2702ECB713|
|1||Tactile Button||SMD Vertical||5.25 x 5.25 mm||changes setting mode||S2||C&K Components||PTS525SM10SMTR LFS|
|1||Tactile Button||TH Right Angle||6 x 3.5 mm||main button||S1||APEM Components||MJTP1117|
|1||Piezo Buzzer||11 L x 9 W x 1.7 H, mm||alarm buzzer||Q2||CUI Inc||CMT-1102|
|1||Vibration Motor||alarm vibration motor||MOT1||NMB Technologies Corp||KHN4NX1RC|
|1||MOSFET||N Channel||SOT-23-3||drives motor||Q3||ON Semiconductor||NTR4003NT1G|
|1||Diode||SOD-323||flyback diode||D1||Fairchild Semiconductor||BAT54HT1G|
|charging connector||X1||Hirose Electric||ZX62D-B-5P8|
|1||Battery Holder||SMD, 2430||holds battery||BAT1||Keystone Electronics||3006|
|1||Battery||2430, 3mm thick||rechargable battery||http://batteriesdirect.com.au/||PD2430|
I did most of my shopping at Digi-Key. The part numbers are mostly only suggestions, if you know how to substitute correctly and need to, go ahead. However, try sticking to one brand for each type of component to achieve visual perfection.
Avoid using blue LEDs (I will discuss this later)
The tools you need:
- soldering iron, with a fine tip
- solder, 0.5 mm diameter, 63/37 Pb/Sn, rosin flux core
- liquid flux (I have a pen type)
- desoldering braid
- flux cleaner (I have a spray can type)
- flush cutters
- double sided sticky tape (the really thin, paper thin kind)
- other misc stuff I forgot to mention
Do these steps:
- solder microcontroller, solder C1 and C2
- at this point, you may do some testing if you wish, you can do testing after every step
- solder all top-side LEDs
- make sure all solder joints are absolutely perfect
- solder all other top-side components, except the buzzer
- again, make sure everything looks perfect
solder everything on the bottom side, except:
- battery holder
- buttons (trim the leads so they don't stick out, or else the acrylic sheets won't fit)
- tin the battery negative terminal
- clean the entire circuit board using flux cleaner
- solder the battery holder
- solder the buzzer (you might need to trim the leads because I had to shrink the footprint slightly)
- use double sided sticky tape to secure the motor in place
- solder the motor
- again, make sure everything looks perfect
- clean the circuit board again, but this time try not getting any chemicals inside the motor or buzzer
- the LED's orientation is extremely important, and the orientation alternates. The cathod is always the pad with the hole
- wear goggles, some SMD pads are actually vias, which trap air, when the air heats, a bubble of solder might pop right into your eye
- avoid scratching your circuit board, work on a flat but soft surface, like a professional antistatic mat
- this took me 6 hours, there are 132 LEDs to solder... take breaks and work in a ventilated area
- SMD soldering is not hard
There are a lot of pictures in this "step"!
Step 7: Programming
You need a AVR programmer with a standard 3x2 ISP connector (the IDC kind) with 0.1" pin pitch. Plug a 3x2 male header into the IDC connector, and plug the other end of the header into the pocket watch PCB. Watch the orientation (the square pad indicates pin 1, the red wire indicates pin 1, the connector might also have an arrow pointing at pin 1).
If your AVR programmer supplies target power, then do not insert a battery. If your AVR programmer does not supply target power, then insert the battery.
In the downloaded package for this project, there should be a *.hex file that contains the compiled firmware. Use your AVR programmer to write this file to the microcontroller.
You need to configure the fuse bits of the microcontroller. The settings will tell it to use the internal RC oscillator, to enable the clock divider, to disable JTAG. My website provides a calculator for this step. The fuses are:
- LOW Fuse: 0x62
- HIGH Fuse: 0xD1
Warning!The clock rate is/will be set at 1 MHz (because the internal RC oscillator is 8 MHz, and then CLKDIV is enabled so it's divided by 8). Your programmer must support an ISP frequency of 250 KHz in order to work with it. I was using an AVR Dragon, which has this setting in AVR Studio.
If you are using AVRDUDE with a USBtinyISP (which I also tried), you need to include the option "-B 256" to achieve the same effect.
AVRDUDE is missing the configuration file entry for the ATmega165PA, so if you must use AVRDUDE, then edit the "avrdude.conf" file yourself to add a custom entry for the ATmega165PA (mostly copy stuff from ATmega645P, and then change the device signatures). Here is the addition I made into my own "avrdude.conf": http://www.frank-zhao.com/ledpocketwatch/avrdude_conf_entry.txt
Both of these issues were causing problems with my USBtiny (which I would normally recommend), but since I'm using Atmel Studio 6.0 anyways, I decided to use my AVR Dragon programmer. So I avoided both of these issues.
Would you like to learn more?
- AVR Programming Introduction - Hack a Day , there are several parts.
- AVR Tutorial, Step-by-step how to start AVRs - Ladyada
- A Quickstart Tutorial for ATMEL AVR Microcontrollers - I Make Projects
- AVR-GCC Tutorial - Scienceprog.com , a collection of tutorials about using AVRs
- AVR tutorials - AVR Freaks , a collection of tutorials about using AVRs on the AVR Freaks forums
The program logic is fairly simple... Here's a rough flow chart (see above), followed by a text description
The code you've downloaded is written in C, and the project is meant to be opened by Atmel Studio 6, which is also highly recommended by me. Atmel Studio 6 uses AVR GCC as its compiler so even if you are not able to use Atmel Studio 6 (if you were not using Windows), you can still compile the code using AVR GCC.
The hardware RTC timer (timer 2 in asychronous mode) will fire an overflow interrupt for every 256 * 128 ticks of the 32.768 KHz crystal. This means the interrupt will fire every one second. This is used to keep track of time. Remember that interrupts can wake up the processor from sleep mode.
There is a PCINT (pin change interrupt) associated with the buttons. The main program loop always keeps the processor in sleep mode unless the user presses a button to wake it up. It'll stay away until it has finished displaying the LEDs.
The LEDs are lit by driving logic 0 to the pin connected to the desired cathode ring, and driving logic 1 to the pin conencted to the desired anode. This is how LED matrices work, a really fundamental technique. This will only light one LED at a time, but we want to light three at once, so this happens in a loop that cycles through the three LEDs really fast, fast enough such that the viewer doesn't know that the LEDs actually turn off.
There are some nice animations, presentation logic, and user interface logic, as demonstrated in the video.
The buzzer needs to be driven at a constant frequency of 4.1 KHz to produce the loudest output achievable. This is done using two timer interrupts that is configured to fire at 2.05 KHz to toggle the buzzer pin. The same interrupt event is responsible for cycling between the hour, minute, and second "hand" LEDs, so that they get a even duty cycle.
The second "hand" and motor won't work if the battery voltage is too low, this is to conserve power (overdrained lithium ion batteries can become permanently damaged), and to tell the user that the battery is low.
The alarm settings are stored in EEPROM, which means even if the battery dies completely, the settings will be stored. The current time is actually also stored in EEPROM when the watch goes to sleep, but this is because during development I want the time to be "interesting" (not always start from 0) between resets.
Step 8: Final Assembly
Put in the battery!
Then put the PCB in, then the middle layer acrylic, then the face plate acrylic. Use the clips on the case to clip everything.
You are done, it's that simple.
Step 9: Appendix
The battery I used is quite hard to find, which seems odd because I usually pick components that everybody have access to. This is because... SparkFun used to sell these batteries, but they stopped, and replaced them with a thicker version... So now I have to order these batteries from a store in Australia. An alternative is to simply find a really thin battery, solder it in place permanently, and not use the battery holder at all.
Blue LEDs are problematic and not suggested. First of all, they are many times more expensive than the other colours. When I was looking for blue LEDs, I found three that suited my filters, and I built a prototype using the cheapest option. This prototype did not work, because that particular model could not handle reverse bias (other LEDs can handle around 5V, this one didn't even have a specification for it, it just said "don't do it"). One of the other two choices might have worked, but it costed nearly $1 each (remember, I'm building two of these, each one requires 60 of this colour). There is a way to program the microcontroller so that you never reverse bias the LEDs, but the problem is that if you make a mistake, your entire prototype is dead. In the end I decided it's not worth the risk.