Newbie transistor question

Hi,

I'm having trouble getting a transistor to work the way I thought it should, and I hope someone could help me.

I'm using a PIC to drive common anode 14-segment LEDs. Since the PIC I/O line can't supply enough current, I'm trying to use a 2N2222 transistor instead. The PIC directly drives the 2N2222's base (no intervening resistor), the collector is tied to +5 and the emitter to the common anode. The problem is that, while the LEDs light, they are very, very dim - only visible in a dark room.

I thought maybe that the PIC wasn't saturating the transistor, so I put in a pull-up resistor on the base. No difference. I connected the base directly to +5, and the LEDs were still dim. The emitter shows +4V (5 volts in the collector, 4 volts out the emitter??!!) If I tie the LEDs common anode to +5, they light up nicely, but of course I can't multiplex a bunch of LEDs with the anodes tied to +5.

Am I using an inappropriate transistor? Am I using it wrong?

Thanks, Bob Alexander

Reply to
realexander
Loading thread data ...

Do you have series resistors to limit the led current? They are essential

Check the pinout of the 2N2222, might be upside down

martin

Reply to
martin griffith

You should have a series resistor in the transistor base to limit the current.

Are you sure the PIC pin you are using is actually configured as an output? Disconnect it and check that it is actually being driven high and low.

Leon

Reply to
Leon

A 0.6 or 0.7V drop from base to emitter is to be expected -- if you're seeing 4.3 or 4.4 volts on the emitter (assuming 5V on the base) and rounding down then your transistor is working as expected.

What are you doing to limit the current of your LEDs, and how are you switching the cathodes of the LEDs? I suspect that with the voltage drop on the transistor your current limiting resistor is now too large, and your LED current is insufficient. You can probably get your current back up either by using lower resistance current limiting resistors, or by using a PNP transistor in common emitter. The PNP in common emitter will only drop 0.2V or so -- connect it emitter to +5V, collector to the LED, resistor between PIC and base, and remember that pulling the base _down_ will turn the transistor _on_.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google?  See http://cfaj.freeshell.org/google/

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

The emitter being at 4V is about right. It can never reach the collector's voltage in the configuration you've got it in (common collector).

If 4V isn't enough to light the LEDs then it may mean that either the LED's current-limiting resistor is too big, or (somehow) there are two LEDs (in series) per segment.

If you rearrange your circuit to be common emitter configuration then you can get the emitter and collector voltage to be closer together, during saturation. If you use an NPN, in the common emitter config, then you'll have to make sure that the PIC can source enough base current (through an appropriate series resistor). If the PIC can't source enough current, but can sink enough current, then you'll need to use a PNP device.

It seems that you do understand the basics. You just need to dig a little deeper to find the root of the problem.

Bob

Reply to
Bob

I think hes using an emitter follower so the base current should be self limited.

It sounds like your cathode drivers are needing more volts to work than available with the voltage drop accros the transistor (1v) And the leds (~2v) might leave them 3v wich should be enough, but if you are using an emitter follower for the cathode drivers too it be you have too few volts accros the current limiting resistor, you may need to adjust this accordingly.

alternativly you can use a pnp common emitter for the anode driver with base limiting resistor, or a P chanel FET, of course the logic output will have to be inverted, this should reduce the volt drop wich is inevetable with an emitter follower.

Colin =^.^=

Reply to
colin

(discussing NPN transistors, like the 2N2222) If the transistor were big enough to carry the current and still have significant current gain, the emitter would have a voltage about .6 to .7 volts (one forward biased silicon diode drop) below the base voltage. The problem is that transistors lose gain rapidly as the collector voltage gets close to or below the base voltage. In this common collector application, you expect operation with both collector and base voltage at 5 volts (no extra positive collector voltage to keep the gain up). So the current gain falls and the base to emitter drop rises. I don't know what the total emitter current is with your load (but it can't be very high if all the LEDs are dim), so this may or may not be the problem. You may have collector and emitter reversed (the emitter is the lead near the tab on the can).

