My project goals are to control all of the LEDs individually, including brightness, via a Raspberry Pi. Once working, I'll be using a webcam to automatically map each LED's location in 3d (x,y, & z coords). In essence, it will be similar to a 3d led cube when complete.

It would be nice to have a relatively easy setup which can display 30-60 fps. I know little about micro-controllers, I2c, etc. but I do have a good understanding of electricity, linux, computer programming, and serial connections.

Assumptions:1. LED's are all wired together. No individual control.2. LED's are only white. Think I've seen some trees where the color changes.3. Tree plug directly into 110 volts. Indicating the LEDs are wired in series each with it's own resistor. So they are like Christmas light and do not need a power supply.

You're not going to like this, but I would recommend you practically start over. Get a "blank" tree and some of these LED strings:

You don't need anything as powerful as a RaspberryPi. You can control these using an Atmel based controller like an Arduino. And they can be programmed to display what ever color you wish.

---

I can see you are not moved. Ok, let's see what you have got your self into. You want to control 600 white LEDs. They are probably super bright so can not be powered directly by any processor. Here, let's use these for an example:

These (which may or may not be like yours) run on 3V at about 20mA. Ok, so to light up 600 of these you need a power supply that is 3V at 12 amps. To be safe we might want to double that. So 3V at 24 amps. Or 72 watts. Hum.

It is likely that in any design you use, you will use a resistor in series with the LED. In such a case you can use a higher voltage power supply and drop the difference across the resistor. Like use a 5V supply and drop 2V across the resistor and the other 3V across the LED. If the expected current is .02A then, to drop 2V, you can try using a 100ohm resistor.

Most people are going to use a MOSFET transistor to switch on and off a high current LED. Here is a web page that talks about controlling LEDs for a Stop Sign Costume:

Half way down the page you see a schematic which includes 2 resistors and a FET. He is controlling 9 LEDs that draw about 400mA all together. You want to control each LED individually. So you need to adjust the resistor in series with your LED according to your power supply and the current your LEDs will draw. So, for every LED you have, you need to buy 2 resistors and a FET and wire this all in someplace on the tree. Then you need to bring back 600 wires to the RaspberryPi. Which, BTW, does not have 600 GPIO pins.

That's too much work. What else is there?

Well, there is what you suggested. Using the Maxim IC. A quick look says you should be able to control 18 LEDs? So that puts you at 4 chips. You could place them around the tree and wire back the LEDs to the chips.

Note, this is something very similar to that string of LED in the first link above.

Are there other ways of doing this? Yes, you can try building a matrix and wiring up each of the 600 LEDs to coordinates in that matrix. That way you only need two times the square root of the number of LED worth of switching circuits. It's a bit tricky to design using FETs, but it should be possible. So a matrix of 30 by 20 should give you control over 600 LEDs. Of course you can only light up one LED at a time. Not so different from the way a TV screen is scanned. But you realize to get a frame rate of only 30 FPS you would have to plow through your matrix at a rate of 18000 LEDs a second.

Are there other ways? I can think of a few more bizarre ones. But I think the most sane is to go with the 1st link above.

ST2000: I beg to differ on one point - you can turn on either 20 or 30 LED's at a time with a 20x30 matrix, not just one. The computation time to setup each block of LEDs goes up, but the update rate goes down, while the brightness [duty cycle] increases to either 3.3% [20 LEDs at a time] or 5% [30 LEDs at a time].

The design tradeoff would be power supply size vs # LEDs on at once.

To get the number of pins needed down, I would use several 1/8 decoders [138's] to decode 32 select lines from only 5 output port bits, and use 30 of the decoded outputs to drive P channel MOSFETs to pull the anodes of 20 LEDs to +5, and use 20 N channel MOSFETs [each connected to an output port bit] to pull the cathodes to ground.

BTW: This is more the way an LCD panel is scanned [many rows or columns in parallel], rather than a TV.

Thanks guys! I now realize I should have been more specific and added more info.

To clarify, I only need help controlling the LEDs via the Raspberry Pi. The main reason for using a Pi, instead of something smaller, is so that I can dynamically map each LED's location in 3d via a web cam; i.e. map x & Y for each LED, move camera 90 degrees from center of tree, map again, and then compute z axis. This same technique could be used to create a house-sized matrix in the future. I would also like to control the tree via wi-fi web app or maybe make it interactive with opencv. I know... I'm asking a lot here. Thanks in advance for the help!

I understand that the entire tree will have to be rewired. Currently, it's powered by an AC wall-adapter which outputs 24v @ 1.25a:

The LEDs seem to be cheap and standard. They are single color (white) and only as bright as a standard LED; not like an LED flashlight:

I have not disassembled the tree to see how it's wired and what resisters it's currently using.

The Maxim IC chip seems like it would do the job with 5 of them but I'm not entirely sure how to hook them up. Given that, it seems like wiring each light individually into a Peggy 2 and connecting it the the Pi's GPIO serial or I2C is the way to go here. However, there are no specs on power input or output.

Still, a big project. But if you like tinkering and are good at wiring things up - let's have a go.

I see what k-ww is saying. Instead of just one you could light up a column or row of LEDs at a time. Just which depends on how you wire up your series resistor. Only 1 LED per resistor or your LED's brightness will start to fluctuate according to how many are lit.

So you think your LEDs run at about 3.4V and draw about 20mA. Your power supply is 24V at 1.25A. And you examined the LEDs and believe they are in groups of 100. And each group is being delivered 24V? If they were all in series that would only be .24V across each LED at most. So that's not it. It's probably more like 20 groups in parallel of 5 LEDs in series with, let's see, 150 ohm resistors next to each LED. What ever it is you are going to have to figure out the particulars. You are looking for the particulars so that you can re-use as much of the things you already have as you can. It won't be much fun if you end up replacing all the series resistors because you picked a power supply which had an inconvenient voltage.

So, we are making a lot of assumptions. So please check on them fist.

Iff your LEDs are 3.4V at 20mA with 150 ohm resisters for each LED, that would translate into 3.4V + (.02A * 150) = 4.9 volts. Close enough to 5 volts that you could probably get by with a 5 volt regulated power supply. At this point you should probably measure the voltage across the LEDs and across the LEDs and the resistor. This so we know we are on track and can backwards-engineer / re-purpose this project successfully.

If you go with the matrix you could conveniently light up as many as, say, 30 LEDs at the same time. That's 30 * .02A = .6A. Add the RaspberryPi and what ever else you decide to use. Then double current that to be safe.

If you go with your Maxim chips, it sounds like you could light them all up at one time. Now you need to be very careful as your power supply and your wiring will have to be able to handle the hight currents. 600 * .02A = 12A just from the LEDs.

I'm confused as to how you are rendering a normal raster with a random cluster of lights. I would think the mapping is only created once. Afterwards the processor would only need to determine the brightness at the position of the LED in space and either light it up or not. And I'm not sure I understand the need to map the LEDs from two different vantage points 90 degrees apart. Usually the effect is only good if viewed from the vantage point of the camera used when creating the initial mapping.

-good luck

Last edited by st2000 on February 5th, 2013, 1:00 pm, edited 1 time in total.

I'll start measuring the voltage and figuring out what's going on there. Also, I was planning on writing code to display effects in 3d rather than raster images. 600 pixels is pretty low resolution for the size of the tree so I guess time will tell what works and what doesn't.