Thursday, August 2, 2012

Some Math, or Way Too Much Text

Okay, so I'm out of tech and need to start back in on this subject. I need to buy another Arduino because mine is buried in the set, but I can still write about some details that are important.

Let's say you've got a mess of LEDs and a request to make some things light up. You don't need any fancy effects, just static light in some practicals or mounted somewhere on your set. It's not as straightforward as connecting the LEDs to a battery or wall wart and calling it done. An LED is not a resistive load, like a light bulb. The current through an LED is determined by the resistive elements of the circuit, while the voltage drop across its terminals is constant (Anywhere from 1.7V up to 3.5V are common values, depending on the color and brightness of the LED). What this means is that wherever you're using an LED, you'll probably use what is known as a current limiting resistor. This resistor is how you select the current flowing through your LED.

You're likely at least passingly familiar with Ohm's law, that is: V = IR. This is probably the most basic electrical relationship, and one every electrician should know about. Voltage equals Current times Resistance. There's a load of resources out there on the web that will tell you more than you ever wanted to know, so I'll speak specifically to how we want to manipulate this equation to calculate the value of our current limiting resistors.

So you've got a boatload of these diffused LEDs, like the ones I used in the buildings for As You Like It last year. If you scroll down that page, you'll see the specifications, and these are important. The big numbers to be aware of are the Forward Voltage and Continuous Forward Current. The forward voltage is the value required to make the LED light up (yes, it will probably glow at a lower level, but the color will be wonky and it will be very dim) and the forward current is how much current the LED is capable of handling before bad things happen. You can vary the current to vary the brightness (there are several techniques to accomplish this, and we'll talk about it), but you'll always need to provide these particular LEDs with 3.4V.

So say you're building a little glowing hand-prop. You already have rechargeable AA batteries on hand, and some 4 cell battery holders, so that's how you'd like to power the LED going into this prop. You want it as bright as possible, so you'd like to calculate the value of current limiting resistor that will provide you the 350mA of current we're looking for. It's simple. Our 4 AA batteries, in series, will provide us 4.8V (many rechargeable types provide only 1.2 volts per battery, rather than 1.5). We subtract the forward voltage of the LED, 3.4V and we have 1.4V 'left over.' Plug that into Ohm's law, along with our forward current of 350mA (For the record, the equation is in Volts, Amps, and Ohms, meaning we'll plug in 0.35 for our current), then divide to isolate R, giving us a value of 4.

This is a good place to mention that resistors come in sort of goofy values(wonder why?), so instead of our ideal 4 ohm resistor, we'll find either a 3.9 or 4.3 value. Typically err on the side of more resistance.

So now we've got our LED, our batteries, and a resistor value. Next we should determine what power rating we need for the resistor. If you push too much current through a resistor, it'll get quite hot (that's exactly how your toaster or electric oven works), so we want to be sure we have some headroom. Power can be calculated with one of two easy equations, either P = VI [power equals voltage times current] or P = I^2 * R [power equals current squared times resistance]. Using either of these, we discover that the power dissipated in our resistor is 0.49W. Resistors commonly come in 1/8, 1/4, 1/2 and 1 watt packages, so we could probably go with a 1/2W unit and be okay. Typically I will increase the resistance value, lowering the current below the maximum continuous forward current, this allows me more headroom with my resistors, reduces heat output of the LEDs (which is not completely negligible with these higher-powered units, and becomes something to account for with very high power units) and probably makes them last longer (though that's hardly a concern.)

There also exist numerous web-based calculators for finding these values, only a google search away. They'll often even spit out the 'real' resistor value and power rating. That's no fun, though.

The last thing you need to know is that an LED could be hooked up two ways, but will only function in one orientation. Don't worry, if you hook it up backwards, you won't hurt anything, it just won't light up, turn it around and try again. The two legs of the LED are commonly referred to as the anode and the cathode, the former being the 'positive' side and the latter being the 'negative.' The two legs will be different lengths, the longer one is the anode. You can also identify which is which visually (and you'll find yourself doing this at some point, no question), as I've indicated in the following photos. I've drawn an arrow pointing at the cathode, in each case.



What this means is that you'll connect the positive terminal of your battery or battery pack to the anode, and the negative terminal the cathode, with the resistor somewhere in between, it doesn't matter whether it goes before or after the LED, as long as it's in series. 

Your LED should be lit up, and once you add some sort of switching mechanism (just interrupt one of the wires going to the battery pack with the switch) your static LED should be stage-ready. If you find that it's too bright, you can increase the value of your resistor (and conversely, to make it brighter, reduce the value, but be aware that if you try to run more current than the continuous value in the specifications of the LED, you will probably significantly shorten the life of the LED, and possibly destroy it outright.) 

I hope this is helpful to some of you, look for more on the topic soonish.