Switching with a transistor. - Page 1
Forum section: electronics / beginners

author: James Harton
author_rank: Newbie
timestamp: January 17, 2012, 08:13:06 am
content: Hi all. I have a string of (up toRGB LED units each with their own shift-register style PWM driver. They are daisy chained with 4 pins in (+5V, clock input, data input, GND) and 4 pins out (+5V, clock output, data output, GND) each. The whole lot is switched on and off with a 2N2222A. Base is connected to an ATmega GPIO pin via a 10k resistor, the collector is connected to +5V and the emitter is connected to the +5V pin for the LED units. Maximum load should be about ~480mA if all 8 LEDs are white at full brightness (24 x 20mA).schematic:My problem is that when I connect more than two LED units the entire board shuts down. My guess is that I need to remove or reduce the resistor between the base and the AVR pin and possibly also add a 10k pull down resistor to the base also.If anyone can give me their opinion I would be really appreciative.Thanks.

author: jjrosent
author_rank: Newbie
timestamp: January 17, 2012, 09:02:07 am
content: Hrm. Several things.NPNs should be used in high side configuration. seehttp://www.rason.org/Projects/transwit/transwit.htmIE your emitter should be connected to GND, and your collector should be connected to your positive rail through your load.Secondly you're using a 10k resistor with 5 volts at your base (v=ir) means you're putting in .5ma. Your transistor has a gain of between 30 and 300. That datasheet is unclear to me, but you're saying you want like 500ma out and for 10v 500ma IC it says min 30, no max. I would use the max current on your base and see what you can get out of it and then ratchet it down if you have to.You might damage your micro if you just open it up so do the math on how much you can take out of your avr. Most AVRs can do 40ma per io pin (check your datasheet) so v=ir 5/.04=125ohm resistor. Try that and see if you can do more.

author: James Harton
author_rank: Newbie
timestamp: January 17, 2012, 10:09:17 pm
content: Hi.Thanks for the reply. I'm going to yank the parts out of the board today and rewire it to do as you suggested. Is there a reason why an NPN has to be used in a high side configuration? I think I can assume a budget of 20mA from the micro, so my rudimentary calculations would suggest that I need a 220mA resistor?The data sheet for the transistor I have is here:http://docs-asia.electrocomponents.com/webdocs/078e/0900766b8078ebad.pdf. I'm not really certain which of the values from the data sheet represent the base saturation current.

author: vk6zgo
author_rank: Super Contributor
timestamp: January 17, 2012, 10:50:07 pm
content: Quote from: jjrosent on January 17, 2012, 09:02:07 amYou mean I've been doing the wrong thing for the last 30 odd years?The text & fig 2 in this link don't match,but nowhere does he say you can't use an NPN transistor with the load in the emitter circuit.To the OP: Have you tried running the LED circuits direct off the +5 volt line?If the +5 volt runs out of puff directly connected,it won't work with the transistor circuit.You should be able to get the transistor circuit to work if you spend a bit of time on it,Disconnect the 10k resistor from D10,& connect it directly to +5 volts----Does it turn the LED units on,& stay on OK?.Try two NPNs in Darlington configuration.This isn't rocket science,but it's a good opportunity to learn.VK6ZGO

author: metalphreak
author_rank: Frequent Contributor
timestamp: January 18, 2012, 05:52:23 am
content: high side = base current doesn't flow through devicelow side = base current has to flow through deviceNot sure that it really matters much for basic switching purposes.

author: markedagain
author_rank: Newbie
timestamp: January 18, 2012, 06:15:49 am
content: Quote from: metalphreak on January 18, 2012, 05:52:23 amit should not from what i understand, since there is no change in current during base saturation there should be no power dissipated, or very tiny if any from tiny current loss. so putting transistor on either side should make no difference.to keep things conventional is a different story. specially in case you screw up and dont saturate the base and dont realize.

author: SteveUK
author_rank: Contributor
timestamp: January 19, 2012, 07:35:38 am
content: QuoteI've been pulling my hair out this evening trying to work out why my collection of 20 year old BC108 NPN's have been showing an excessive Vce drop of 0.8V, when the data sheet says it should be something like 90mV. I tested three different BC108s with the following results.BC108 - Number 1-----------------Ic = 11.3 mAIb = 0.06mAVce = 0.77VVbe = 0.7VBC108 - Number 2-------------Ic = 11.7 mAIb = 0.04 mAVce = 0.74VVbe = 0.7VBC108 - Number 3-------------Ic = 11.6mAIb = 0.05mAVce = 0.78VVbe = 0.71VI was supplying the base from 5V via a 1K resistor (I was using 10K, but due to the high Vce I brought it down to 1k thinking there wasn't enough base current for saturation). A 390 Ohm resistor from the emitter to ground is the "load". However, I had the load on the emitter side, down to ground. I didn't have it High-Sided.As soon as I high-sided it, the results were...Ic = 13.5mAIb = 4.6mA (100 times bigger)Vce = 33mV (much nicer!!)Vbe = 0.78VSo, putting the load on the high side seems to have a big effect.

author: olsenn
author_rank: Frequent Contributor
timestamp: January 19, 2012, 05:27:59 pm
content: Your LED's have a voltage drop on them (Vled). Thus the base current of your transistor is ([5V - Vled]/10) mA. The current through the LED's will be that base current multipled by some factor, hfe. If when you work all that out it turns out that not much current is passing through those LED's (per LED), then they will not light up; this may explain why your circuit does what you want until you add too many LED's.Try a common emitter configuration.

author: Zero999
author_rank: Super Contributor
timestamp: January 19, 2012, 10:40:07 pm
content: There is nothing wrong with the configuration you've posted, as mentioned above, it's an emitter follower. The only thing you should change is remove R3 as it's not required to limit the base current which is self-limited by the transistor's emitter voltage rising to drive the load.The advantages are::High input impedance.Minimal base current.No base resistor required.The base current is used by the load.High side switching is convenient for some applications such as in an automotive environment.The disadvantages are:Higher voltage loss than common emitter: the load sees 0.7V to 1.6V less than the supply voltage.No voltage gain so needs to be driven from a rail-to-rail output: the load sees 0.6V to 1V less than the output voltage of the driver.Higher power dissipation by the transistor.A common emitter amplifier uses the NPN transistor to switch the load side.The advantages are:Minimal voltage loss in the transistor, typically <0.6VPlenty of voltage gain: a load running off 400VDC can be switched by under 1V.Lower power dissipation by the transistor.The disadvantages are:The base current is often set higher than is necessary to ensure saturation.Lower input impedance.A base resistor is required which dissipates additional power.All in all the common emitter configuration is generally more popular thanks to the voltage gain and low voltage loss.In this case I'd recommend a logic level power MOSFET in common source configuration because it doesn't take any power from the driver when it's not switching and the voltage loss is lower than a BJT.