Sunday, December 18, 2011

Individually Addressable and Dimmable Christmas Lights


This project was inspired by a Radio Shack print advertisement or similar article showing how to make a strand of Christmas lights using LEDs and an Ethernet cable connected to an Arduino controller.  I stole the idea and created the rest from scratch.


Christmas LED Shield
I found some large 1cm diameter LEDs that look like jelly beans at a local surplus electronics warehouse, and swapped out a black Ethernet cable that was in use in my house.  Having just completed assembly my Arduino Duemilanove kit, and being the middle of December, assembling Christmas lights seemed like the logical next project.  Originally I was going to place the LEDs 11 inches apart to use up the entire length of Ethernet cable, but my wife talked me into having them closer together, so after making cuts in the outer covering at 11 inches, I made additional cuts halfway between them, now every 5.5 inches. 

Curtain Rod Installation
The point of using an Arduino is addressing the individual LEDs.  As the Ethernet cable has eight wires, that could accommodate seven LEDs (seven lines of power, one common ground), so the original plan was to include seven and the Christmas Light Shield shown does support seven LEDs.  But the Arduino Duemilanove supports exactly six PWM (pulse width modulation) outputs at D11, D10, D9, D6, D5, and D3, so I settled on a six LED strand.  Each light can be individually dimmed to a resolution of 256 values (0=off, 255=bright).  This allows the lights to chase, flash, dim, and perform other light patterns.  Two inputs (in addition to reset) were added to the shield to control the nine patterns of the lights programmed into the Arduino.



The shield was built on a empty prototype PCB, with an attached RJ45 jack and corresponding breakout board.  The lines of the Ethernet jack were wired to the PWM ports using 500K resistors.  The switches were wired to inputs at D2 and D8 with 18K pull down resistors, and those circuits are wired to 5V when the switches are pushed.  The RJ45 jack turned out to be a great way to connect and disconnect the wires.

Merry Christmas!

Friday, December 16, 2011

Learning Surface Mount Soldering by Experience

Soldering together this Duemilanove (Arduino 2009 model) was my third attempt at surface mount soldering (first was FTDI232RL, second was PIC32). 

This was a roller coaster ride as it included a number of successes and failures.  Is it pretty? Not so much, but it works!  In the end it has been a success as the board works and I learned a lot. 
What exactly did I learn?

1. Dab some flux to the solder pads and tin them.  Heat the fluxed solder pad and apply a light coat of solder.  The flux and heat will suck the solder quickly so be careful to use little solder.

2. Use less solder, get the soldering iron hot enough, use a fine solder pitch, and a fine solder iron tip.  This board is a mess because I applied too much solder and many of the solders look horrible probably due to not enough heat.

3. Be careful desoldering.  I tried to clean up some messes with desoldering braid.  I wasn't very careful and tore off some solder pads.  This required three reworked lines.  You can easily see two, and a small one is in the top middle.  Using a continuity test mode of my multimeter and comparing a bare board with the board under test was very useful in isolating problems.

4. Order the right parts.  Double and triple check parts.  I ordered the bare Duemilanove PCB boards from Hong Kong via eBay, ordered most of the parts from Mouser, and some I already had on hand. 

But I ordered the voltage regulators in the wrong package size (8 pin instead of 3 pin), and ordered the corrected part from DigiKey.  But on the second try I had recorded a fuse part number for DigiKey, and ordered it blindly, and it turned out to be the completely wrong part - wrong value and wrong size.  I still don't have the right fuse.  And I never figured out the right diode.  It would probably take three or more orders to get the right parts.  In the end, I shorted the fuse and diode pads with bare wire, determining these are optional in this circuit design.  Also, I didn't realize I was out of USB sockets and had to purchase some locally. 

5. Order the correct quantity of parts.  I had three PCBs, and ordered most parts in quantity of five just to have extras.  For resistors and capacitors I ordered in quantity 100 to get the good price break and have extra stock on hand for future builds.  But the LEDs I bought only 10 and each board uses 4.  After losing one LED, and soldering one to a test board, I was short 4.  On my second parts order I splurged $8 to get another 100 LEDs.