All this can be extracted from the data sheet:

formatting link
Note figure 3 and 4. Figure 3 shows the base to emitter drop with the collector voltage so low that the current gain is reduced to 10. Figure 4 shows the base to emitter drop when the collector voltage is

5 volts more positive than the emitter.

You could use a PNP transistor, such as a 2N4403, but you will need a base resistor to limit the base current to a reasonable value (say,

1/20th of the worst case LED load current), if the PIC can pull down that much. If the required base current is more than the PIC can reasonable supply, you need two stages of PNP. The first connected as a follower (similar to what you have, now, except that the collector connects to ground). But then you add a base resistor between its emitter and the saturating switch transistor's base. The resistor's value will have to take into account the two base emitter drops in series that use up some of the 5 volt supply.
Reply to
John Popelish

LEDs (in

He led me to the answer, though perhaps not the way he intended. The display I'm using is a dual 14-segment alphanumeric display, with two common anodes (one for the left digit, one for the right). I initially had +5 wired to both anodes. When I was ready to add transistors, I added one transistor to one of the anodes, but left the other anode at

+5. I assumed they were working independently, so why not leave one digit at +5? The LEDs controlled by the transistor were dim, while the ones wired to +5 were bright. Bob made me stop and think, and I realized that the two digits could affect each other, since segment x of one digit has the same cathode as segment x of the other. I disconnected the common anode of the other digit, and the transistor-controlled digit became bright!

Even a newbie like me understands what was happening now. The LEDs need a voltage drop of 2.6V. The LEDs being fed directly by +5 had (5 - 2.6 = 2.4V) at their cathode. The LEDs fed by transistor were getting +4 in their anode, and saw a (4 - 2.4 = 1.6) difference between their anode and their cathode, which was not enough to light - at least not very brightly.

Once again, thank you all!

- Bob Alexander

Reply to
realexander

If you do, in fact, have a common anode, then that's the only way you can possibly do it. From each individual cathode, run a 120 or 220 ohm resistor to the collector of a 2N2222, and ground all of their emitters. I'd put a resistor (maybe 1K ~ 4.7K) between the chip output and the base, just to limit the current.

If you want to mux more than one display, then drive the common anode with the collector of a PNP.

If the LEDs have separate anodes, then that's not common anode, it's common cathode, and you have to drive it with PNPs, and control the whole display with an NPN at the common cathode.

Good Luck! Rich

Reply to
Rich Grise

eh?

it depends what sort of current your LED requires, but the correctly configured outputs of PICS are definately capable of directly sinking and sourcing 25mA - more than enough for most LEDs. The datasheet I have in front of me (16F84) lists "High current sink/source for direct LED drive" as one of the peripheral features on the over-view page (with the pin-out diagram of the chip)

Obviously if you are driving something that requires more than 25mA then you will need to buffer the signal, but not for "normal" operations.

I drive LEDs direct from PICs with a 150R resistor which gives the LED

20mA - plenty bright enough for most indicators. As a newbie, this is calculated as supply voltage-2 (the LED will roughly "use" 2 volts from your supply) divided by current required... which gives 3V / 0.02A = 150R Ohm's Law.

Why are you driving the anode through the transistor? You should connect the anode directly to (in this case) +5V and then each segment should be connected to the PIC pin via a 150R (or so) resistor. Remember that with a common anode display, you need to drive the pins in a reverse logic, so set a pin low to light the segment. So in any output, 1 is seg off, 0 is seg on.

You need to re-do your drive circuit then go back to your code with a single LED and make sure you can switch it on and off correctly. Then connect up a segment of your display - with the same results - then finish off by replicating your control code for all segments - it has to work. Are you sure you are TRISing the port pins correctly? also, make sure you have turned off any special features of the pins, i.e. analogue input ports, PWM etc... Keep it really simple until you have got control.

Might I also suggest that you take this thread to sci.electronics.basics as this group is populated by engineers that like to eat noobs :o)

Best of luck

H
Reply to
unclewobbly

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.