Wednesday, September 5, 2012

Complete Precision

Project Precision has reached its successful conclusion. I now have a physical hardware clock with an hour, minute, second, and third hand, and enough accuracy to justify needing a third hand.

As I have mentioned before, I noticed that an Arduino Nano has precisely the pinouts necessary to drive a charlieplex with 240 lights. The interesting thing is how few leftover resources there are. There are two analog inputs that are useless in this design. Every single other pin is used. I even considered giving up the crystal inputs to get two more digital pins.I had to include a digital multiplexer since the ATMega only has one serial port, and it needs to listen to both the USB port and the GPS.

As I said before, I will not make one for you for less than $300. The parts alone cost almost that much. However, I am going to publish everything you need to make one yourself. This is the Digikey part list:  Quantity Digikey Part Number Part Value Case Placement Price per Min quantity Ext Price 2 445-7483-1-ND Capacitor 4.7uF Ceramic 0603 C010 C418$0.24000 1 $0.48 2 478-6025-1-ND Capacitor 18pF 2% NP0 Ceramic 0603 C407 C408$0.40000 1 $0.80 2 445-1316-1-ND Capacitor 100nF Ceramic 0603 C420 C502$0.10000 1 $0.20 61 754-1359-1-ND LED Red 320mcd LED 0603 D000-D059 D502$0.14040 1 $8.56 60 754-1124-1-ND LED Yellow 150mcd LED 0603 D100-D159$0.11160 1 $6.70 60 350-2036-1-ND LED Green 300mcd LED 0603 D200-D259$0.51840 1 $31.10 61 350-2037-1-ND LED Blue 140mcd LED 0603 D300-D359 D501$0.48960 1 $29.87 4 CRA4S847CT-ND Resistor Pack 47 CRA04 R1 R2 R3 R4$0.04300 10 $0.43 2 P680GCT-ND Resistor 680 SMD 0603 R501 R502$0.10000 1 $0.20 1 CRA4S810KCT-ND Resistor Pack 10k CRA04 R606$0.04300 10 $0.43 1 SW1021CT-ND Switch SPST B3U-1100P S429$1.03000 1 $1.03 1 ATMEGA328P-15AZCT-ND Microcontroller ATMEGA328P 32-TQFP U401$6.45000 1 $6.45 1 768-1007-1-ND USB interface FT232RL 28-SSOP U501$4.50000 1 $4.50 1 NC7SZ157P6XCT-ND Multiplexer Noninv 2 input SC-70-6 U602$0.41000 1 $0.41 1 887-1319-1-ND Crystal 16MHz 7M Y401$1.69000 1 $1.69 Lights$76.23 Rest $16.62 Total$92.85
This costs on the order of \$100, but the vast majority of the cost is in the 242 lights (240 for the hands, 2 for the TX/RX indicator). I get the above prices today from Digikey with no tax or shipping added on.You can get cheaper lights if you are satisfied with not using green or blue.

You will also need some connectors for the boards:
Sparkfun Female Header Pack - a set of two 6-pin and two 8-pin sockets. You will need this complete set, plus another 6- or 8-pin that will be cut down to 4 pins. You might as well get two of these sets, since they are cheap
Two Arduino 6-pin stackable headers
A strip of male straight headers and male right-angle headers. You need 32 pins' worth of straight headers and 4 of right-angle headers.
A long USB-A plug to USB-Anything cord. You are going to cut the cord off as far from the A end as possible.You will also need a way to connect this to the 4-pin right angle connector. I used a 5x2 ribbon connector (yes, 5, even though only 4 are needed. It's what I had on my bench at the time.).

While we are going through the Sparkfun shopping list, I recommend getting the UP-501 GPS receiver. In principle, any GPS receiver can work, and you can even set the clock over USB and have it run free without any GPS at all, but then you don't get sufficient precision to justify the third hand. The socket on the circuit board is designed for this UP501, and it fits nicely on the back of the board in between the four screws. If you use another GPS, you will need to make a connector for it. Get one that runs at 3.3V (or has a voltage adaptor) and one that has a PPS signal.

Finally, you need the light pipe parts. Ponoko does great work, but it is quite a bit more expensive than just the bare plastic sheets cost. The light pipes as I designed them are exceptionally fragile, and I forgot to put tabs on the light pipes to connect them directly to the four screws. If I were to make another clock, I would fix the latter flaw. As it is, the light pipes have holes for each LED, and these are used to hold the hands in place.

The firmware is plain ordinary Arduino code. There are two separate sketches, one to test each light in a controlled condition, and one to actually be a clock. The Charlieplex driver is put into a library so that the test code tests the same code that the clock code uses.