Author Topic: Switching with a transistor.  (Read 1848 times)

0 Members and 1 Guest are viewing this topic.

Offline James Harton

  • Newbie
  • Posts: 2
  • Country: nz
  • Professional tinkerer
    • axe.io
Switching with a transistor.
« on: January 17, 2012, 07:13:06 PM »
Hi all. I have a string of (up to 8) RGB 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.

Offline jjrosent

  • Newbie
  • Posts: 3
Re: Switching with a transistor.
« Reply #1 on: January 17, 2012, 08:02:07 PM »
Hrm. Several things.

NPNs should be used in high side configuration. see http://www.rason.org/Projects/transwit/transwit.htm

IE 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.

Offline James Harton

  • Newbie
  • Posts: 2
  • Country: nz
  • Professional tinkerer
    • axe.io
Re: Switching with a transistor.
« Reply #2 on: January 18, 2012, 09:09:17 AM »
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.

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 2487
  • Country: au
Re: Switching with a transistor.
« Reply #3 on: January 18, 2012, 09:50:07 AM »
Hrm. Several things.

NPNs should be used in high side configuration. see http://www.rason.org/Projects/transwit/transwit.htm

IE 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.

You mean I've been doing the wrong thing for the last 30 odd years? ;D
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

Offline metalphreak

  • Frequent Contributor
  • **
  • Posts: 767
  • Country: au
Re: Switching with a transistor.
« Reply #4 on: January 18, 2012, 04:52:23 PM »
high side = base current doesn't flow through device
low side = base current has to flow through device

Not sure that it really matters much for basic switching purposes.

Offline markedagain

  • Contributor
  • Posts: 9
  • Country: ca
Re: Switching with a transistor.
« Reply #5 on: January 18, 2012, 05:15:49 PM »
Not sure that it really matters much for basic switching purposes.

it 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.

Offline SteveUK

  • Contributor
  • Posts: 19
  • Country: gb
Re: Switching with a transistor.
« Reply #6 on: January 19, 2012, 06:35:38 PM »
Quote
NPNs should be used in high side configuration. see http://www.rason.org/Projects/transwit/transwit.htm


I'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 mA
Ib = 0.06mA

Vce = 0.77V
Vbe = 0.7V


BC108 - Number 2
-------------
Ic = 11.7 mA
Ib = 0.04 mA

Vce = 0.74V
Vbe = 0.7V


BC108 - Number 3
-------------
Ic = 11.6mA
Ib = 0.05mA

Vce = 0.78V
Vbe = 0.71V

I 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.5mA
Ib = 4.6mA (100 times bigger)

Vce = 33mV  (much nicer!!)
Vbe = 0.78V

So, putting the load on the high side seems to have a big effect. 

« Last Edit: January 19, 2012, 06:45:42 PM by SteveUK »

Offline AcHmed99

  • Super Contributor
  • ***
  • Posts: 1069
  • Country: ca
Re: Switching with a transistor.
« Reply #7 on: January 20, 2012, 04:01:57 AM »
Hi Steve

Google "emitter follower" and all will become clear.Your first circuit emitter load is doing exactly what its supposed too.There is nothing wrong with either they both have there uses.

Offline olsenn

  • Frequent Contributor
  • **
  • Posts: 995
Re: Switching with a transistor.
« Reply #8 on: January 20, 2012, 04:27:59 AM »
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.

Online Hero999

  • Super Contributor
  • ***
  • Posts: 3534
  • Country: 00
Re: Switching with a transistor.
« Reply #9 on: January 20, 2012, 09:40:07 AM »
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.6V
Plenty 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.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf