Introduction: 30 Channel LED RGB Ambilight Clone
This instructable is my new approach on an ambilight clone. It all developed from my first try. Here you can find the old instrucable, which is OUT OF DATE and only linked for historic purposes. You will not need anything explained in the old instructable.
Enough about that old one.
At the end of this instruction set you will have a low cost (?) ambilight clone, with as many channels as you like. I will, for instance, show you how to build a 30 channel LED TV light, which adapts to the colors of your screen. If you are impatient, checkout the last step of this tutorial to see the very low quality video.
Hardware you will need:
- LED RGB SMD strip
- Microcontroller (Arduino Duemilanove Clone for example)
- (Two) TLC5940 PWM Unit
- maybe a cooler or a heatsink
- 12V power supply
- a few resistors
- electronic stuff (cables, soldering iron, breadboard, ...)
Software it takes:
- Windows or Linux
- Programming Software for your micro controller
Skills you will need:
- ability to solder
- maybe the skill to think a little bit technically, so you don't ask that many questions here in the comments :-)
This project is perfect for users that didn't have to do anything with electronics yet, but want to make something useful and uncomplicated to get started with.
I promise, this project is realizable for everyone who has got the attendance to follow my instructions step by step. It is really easy and if you only have some electronic skills and this is not your first project, it is even easier and you can modify it as you like.
So let's get started...
First of all, I want to explain the main principle of the completed unit.
1. You connect a computer to your TV and to the ambilight unit via USB.
2. You start the Boblight software
3. You start a movie.
4. Boblight analyzes your screen image and calculates some mean values of specific areas of your screen
5. Boblight sends these color-values via USB to your ambilight unit.
6. The micro controller within that unit takes the received color-values
7. According to the values the micro controller changes the LED strip colors
Steps 4 to 7 will be repeated up to about 50 times / second until you tell Boblight to stop.
Step 1: LED Strips
I will stay in metric scale, because it is much better than this crappy inch, feet and mile thing. You can convert centimeters to inches by dividing by 2.54, but I guess you know that ;-)
Before we can start soldering all the stuff together we have to order it. Let's start with the LED strips responsible for the illumination. We need to control the color of the strip. By adjusting only three colors (Red, Green, Blue) it is possible to create many many colors. Your TV works similar. Google for RGB if you want to know more about that. So we will need LED strips which have got 3 channels. One for color red, one for color green and one for color blue. If you power up the red channel, the strip will glow in red, if you power up the red and the blue channel it will be pink or something (mix of blue and red). By adjusting the voltage of the channels it is possible to create all the colors we need.
There are so many different RGB LED strips out there: 60 LEDs per meter, 30 LEDs per meter, common anode, common cathode, waterproof, length of 3 meter, length of 5 meter, etc.
Common anode or common cathode?
You HAVE to take common anode (all 3 channels share 12V) because of the TLC5940 and that is really important. You could destroy the TLC5940 chip if you try to connect it to 12V.
As long as your TV isn't waterproof and you don't want to use your new ambilight under water, there is no real necessity to buy waterproof LED strips. It may be better because of insulation issues. You will tape the strips onto the back of your TV so make sure, you either buy waterproof strips, or the back of your screen is not conductive, because otherwise you could get in big trouble as soon as the contacts of the strips short curcuit. My screen backside is not conductive, because it is painted, so I decided to save the money and use non-waterproof strips.
60 or 30 LEDs per meter?
Another question is, how many LEDs you want per meter. The TLC5940 chip, which will control the color of the strips, is capable of serving 120mA per channel. I would not exceed that value.
I measured 15 LEDs on one strip. Here are my results: If you power up all three channels completely, the strip takes 240mA and glows completely white. The red channel takes 90mA, green and blue 75mA each. 90mA is close enough to 120mA maximum, and we still have a little buffer of 30mA. So the TLC5940 chip is capable of driving 15 LEDs on one channel without getting too close to the maximum.
Now back to the question what to buy.
If you want to use a strip with 60 LEDs per meter, the maximum length of one strip is 25cm, because than you have exactly 15LEDs. If you decide to buy a strip with 30 LEDs per meter, you can double the length of one strip to half a meter to have 15 LEDs. Shorter strips, of course, are always possible. It's not just a question of current flowing, but of brightness. Maybe your room is often dark and you don't want that many LEDs shining behind your tv. In such a case 30 LEDs per meter would be completely okay and you don't have to pay the extra price for 60 LEDs per meter. To get to the point, I used strips with 60 LEDs per meter, because I ordered them to compare both solutions.
After all of your ordered LED strips arrived, one of the first things you have to do is to cut the LED strips into smaller pieces and solder cables to the ends.
Here is my setup:
I have got a 127cm (50") TV screen.
The outer dimension:
I wanted to have 10 areas all in all so I had to cut the whole long thing (5 meters) into 10 shorter strips. The question was how long shell they be? Just to get an idea, I attached an image so you can see where I taped the strips to the backside of my tv screen after I finished the project. As you can see, one piece has to have the length of 25cm to make sure there is enough light, small distances between two strips and they do not overlap. That corresponds to the results I measured for the maximum current. So at the end I still had 2.5 meters of LED strip left, which was resold on ebay.
As already precalculated each one of these strips takes 240mA on full white light. If you multiply that value by 10 strips, we get 2.4A.That is pretty much in my opinion: About 30 Watt.
I ordered my 12V power supply from Ebay. It can serve up to 5A and only costed 9 euros. Now I have a nice security buffer and the device doesn't overheat.
Soldering cables to the strips
My strips can be cut every 3 LEDs (so 5cm) and there are premade solder joints. Look at the second image I attatched to this step just beside the letters B R G on the strip. Sometimes there is even some solder on it so you don't need to care about that. If not, just take a needle and make a small hole into each of the joints and the solder will hold really good.
Just solder one cable to each channel and one cable for common anode (12V). Every strip has to have four cables. I used old network cable because it was long enough to cut it into pieces and has got 8 cables in it. That is very good because we need 4 cables per channel and I wanted to make pairs to cut down the number of cables behind my tv. The cable also has got a nice coating so I only have one bigger cable instead of 8 individual ones per pair. Now I have got four pairs of strips and two single (bottom). Make sure your chosen cables are long enough so the controller unit doesn't float behind your screen.
You can either leave the other side of the cable as they are and solder them directly to the controller unit or solder some pins to it so the strips are exchangeable, if one gets destroyed. That's up to you.
Step 2: Controller Unit
The controller unit consists of two pieces.
The micro controller, in my case an arduino duemilanove, receives the color values from your computer via USB (serial). The sketch running on the arduino is only a few lines long. It waits for enough data on the serial stream, reads one synchronization byte and than 30 bytes for the channels' color values.
The next step would be to control the colors of the led strips.
That is done with a technique called PWM. For those of you who are interested in the technical details, just search for it on wikipedia. One of the problems is, that the arduino only has 6 PWM channels. That would be enough to control 2 strips (RGB x 2 = 6 channels), which is not much. Another problem is that the PWM pins of the arduino are not capable of serving the 'high' currencies we need. So we will expand the number of PWM pins to as many as we want (almost) by adding some TLC5940 chips. Each one of these chips will add 16 PWM pins to your arduino, by giving up a few of the 6 you already have. But that's no problem, because the new pins are better. They have a higher resolution and can serve higher currencies, which is more than a fair deal.
As I already explained, I have got 10 LED strips. Each one of these strips has got 3 channels. So all in all I have to control 30 PWM channels. Therefor I used two TLC5940 which give me 32 (16x2) PWM pins.
There is one really good thing about the chip. There are already prewritten libraries for arduino and after some experiments and wrong soldering I found out how to connect the chips to the arduino.
Actually there are a few suggestions on how to connect the chip, but the one I attached to this image works perfectly together with the library you can download a few steps later.
Connecting the TLC5940
You can operate many of these chips in series. For example, if you want 96 channels, you have to connect 6 of the chips in series. In my case, as already said, two chips are enough. Look at the pictures how I connected all electronics. The hardware setup is based on this project page.
One side of the TLC5940 chip is connected to the micro controller and to ground or 5V. The other side consists of 14 output channels. There are two more output pins on the other side of the chip. The most outer pins are output pins 0 and 16. We only need 15 channels per chip so pin 0 will not be used.
Pin 20 of both TLC5940 chips are connected to ground with resistors with a resistance of 390 ohms. That pin is to limit the current flowing through each channel. It's just a reference pin, but pretty useful. According to the datasheet there is one equation to calculate the resistor's value:
I = 1.24 * (31.5/R)
By choosing R = 390 ohm we get
1.24 * (31.5/390) = 0.100153846
Exactly 100mA and that is okay, because the red channel only takes 90mA on full power, green and blue even less. But if we mess up something, the chip doesn't get destroyed because of high currencies.
Step 3: Heatsink, Enclosure, Cooler
Of course I tested the setup on a prototyping breadboard before soldering everything together and made some tests. I wanted to know if the chip can take full white light on all 15 channels for a longer time. So I illuminated my room with 5 LED strips fully on for a few minutes and measured the temperature with my IR-thermometer and with one of my best tools, my hands. It was a little bit hot but didn't get any hotter after one minute or so.
I decided to add a heatsink to the unit. Because I didn't have any dedicated heatsink for such chips, I just cut one of my old broken XBOX 360 heatsinks into two pieces. After that it was still a little bit oversized, but ok. I added some heat transfer paste to the chip and screw the heatsink tightly on top. Do not forget the paste if you want to use a heatsink, because if you do so, the solution is useless.
Because all of the devices are sensitive I put all of them into an enclosure and fixed them with hot glue. Because the enclosure was too tight for the big heatsink I removed it.
Instead of the heatsink I wanted to add something else because inside of the closed plastic casing everything would get even hotter. I had a small 12V cooler laying around at home and connected it to 12V directly. The fan was way too fast and too loud to be on all the time I use my system. So I connected it to 3.3V of the arduino and that works very good. It is really quiet and after I added some holes to the case the air can flow through it.
Step 4: Software
Download the zip-file attached to this step. It consists of boblight for windows users, a boblight config file to use with my setup, the sketch for the arduino and a library necessary to run the sketch correctly. Linux users, like me, will be able to find the software by themselfs, I assume.
You have to get my sketch on your micro controller. Therefor go to the arduino download page and download the current version of their software.
From my zip file take the TLC5940 library and copy it to YOUR_ARDUINO_FOLDER/libraries to make it available to the arduino IDE. The library is taken from the official homepage of the library.
Take the ambilight.pde sketch and upload it to your micro controller.
The first byte sent from the computer and received by the arduino is always 0xFF to synchronize. Bytes 2-4 are the values to set channels 1-3. And so on. After 16 bytes have been sent, the first TLC5940 has set all of the 15 RGB values for the first 5 LED strips. So the next 15 bytes are meant for the second chip, channels 1-15, to set the other half of the strips.
Channel 0 of both chips are not connected because they are needless (I said that before).
Boblight is by far the best solution to get fast readings from your screen and configurate how to deal with it.
Change the file boblight.conf just as you need it. Open it with any text editor and see how it is designed. Change the values to your needs.
Maybe I can help you a little bit. Look at these lines from the file:
color red uCon 17
color green uCon 18
color blue uCon 16
hscan 50 75
vscan 0 20
What they mean:
The light has got the name upper_right_left. That's one specific strip. It is the second from the right on the top of the tv screen as the name says. It's the left one of the two right on top of the screen. A little bit complicated, but I think you get it.
color red uCon 17
This line says, that the byte for the red color is sent as byte number 17. That means it will set channel 1 of the second TLC5940. The sync byte (in boblight.conf it's called PREFIX) is not counted in boblight.
color green uCon 18
color blue uCon 16
Just the same for the green and the blue values.
hscan 50 75
vscan 0 20
This says what area of the screen belongs to the strip. It's from 50% to 75% horizontally. So just from the half of the screen to 3/4 from left to right. The second line tells us, that only the upper 20% (from 0 to 20) will be analyzed. And, as already said, it is the second from the right on top of the screen.
All of the other strips are specified similarly.
To run boblight, first start the daemon (boblightd) and then the screen-analyzer (boblight-getpixel on windows or boblight-X11 on linux).
I hate to say that, but Windows Vista and Windows 7 users have to disable their aero theme while using the system because one function boblight uses (getPixel()) is not supported in combination with aerothemes. Deactivate the theme by right clicking on your Desktop. Then choose 'Personalize' and click on 'Windows 7 Basic'.
Redo that after your movie has finished.
Change the source code
For those of you who want to take more or less TLC5940 chips, do not forget to change the number of your chips in tlc_config.h in the TLC library and change the source code of the sketch and the boblight config file, of course. The preconfigured number of TLCs in the library I attached is two, because I changed it.
Step 5: Prices
In the old instructable a lot of questions have been asked about the prices of the components I used. For this new update I ordered EVERY single thing from ebay. All the prices include shipping.
The Power Supply, as I said, costs 9 euros.
Five meters RGB LED strip with 60 LEDs/m were sold for 30 euros. I resold two meters for 12 euros because I only needed 2.5 meters for my setup. So I only payed 18 euros. You can save some money by using LED strips with only 30 LEDs per meter.
Both TLC5940 chips together costed 3.50 euros.
The Arduino Duemilanove I bought is just a clone, but it's completely okay and it works perfectly. It was 15 euros from Hong Kong.
I already owned all of the other things I needed, but I assume they do not cost more than 10 euros.
All together the price is 55.50 euros.
The two images I attached shell give you an idea of the resolution the system can offer. All 10 lights have slightly different colors. With my incredible painting skills I also added a few stripes to show you how I taped them to my tv.
Also notice the last picture showing the strips in reality taped to the back. Quick and dirty :-)
Here's a video of the system running. Due to my smartphone lense and the overall qualaty of the video it doesn't look as impressive as it really is.