6. I was able to use 20-pin breakaway sockets found at a local surplus warehouse to create the 8-pin and 6-pin sockets.  I had breakway sockets that already had indents per pin (not smooth), but those ones didn't match well with the standard ones.  Reading comments on SparkFun's site I learned that the standard sockets are created from the 20-pin ones even though they look smooth.  The only caveat is you lose one pin when you cut them (I used the cutter on my wire strippers), and if not done correctly you are unlocky and lose one of the pins you wanted to keep.  I was lucky this time.  Part numbers from DigiKey are also listed at SparkFun at the above link if you want them to cut them for you.

7. Reviewing the Arduino Duemilanove Eagle schematics and gerbers were indispensible for identifying parts and performing the assembly.  I was able to export the BOM from Eagle, but had to research most every part.  Also finding a high resolution picture of an assembled unit helped identify where to place the parts.

8. Soldering the FTDI part (FT232RL) was tricky to remember how to do it well.  It is a 0.65" pitch 28-pin device.  That's a lot of pins in a fairly dense package.  In the end, what worked best was dabbing just a tiny bit of solder on the tip of the iron.  Very very tiny dab.  And then applying the hot iron to the end of the fluxed pin.  Do every other pin, to let the hot solder cool before revisiting.  If I tried soldering consecutive pins or didn't have a steady hand, then the pins could short.  There still might be some shorts, but this design doesn't use every single pin, so I got away with a sloppy job again.

9. The Duemilanove can use an Atmel ATMEGA328-PU instead of an ATMEGA328P.  Since I ordered five CPUs, this saved me 68 cents per, or $3.40 total.  The difference internally is some additional low power idle statements yet doesn't appear required for Arduino programming.  To load these CPUs with the bootloader I had to follow some additional steps in addition to the standard tutorial on loading the bootloader.

10. Buying pre-built boards is much cheaper and efficient. It took me a week to build and test this, and multiple orders. Justing buying an existing board would have been much easier and cheaper.  But the experience is priceless.

11. I can do this!  Even with a cheap 30-watt Radio Shack soldering iron and a coil of lead-free solder.  Though I am considering purchasing a much higher quality iron.

12. Next step is to design my own PCB with a combination of through hole and surface mount components to balance physical size, price, and ease of build.  That will be another learning experience!




It works!  Shown with my thermometer board

Friday, December 2, 2011

USB PIC24 and PIC32 SPDIP Arduino

PIC24FJ64GB002 shown
Microchip has just released a SPDIP-28 PIC32.  This chip is pin compatible with the PIC24 which I have been developing for, and my latest toying has been with Arduino style boards, so I was determined to combine the two.

In the last week I have developed a prototype USB Arduino format board using a PIC24 or PIC32 as its CPU.  The Arduino format consists of the standardized 8 and 6 pin headers for I/O and power.  This was accomplished starting with an empty Arduino shield prototype board and building up as a PIC single board computer instead of a shield.  Now standard shields can be attached to this board.

The two CPUs I am targeting to support with this board are PIC24FJ64GB002 and the recently released PIC32MX220F032B.

The power circuit, ICSP (on left), and USB have been tested.  The PIC24 running a CDC (Serial over USB) project is recognized by the host PC.  Next step is to test the FTDI serial connector (on right), and all the analog/digital pins.  Following that is to add a crystal and capacitors to get USB support for the PIC32 (I wonder if I can do that on a shield?). All pins are exposed via the Arduino shield interface, so it is super expandable.  The red LED is for 5V power, and the green LED is for 3V3 power.  The button is the reset switch.  No user I/O are provided, must be accomplished by add ons.

The missing piece is the Arduino development environment support for PIC24 and this low end PIC32 chip.  That's a pretty big missing piece.  For now I can develop using Microchip's MPLAB 8 and MPLAB X.  I am hoping to use the chipKIT Arduino Development Environment for this board soon as it would be nice to program with Arduino sketches and C++. 
PIC32MX220F032B shown
Underbelly