Again, I realize this is old, but thought an electrical engineer's knowledge might be helpful here. (For others reading this post, looking for backlight control).
The specific arrangment of the transistor in this circuit is of a voltage amplifier, which if driven into saturation (in other words, given a sufficient current from base to emitter), will act as a switch. Used in this manner, the current through the backlight will be I=V/R. In this case, the voltage is that across the resistor, which is the supply voltage (5V) minus the voltage drop across the transistor (about 0.3V when fully on) and the LED backlight (about 2V; should be listed in the datasheet). As well, the required (full-brightness) current should be listed in the datasheet. Using this, the value of the top resistor should be:
Code: Select all
V_supply - (V_transistor - V_LED)
R = ---------------------------------------
I_LED
I will provide an example of this using my 2x40 LED backlit LCD. According to the datasheet, (
TM402CBC from Tianma), the forward voltage drop appears to be 4.2V (since that's the rated voltage of the anode on the datasheet), and the current is max 410mA. We'll plan to drive it at 400mA, which leaves little headroom, but this isn't much of a concern (overdriving an LED will shorten its life, but it takes a lot to burn it out). Given our information so far, this is our resistance:
Code: Select all
R = V/I = [ 5V - (4.2V + 0.3V) ] / 400mA = 0.5V / 400mA = 1.25 ohms
This is quite a small resistance, but is important none the less. If we were to drive it without a resistance, it could technically draw an infinite current (although the actual current would be limited by the amplification of the transistor, given by h_FE, and the base current).
Given this, let's find out how much base current is required to ensure that the transistor is on. In saturation (switch action), the base-emitter current (Ib) times the DC gain (h_FE) should be significantly larger than the collector-emitter current (Ic). Since Ic is 400mA, and h_FE is typically 100-300 for an NPN small-signal transistor (like a 2N3904 or BC547), Ib should be about 10% of Ic. This is important, because as Ic increases, the gain decreases (transistors aren't perfect); for my 2N3904, it decreases to 30 when Ic is 50mA.
"Wait a minute," you might be saying, "isn't the peak current for a 2N3904 or BC547 only 200mA?" Yes, you're correct! I'm glad you caught that now, instead of burning out your transistor (or at least burning your finger on it). If you were to push this limit, your current gain would probably drop enough that you would just end up limiting the output current to about 200mA. If you were to try pushing it harder (perhaps increasing Ib to 200mA or more), you would quickly burn up the transistor.
But first, let's assume that this would work (we can always use a different transistor). We want to set Ib to be 10% of Ic, or 40mA. We use the base resistor to do this. Once again, I=V/R. This time the voltage drop across the resistor is the 5V supply from the parallel port, minus the 0.7V drop between the base-emitter junction of the transistor. Moving our formula around to get R=V/I, we get:
Code: Select all
R = (5V - 0.7V) / 40mA = 107.5 ohms
If the resistance is significantly higher than this, we won't be fully activating our switch, which means our backlight will be dim.
"Aha," you say, "so THAT'S why my backlight was so dim." Yes, essentially. The resistors given in the previous schematic were correctly balanced, but the current through the LED was being determined by the 100 ohm resistor. This would have given a current of only:
Code: Select all
I = V/R = [ 5V - (0.3V + 4.2V) ] / 100 ohm = 50mA
This would be enough to light the backlight, but would only be approx. 1/8 of the brightness (the brightness isn't directly proportional to the current, but it's close enough).
So the most important thing is having the correct resistances. If the collector resistor is too large, we won't have a bright enough LED; too small and we'll burn it out. If the base resistor is too large, the switch won't fully turn on and the collector current will be limited to Ib x h_FE (where h_FE would probably drop below 30). Too small and we risk burning out the base-emitter junction (it is also rated at 200mA peak, and the entire device itself has a maximum heat dissipation).
"But if you had no resistors, wouldn't you get an infinite current and burn out the transistor and the backlight?" Technically, yes: that is, IF we could pull an infinite base current. However, our base current is coming from the parallel port, not a battery. It just so happens that the parallel port has current limiting protection built into it, just in case it should see a short circuit. Let's see what's happens now.
As quoted from
ePanorama:
The parallel port data pins are TTL outputs, that can both sink and source current. In ordinary parallel port implementations the data outputs are 74LS374 IC totem-pole TTL outputs which can source 2.6 mA and sink 24 mA.
From this we can see two things:
- We aren't getting much current from the parallel port, since we are asking it to source (provide) current.
- We could get a lot more out of it if we instead used it to sink current.
Aside from this, let's see what the prescribed circuit would do in this case. Since the collector resistance is essentially zero and is trying to draw an infinite current, the actual collector current will instead depend on the available base current. With no base resistor we should be getting an infinite base current, but because it's limited by the output of the parallel port's driver, we will instead see approx. 2.6mA. The resulting collector current is:
Code: Select all
Ic = h_FE x Ib = 30 (under significant Ic) x 2.6mA = 78mA
This is obviously brighter than the case using the 1kohm resistor on the collector, but there's a long way to go (it's still less than 1/5 of the brightness).
So what do we do? Well, we could use two transistors. The overall gain would be the gain of both multiplied together, which would certainly be enough to power the LED (30*30 = 900, 2.6mA * 900 = 2.34A max). Of course, we already had the problem that this transistor can't handle much more current than this anyway, so we also need to pick a different transistor. We could just replace our current transistor with a darlington pair--this is what looks like one transistor, but is actually two together inside of a package. This would not only be able to provide our current gain, but would also be able to handle the current we need.
OnSemi has the
BC517, which is a cheap NPN Darlington pair that can sink 1A with a minimum gain of 30000; more than enough for our application. Unfortunately, Darlington's do have some small disadvantages. The base-emitter voltage is doubled because there are two transistors; but this isn't particularly important because we have a full 5V to use at the base. What could be a problem is that Vce(sat)--the voltage across the collector-emitter when a sufficiently strong current is at the base to cause saturation--also increases by 0.7V to become 1.0V. This unfortunately doesn't add up; how can we provide 4.2V to the LED if our 5V supply gets dropped 1V by the transistor? Well, we can't, and though it's hard to say exactly what the effect will be, it's quite possible that this small 0.2V will just cause the LED to become dimmer. Why? Because there is a linear--but steep--relationship between the voltage across a diode and the amount of current it will allow through. If we sneak just below this 4.2V forward voltage drop, we may lose quite a bit of current, yet still be turned on and have plenty of current flowing. If we were to drop the voltage much lower than this, the current would also drop quickly to the point that it would probably just turn off. Bad news.
So, this is what we have so far. A single transistor won't work because we don't get enough current gain. A Darlington might work, but the high Vce(sat) might prevent the backlight from lighting (or atleast fully), even without a resistor (which is a tricky situation that we don't want to play with, since even a small variation in the supply voltage could cause the current to rise quickly and blow the LED).
With this in mind, we are down to two options. Either we use two transistor amplifiers one after another to create our switch; OR we use a PNP transistor. Why a PNP? Because the parallel port can only source 2.6mA, but it can sink 24mA (note that the 2.6mA is internally limited, but the 24mA may not be!), and turning on a PNP requires presenting a ground voltage to the base, thereby sinking current into the parallel port.
Now I'm laughing to myself. All this talk about using two amplifiers and Darlingtons, and yet this whole time I've been limiting my thinking to using a BJT (bipolar junction transistor). Though certainly the oldest, most abused transistor ever, we have several new ones which would work just as well. In particular, the standard MOSFET (the main component of almost every IC in your computer) has properties which overcome almost all of these problems.
What makes a MOSFET special? For one, it doesn't consume any base current. Well, that's not entirely true, but it's absolutely miniscule, and is only consumed during a switch from on-to-off and vice-versa. Also, it's a voltage-controlled device as opposed to a current-controlled device; it doesn't care what the input
current is, only the input
voltage, so our lack of current isn't a problem, since we have more than enough voltage.
Now the only problem is finding an appropriate MOSFET. The BS170 is quite common, and though it is capable of handling our desired current, it's Rds (resistance across the drain-source, which is basically the same thing as the collector-emitter of the BJT) is 5 ohms; significantly higher than the 1.5 ohms we need to drive our LED properly. Also, anything higher powered becomes REALLY powerful--more than we really need--there just doesn't seem to be a happy medium.
The IRFD110 from International Rectifier is a rather common--albeit strange--model. It comes in a 4-pin DIP, where the 2 drain pins are connected together. It has an Rds of approx 0.59ohm and can handle drain current up to 1A. This is essentially a drop-in replacement for our old BJT transistor.
Unfortunately I'm running out of time here, and am having some small trouble determining the required resistances in order to use this MOSFET. The value of the gate resistor isn't very important (in fact, it could be left out), but 100 ohms usually works well to avoid problems (in case the gate breaks down this will prevent a bad short-circuit from gate to source).
The real problem is the drain resistor (equivalent to the collector resistor). The drain current, Id, and the resistance, Rds, depend both on the gate voltage (Vgs=5V in our case) and the drain-source voltage (which would be approx. 0.8V for my LED). There are graphs shown on the datasheet that describe the relationships between these three values. Of course, changing our external resistor changes Id, and therefore changes Rds, so picking a resistor values requires some trial and error, and I just don't have time for that at the moment.
So, all in all, this is what we've come up with:
- Driving a transistor and/or LED without a resistor is dangerous
- The previous circuit works (only partially) because the source current of the parallel port is limited
- We need to use some alternative configuration: perhaps putting another common-emitter amplifier in front of the existing one, or using an PNP transistor to take advantage of the parallel port's superior sinking ability
- Picking the right transistor, especially with MOSFETs, can be challenging
My final suggestion then is to use a PNP transistor, such as the 2N4918. Although they have smaller amplification (barely enough to maintain saturation), they are a cheap, simple solution to the problem which--although not ideal--will give much better performance than the previous circuit.
Given a more reasonable forward voltage drop on the LED backlight and more time, picking out a good MOSFET (like the IRFD110) and the appropriate resistors is your best bet. Until then, simply substituting a PNP transistor (using the circuit below) will do the trick.
