Traditionally I have always used a \$1\:\mathrm{k\Omega}\$ resistor as a current limiting resistor for driving an LED direct from a TTL (or 5V CMOS) output. I can't remember how I came by this value - it is lost in the annals of history.
Is this OK, or a Bad Habit™ I have got myself into that I should break?
Should I be calculating a more precise resistance to use from the voltage and current draw of the LED I am using?
Answer
It's a Bad Habit, just like thoughtlessly using a 1k\$\Omega\$ base resistor for a switching transistor, or as thoughtlessly using a 100nF decoupling capacitor. Millions of engineers get away with it.
Even without much calculation we can see that 1k\$\Omega\$ is a bad choice. From a +5V supply it won't allow more than 5mA, and that's even without taking the LED's voltage drop into account.
Everything depends on the LED, specifically the color, which determines the forward voltage. Also, what current does it need? An often used value is 20mA, because above that the brightness won't increase so much anymore. Let's take that value, and a forward voltage of 2V.
I also presume that by TTL you mean Low-Power Schottky, the original TTL is really obsolete. OK, we take the datasheet for a typical LS-TTL part. The TI datasheets are interesting, because they give you a complete schematic of a gate. We're mainly interested in the output stage. First thing you see is that the totem-pole output (as it's called) is asymmetric: the transistor to \$V_{CC}\$ has a resistor in series with the collector, which the lower transistor doesn't have. This is typical of (LS-)TTL, and means that it will sink more current than it will source. How much? That we find on page 5.
High-level output current: -0.4mA,
Low-level output current: 8mA.
The 0.4mA is much too low to drive a LED, but also the 8mA is a bit low. Standard totem-pole LS-TTL is not fit for driving LEDs.
The good news is that there are other output configurations. The 74LS06 has an open-collector output, which means it can only sink current. The datasheet says
Low-level output current: 40mA.
Great, that's what we want.
So now we have a device which can drive our LED, we calculate the resistor. There's one more thing we need from the datasheet, that's \$V_{OL}\$, the output voltage when low. Datasheet doesn't say for 20mA, so we interpolate a bit and say 0.5V. Then
\$R = \dfrac{5V - 2V - 0.5V}{20 mA} = 125\Omega\$
Take the closest E12 value, that's 120\$\Omega\$. A value of 1k\$\Omega\$ was probably alright for the TTL port, but didn't result in optimal LED brightness.
edit
Kevin added CMOS to the question. HCMOS is the most used series here. Unlike TTL CMOS outputs are symmetrical, and they can sink current as well as source. The 74HC00 can both source and sink 25mA, so we can use it to drive our typical indicator LED.
No comments:
Post a Comment