This was originally published on my blog: chris-labs.de
This is the second part of my RGB-Cube series (here's the first) which describes my process of forming an idea to a working prototype. After spending hours of reading and ordering the first parts the project started to take shape and it was time for some serious prototyping. In the last part I described the different ways of controlling 192 LEDs and I decided to go with shift registers (SR). They are easy to control, have a low latency and there are no glitches like when you use Charlieplexing.
After checking out some datasheets I decided to use the 74HC595 which has some nice convenience features:
- Output-Enable: Turn all outputs off at once
- Cascading: Serial output to chain multiple SRs together
- Dedicated Storage Register: Fill the storage with data without impacting the output. Then use the latch to update the output.
Problem: The 74HC959 however has a max. continuous current of only 35mA. One SR should control 8 LEDs which have a total current of 160mA (if they are all on at once). If we don't want to blow the SR we need something that can handle a little bit more current: Darlington Transistor Arrays (DTA). They are available as ICs and allow you to switch a higher current with a lower current. That means we put the DTA with 8 channels after the SR to avoid blowing our SR. The DTA model I chose was ULN2803A.
Problem: Our circuit will be powered with 5V but LEDs don't like that. That's why we need resistors after the DTA. Since I'm a lazy person and I did not want to solder 192 resistors I searched online and found Bourns Resistor Networks. Essentially it's an IC with 8 pins on each side and a resistor in between. If you use IC sockets in your final PCB you get the added advantage of quickly changing resistors to adapt the brightness of your LEDs.
Everything seems settled so now is a good time to print pin-outs of the ICs and grab a breadboard. Once that worked I wanted to create a PCB with one SR, one DTA and 8 LEDs just to make sure and to get some experience in the toner transfer method. After I figured out how to arange the ICs (SR on top, DTA on bottom) I used Eeagle to design the PCB. Use pull up / down resistors where necessary or your results might get very unpredictable. In my case I used a 10k resistor to pull OutputEnable high (disable output) and then set it low with the Arduino once I started to push some values into the SR.
Using some SPI-Code on the Arduino I got the prototype working. Nice! I could have started now and use 24 SRs to control the LEDs but then every LED would have needed three dedicated wires (red-, green-, blue-kathode) and one shared anode. That would be one ugly Cube with a lot of wires. The solution for this problem will be discussed in my next blog post. But before I end this post one more step was needed to get a smooth LED-Cube: Determining the correct resistor for each color in the RGB-LED so that when all light up at once it gives a clean white. Use a breadboard for this and after that do yourself a favor and **test every singe RGB-LED you want to use**. They vary in brightness sometimes, so take a reference LED and test them all. I built a testing rig with three reference LEDs (one for each color) and a button for each of them. Then I attached the LED to test and pressed each button to compare the colors. To better judge the brightness you can put small paper hats ontop of the LEDs, also you won't get blind this way ;)
Take aways of this post:
- Use a darlington transitor array to protect your shift register
- Use bourne resistor networks and IC-sockets to save soldering work and make your resistors exchangable
- Use pull up / down resistors where necessary to avoid erratic behaviour
- Test your LEDs for brightness
- Find the correct resistor for each color so your RGB-LED is truly white