I have a new plan for my house christmas lights this year, involving roughly a quarter mile of RGB LEDs. I bought 12 individually-controllable segments and plan to daisy-chain them to outline the entire perimeter of my roofline.
Each segment (i.e., roughly 1/12th of my display) has an individual controller that can make the segment be Red, Green, Blue, or any combination (the R, G, and B values can be set individually). The control is for the entire strand; I do not have a quarter-mile of directly addressible individual LEDs (perhaps that will be a future project).
The controllers come with an IR remote that lets you set the color you want. Of course what I want is to set all 12 strands to the same color at the same time and have them change in unison periodically, so I need a computer controlled IR emitter and some programming.
I’ve already captured the necessary IR codes using an Arduino setup and the excellent IRremote library. I’ve also extended my Arduino Digital I/O Web Server code to accept more types of JSON POST requests to emit IR codes (also via IRremote). So now I have a server on my network that I can POST JSON to and have it emit the proper codes to control these LED strings. Woohoo!
The next problem is I need to drive 12 IR LEDs. I can’t drive them all from one output of the Arduino. I could conceivably simply hook them up to 12 different outputs and just do twelve JSON POST requests every time I want to change the light colors. There might be a way to reduce that to, say, 6 different outputs by daisy chaining two LEDs per Arduino output. There isn’t enough voltage available to drive very many LEDs though and I didn’t want to go down the path of serial/parallel arrangements when I could do something else more complicated and (conceptually) more fun.
So, instead I’m making a separate circuit to drive the LEDs themselves. First I wanted to prototype the circuit concept. I had several 9V adapters laying around, so I planned this circuit based on a 9V supply:
If you work this out the current flow will be about 64mA (smack in the middle of the acceptable range of 20-100) and the 47 Ohm resistor will dissipate 200mW. A small 1/4W resistor will be fine.
This oversimplified circuit is “always on”; the actual plan was then to add a MOSFET to control the circuit, and given the MOSFET input characteristics I could easily drive three MOSFETs from one Arduino output. Problem solved!
So I grabbed a 9V adapter I had laying about; I have many of these from prior dead bits of technology (throw away the gizmo; keep the adapter). Just to be sure I decided to measure the output of the device:
Says 9V but…
Yup, 13.9 volts. I checked several of my other “9V” adapters and found the same thing. The reason for this would fill a whole posting unto itself; here’s one write-up if you are interested in more details: Unregulated power supplies
So, back to the spreadsheet to recalculate. The good news is that now I can easily put 8 IR emitters in series and the new calculations look like this:
- Supply Voltage: 13.9V
- Pullup Resistor: 82Ω
- Calculated current: 52mA (assuming Vf of 1.2V per emitter)
- Power through resistor: 0.225W assuming Vf of 1.2V. A quarter watt resistor will still be ok.
So, time to break out 8 IR emitter LEDs, an 82Ω resistor and do some testing:
Eight LEDs connected in series with an 82Ω resistor.
Hooked this up to the “9V” (13.9V) power supply and…
Well, how can we tell if it works? First thing is no blue smoke came out of anything, so that’s good. Second thing: some digital cameras can see IR (because some don’t do a sufficient job of filtering it out). My phone camera (iPhone 6) can’t see IR, but I had an old Canon Powershot that can. Here’s what it looks like through that camera:
This is pretty cool. To the naked eye you can’t see anything, but with the camera you can see the IR emitters lit up. So, everything is working, no blue smoke is coming out anywhere and nothing smells like it is burning. So far so good.
I went to measure a few parameters just to verify everything. First off, the power supply voltage dropped to 12.6 under this load. That’s not entirely surprising (and probably somewhat related to why it read 13.9 unloaded). In fact it’s actually helpful, as it pretty dramatically reduces the power dissipated in the pullup resistor (because the entire voltage reduction of 1.3V from 13.9 to 12.6 is “seen” entirely by the resistor as the LEDs have a somewhat-fixed voltage drop across them). The new calculations work out like this:
- Supply Voltage: 12.6V
- Pullup Resistor: 82Ω
- Calculated current: 37mA (assuming Vf of 1.2 per emitter)
- Power through resistor: 0.110W
I took my meter and verified that each LED was operating at Vf = 1.2V. This is a little tricky to figure out a priori because it depends on the current flow. At 100mA the data sheet says Vf will be 1.5V; at 20mA the data sheet says Vf will be 1.2V and there is a graph showing you how the values vary at intermediate current levels. The tricky part with all this is that the current flow circularly depends on Vf. Figuring this out from the data sheet is beyond my EE pay grade but I just assumed system would come to a self-imposed equilibrium, which in this case turns out to be 1.2V per emitter and total current flow (calculated) at 37mA.
Indeed, if you really care about the LED brightness you should be using a fixed-current driver circuit that would let you control the exact amount of current; versus the “whatever it turns out to be is good enough for me” method I’m using with this simple passive circuit. In fact you can get things called “LED drivers” that are designed to do exactly that. However, in my application it doesn’t matter. The emitters are happy with anywhere from 20mA to 100mA and I don’t really care how bright they are because they will ultimately be taped up right next to the receiver on the LED strip controller.
Finally, I broke out my analog meter again (because my digital meter won’t do this – WTF?!) and measured the current flow just to be sure I had understood everything correctly:
We’re on the 0-25 scale here so the mid-tick between 0 and 5 is 25mA and each subsequent smaller tick is 5mA. It looks like we’re reading about 34mA (the picture isn’t straight on to the meter alas) which is well within expected variation/tolerance from the calculated value.
Next step will be adding in the MOSFET to control this so the emitters can be blinked by the IRremote code to control the actual LED strings. Stay tuned for a future report.