Author Topic: Transistor bias. For a switch. Again.  (Read 5199 times)

0 Members and 1 Guest are viewing this topic.

Offline apellyTopic starter

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Transistor bias. For a switch. Again.
« on: May 27, 2015, 12:28:13 pm »
I hesitate to ask such a recurring n00b question, being that it's the most basic of basic building blocks, but I'm well into my 8th hour of googling, calculating and failing: We'll see how it goes.

I have this PNP transistor that I'd like to use as a switch. Datasheet. I'm pretty confident that the base resistor doesn't matter. I think 5k should turn it on and stop it blowing up. But that feels like a guess. I'd like to know how to calculate it properly.



I think I have 2 problems:
1) I can't read the fucking datasheet. This is incompetence and ignorance on my part. It's a combination of not understanding the fundamentals, and the datasheet not meshing well (for me) with any of the top google hits for the math. I'd really like some help here.
2) I think I've been lazy. It's too easy to learn the stuff you "already know" and gloss over the stuff you "think you know." There are quite a number of (endless?) pretty bloody comprehensive transistor theory pdfs and web pages kicking around, but they seem to start with "this is the theory of silicon doping," proceed through "and this is why they are used as amplifiers," to "these are common amplifier topologies." I know all the information is in there, but I'd like to eat this elephant one bite at a time, not all at once. To use an old professor's analogy.

After a quick look in minute 5, and a long look in hour 8, I reckon Sparkfun's intro is the short, comprehensive and looks the most useful, at least for this basic situation: https://learn.sparkfun.com/tutorials/transistors.

If you can be bothered replying then thank you for taking the time, but please, I'm interested in the why and the how, not just the answer.

Cheers,
Aaron.

Edit 1: I may have rushed this post. If it reads like nonsense I'll make it more sensible in the morning.

Edit 2:
Clarifications
The transistor selection criteria was digikey>PNP>sort by price>lots of stock>headline values look plausible>select. I don't need to use this particular one, but I've got to learn how to do this one day so in this regard this one is as good as any, even if I choose another later.

The image is a crop from my project using an LXP ARM M0. The function of the switch is to allow USB soft connect by pulling USB data + up to 3.3V via 1.5kR. Details in AN11392 section 2.2

The full datasheet for the device I'm using, an LPC11U35FBD48, is here if anyone cares:
  • Section 11.1 has more info about USB.
  • Section 9.4, Fig. 20 says the typical pin pull down current is around 62uA at 3.3V and 25°C, climbing slightly with heat. Lets say 50uA to be safe. That's lower than I was expecting. I think my original math suggested I was looking for more like 500uA on the base. But, the reason I'm asking about this in the first place is I think my original math was bollocks.

Notes to self:
What causes a transistor to dissipate power?
Is it the predictability of saturation that makes it the region to operate as a switch, or is this related to power dissipation?
Is my terminology bad enough that it is confusing me too?
What parameters should I have searched for in the beginning to be reasonably confident I started researching an appropriate part?
I get the feeling that I jumped into this without properly defining or understanding the requirements I had, for example, by not knowing the current consumption of the USB data lines.
« Last Edit: May 28, 2015, 08:55:25 am by apelly »
 

Offline apellyTopic starter

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Re: Transistor bias. For a switch. Again.
« Reply #1 on: May 27, 2015, 12:53:13 pm »
Actually, this is a huge question.

I'm not expecting anyone to write the intro to transistors here (free electron has done that somewhere already, (but I haven't read it for a while.)) I guess I was was hoping for a  conversation while I get my head around it.

 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1780
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Re: Transistor bias. For a switch. Again.
« Reply #2 on: May 27, 2015, 12:55:19 pm »
First question - what does the load look like (i.e. what is connected to USB_DP)? 
How much current will it draw, and will it work properly when fed through a 1.5k resistor to 3.3V?

Assuming the current is reasonable, and the answer to the 2nd question is "yes", then when using a bipolar as a switch - you'll be pushing the transistor into saturation.  In that case, you generally size the base resistor so that the base current is about 10% of the expected collector (load) current.

For a saturated switch application, the only datasheet parameters you generally need to think about are:
- The collector emitter saturation voltage - VCEsat - and will your circuit work with this much voltage drop in series with the load
- The maximum rated collector current - are you operating well below the max...
- The base-emitter saturation voltage - used to help you calculate the base resistor value (VCC-VBEsat-VLOWdriver)/IB

Does this help?
« Last Edit: May 27, 2015, 01:26:04 pm by w2aew »
YouTube channel: https://www.youtube.com/w2aew
FAE for Tektronix
Technical Coordinator for the ARRL Northern NJ Section
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7695
  • Country: de
  • A qualified hobbyist ;)
Re: Transistor bias. For a switch. Again.
« Reply #3 on: May 27, 2015, 01:25:16 pm »
Assuming the current is reasonable, and the answer to the 2nd question is "yes", then when using a bipolar as a switch - you'll be pushing the transistor into saturation.  In that case, you generally size the base resistor so that the base current is about 10% of the expected collector (load) current.

So much? That would be 2mA for a 20mA LED for example. Don't you consider hFE to optimize the circuit's power consumption?
A rule of thumb I know suggests to make the base current 10 times the current required to to drive the load. When we assume hFE being 100, the minimum base current would be 20mA / 100 = 0.02mA to drive the LED. So we use 10 * 0.02mA = 0.2mA as the base current to switch the LED.

EDIT:
Mea culpa! 20mA / 100 = 0.2mA and 10 * 0.2mA = 2mA. Perfect match :)
« Last Edit: May 28, 2015, 12:15:24 pm by madires »
 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1780
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Re: Transistor bias. For a switch. Again.
« Reply #4 on: May 27, 2015, 01:31:12 pm »
Assuming the current is reasonable, and the answer to the 2nd question is "yes", then when using a bipolar as a switch - you'll be pushing the transistor into saturation.  In that case, you generally size the base resistor so that the base current is about 10% of the expected collector (load) current.

So much? That would be 2mA for a 20mA LED for example. Don't you consider hFE to optimize the circuit's power consumption?
A rule of thumb I know suggests to make the base current 10 times the current required to to drive the load. When we assume hFE being 100, the minimum base current would be 20mA / 100 = 0.02mA to drive the LED. So we use 10 * 0.02mA = 0.2mA as the base current to switch the LED.

hFE only applies when you are NOT operating in the saturation region.  If you are designing an amplifier, etc. where the transistor isn't going to be in the saturation region (i.e. a non-switch application), then hFE is something to consider  when setting up the bias.  Although, there can be very large variations in hFE, so it is good practice to make your designs as immune to hFE variations as possible (see my video on beta independent transistor biasing).

Once you drive the collector voltage to saturation, hFE no longer applies and you generally use the 10% figure.  This is partly because when the transistor is saturated, the base-collector junction is also forward biased and contributes to the total base current.  In fact, look at the datasheet for the VCEsat spec and you'll see that it is spec'd using base currents that are 10% of the collector current.
« Last Edit: May 27, 2015, 01:33:10 pm by w2aew »
YouTube channel: https://www.youtube.com/w2aew
FAE for Tektronix
Technical Coordinator for the ARRL Northern NJ Section
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21609
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Transistor bias. For a switch. Again.
« Reply #5 on: May 28, 2015, 03:50:56 am »
Externally speaking, for just a switch, you can disregard most of the datasheet.

What you need to find are:
Vceo and/or Vcbo: must be greater than supply voltage (page 2, 40V >> 3.3V is fine),
Ic max: must be greater than the required current load (page 2, 200mA?),
Pd max: must be greater than the required power dissipation (page 2, 250mW; more on this later),
hFE min (at condition ___ ): must be good enough for the application (page 3),
Optionally, switching speed t_(d, r, f, stg), fast enough for application (page 3).

Note that PNP datasheets are sometimes written in consistent units, i.e., Vce is literally voltage from positive collector to negative emitter, current is positive if flowing in, negative if flowing out, etc.  So you get a storm of negative values.  Sometimes you get inconsistently signed values. :)

Personally, I don't give a shit, magnitude is fine by me.  I already know what direction it's supposed to be.  That's what the little arrow says.  If you've got 20V across an NPN or a PNP, you don't have to guess which direction you're doing it in -- the presence or absence of magic smoke will tell you at a glance!

Ok, switch.  Using the "current controlled" model is fine here (though don't lose sight that B-E voltage really is the thing that matters, we're just using an excess of controlled current to get there safely!).  So, we need Ic / hFE base current.  Or, we can get up to Ic = Ib * hFE current out of it.  Ah, but that's linear.  hFE drops in saturation.  How much is safe?  Depends.  You get lower saturation for lower hFE (= higher Ib for the same Ic -- when it's saturated, we're in charge of what "hFE" can be; as a device parameter, hFE is only valid in the linear range, as mentioned).

Typically, a design goes like this:
- Pick a transistor with min hFE 100 or so (it'll actually be up to 300 at higher temperature, maybe 500+ with manufacturing tolerance included -- many types are binned by rough hFE range, giving you some control over this if necessary/desirable)
- Pick some safety margin for saturation (usually 3 to 10 x)
- Apply that base current (if from a logic voltage or whatever, use a current limiting resistor)
Easy.

The safety margin works thus: a transistor with typical hFE = 200 might saturate quite nicely (Vce(sat) < 0.5V)) at hFE = 100 (i.e., if we're switching 10mA, use 0.1mA Ib).  But it won't be very good, because at low temperature, hFE drops and it might come out of saturation.  (On the upside, the increased power dissipation might heat it up enough to resume a near-saturated condition?)  A factor of 3 is pretty good insurance there, so you might use 0.3mA Ib instead.  Now it's pretty well saturated (Vce(sat) < 0.2V, say?), and pretty well guaranteed to remain so, even in the friggin' arctic, with floor-sweepings quality transistors.  But maybe that's still not good enough, maybe the load is 10mA normally, but spikes to 30-100mA!  We can keep it nice and solidly saturated under most of those conditions, by raising Ib still more.  And the highest peaks might be dubious, but we can give them a good try.  So such a switch might be driven at Ib = 1mA instead.  It's not usually a big cost to draw more base current, so this is OK, and it makes it stupidly robust*.

*Except that, if the load is prone to shorting as well, it'll pull the collector voltage up from Vce(sat), moving into the linear range.  Where it will draw 100-200mA.  At 3.3V supply, a short can be expected to cause 3.3V * 0.2A = 0.66W dissipation, which exceeds the continuous 0.25W rating.  It won't burn out immediately, but it won't be happy after a second or three.  Because of cases like this, it can be desirable to keep base current more modest, thus limiting the short-circuit current (at least crudely).

Traditionally, transistors are rated for saturation at this condition, hFE = 10.  Not sure why it's so low, really, because 30 would be comfortable for most, but, I guess it comes from the olden days when transistors were truly all over the place.  Always take note of the condition, though: high voltage power transistors will be rated for hFE as low as 5, or even 2; high gain (often "low Vce(sat)" or "superbeta" types) might be specified for hFE = 80 or more.

Anyway, page 3 shows Vce(sat) at hFE = 10 (Ic = 10 or 50, Ib = 1 or 5), and it's under 400mV.

Now... if you were planning on drawing more than 50mA Ic, you should probably consider a different transistor.  They give the highest rating for 50mA, and the maximum is only four times this.  Double, 100mA, would still be okay -- they don't guarantee parameters at this condition, but we can at least guess that it won't be too bad.  Referring to the hFE plot on page 4, it's clear that hFE is dropping sharply in the 50-100mA range.  But the 25C curve crosses 100mA at around 70 hFE, which still isn't too bad.  So it will probably be quite well saturated at the hFE = 10 condition, even at 100mA.  (Note that all the curves are pretty well tanked by 200mA, and don't even show data beyond Ic max.)

Now, if you need to handle more than 100mA, like switching USB power (as your drawing seems to suggest..?), that's completely unreasonable, and you'll need a better one.

BTW, Ic(max) for BJTs is usually a physics limitation.  Current crowding and all that.  It simply can't carry any more current (hFE drops)!  As a switch, or in pulsed operation, it's not at all unreasonable to operate at 25-50% of Ic max.  You'll probably cook it if you try doing that in the linear range (i.e., Vce > Vce(sat)), but that's a thermal problem.

On a related subject:
MOSFET ratings are usually thermally driven, so beware: a D/D2PAK device will typically be rated for Id(max), DC, at *package* thermal dissipation (50-200W!), which is one or two orders of magnitude off the typical PCB-mounted capability (~1-5W?).  In normal use, an "on" MOSFET can be assumed to act more-or-less like a resistor, so dissipation can be calculated accordingly.  The MOSFET *physics* limit is much higher than the continuous rating; this is more-or-less captured by the Id(pulsed) rating instead.  MOSFETs have a constant-current characteristic, like BJTs, but "below the knee" (where it looks like Rds(on) resistance) goes up to much higher voltages, usually ~10V or so.  The point where the highest Vgs curve levels off, is the point if Id(pulsed).  So the rating is essentially, "if you want to blow up transistors, this is how much shit you're gonna see flying".  At lower currents (and voltages), it can simply be treated as a resistor.

(On a related related subject: BJTs in saturation kind of act like resistors, too.  They're not nearly as linear, which means they stink for "audio mute" type switches.  You can still do calculations, assuming a BJT has an "on resistance" -- but it's not usually as useful, because you still need to know Ib anyway.)

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline apellyTopic starter

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Re: Transistor bias. For a switch. Again.
« Reply #6 on: May 28, 2015, 06:23:53 am »
Alan & Tim: Thank you for taking the time to reply.

I'm just sitting down now for a couple of hours to work through what you have said and answer your questions. I may not finish this today because I'm finding more and more stuff (distractions?) tucked away in the MCU datasheet. I've added a couple of clarifications at the end of my first post.

And Tim, I do like your writing style!
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: us
  • If you want more money, be more valuable.
Re: Transistor bias. For a switch. Again.
« Reply #7 on: May 28, 2015, 07:20:08 am »
Tim,

If you wrote a book. I would buy it.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline apellyTopic starter

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Re: Transistor bias. For a switch. Again.
« Reply #8 on: May 28, 2015, 07:21:59 am »
Tim,

If you wrote a book. I would buy it.
That's pretty much what I was thinking!
 

Offline apellyTopic starter

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Re: Transistor bias. For a switch. Again.
« Reply #9 on: May 28, 2015, 08:56:33 am »
First question - what does the load look like (i.e. what is connected to USB_DP)? 
It's a pull up on a data line.

How much current will it draw, and will it work properly when fed through a 1.5k resistor to 3.3V?
I calculate 2.2mA short circuit. I actually have no idea about the real current draw. I suspect SFA. According to the datasheet and app note, linked in the first post now) this is how it's done. Pulling this line high signals the presence of a USB devise to the host.

Later:
On reading the USB spec, the host pulls the data line low with a 15k 5% resistor. Now I'm thinking that's 200uA at 3.3V, not allowing for the drop across the transistor.

Assuming the current is reasonable, and the answer to the 2nd question is "yes", then when using a bipolar as a switch - you'll be pushing the transistor into saturation.  In that case, you generally size the base resistor so that the base current is about 10% of the expected collector (load) current.
220uA. I may be getting ahead of myself, but that looks like you're assuming hFE >= 100. From what I've read and watched, this looks like a safe assumption. Would you mind explaining a bit more about why this rule of thumb applies?

After research:
OK, now I think IB 20uA, taking into account the 15k pull down at the other end.

For a saturated switch application
Emphasis mine. You are saying that a switch always operates in the saturation region. I think.

For a saturated switch application, the only datasheet parameters you generally need to think about are:
- The collector emitter saturation voltage - VCEsat - and will your circuit work with this much voltage drop in series with the load
The USB spec says pull up with 3V to 3.6V with a 1.5k 5% resistor. I'm going to say yes. But I'll do math later.

- The maximum rated collector current - are you operating well below the max...
Crazy below.

- The base-emitter saturation voltage - used to help you calculate the base resistor value (VCC-VBEsat-VLOWdriver)/IB
VCC 3.3V
VBEsat, well that's off the chart, according to Fig4 in the datasheet which shows ~580mV at 100uA if I'm reading it correctly. If I'm right I'm supposed to be looking for 20uA here.

While I've been following through your post, and doing other, perhaps relevant, research I've found another transistor that's probably a better fit, but let's stick with this for now, because it brings up the question: Can I extrapolate off this graph, or is the fact that the data is missing a fat clue that I've got the wrong component here?

VLOWdriver, I do not know what this means. I can tell you that Google indexes this site fast though. The top hit it this thread. I'm going to guess it's the voltage applied to the base via the resistor. So, zero.

3.3 - 0.58 - 0
--------------  = 136k
     .00002

Does this help?
Ha! I think so. It's nice to have some structured questions to think about.


 

Offline apellyTopic starter

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Re: Transistor bias. For a switch. Again.
« Reply #10 on: May 28, 2015, 09:21:28 am »
Tim, I'll work through your epic post tomorrow. I've been dicking around with this for another 4 hours now, although you wouldn't know it from my meagre writings.

Aaron.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7695
  • Country: de
  • A qualified hobbyist ;)
Re: Transistor bias. For a switch. Again.
« Reply #11 on: May 28, 2015, 12:45:24 pm »
Traditionally, transistors are rated for saturation at this condition, hFE = 10.  Not sure why it's so low, really, because 30 would be comfortable for most, but, I guess it comes from the olden days when transistors were truly all over the place.  Always take note of the condition, though: high voltage power transistors will be rated for hFE as low as 5, or even 2; high gain (often "low Vce(sat)" or "superbeta" types) might be specified for hFE = 80 or more.

So hFE drops to about 1/10 when the BJT is in saturation mode. This might be the reason for the rule of thumb: 10 * Ib while Ib = Ic / hFE. I've checked the datasheets for BC54x and BC55x, they use a factor of 5 (Ib = Ic / 20) for specifying the saturation voltages. The next question is, if the hFE classes A, B, C got any impact on that.
 

Offline con-f-use

  • Supporter
  • ****
  • Posts: 807
  • Country: at
Re: Transistor bias. For a switch. Again.
« Reply #12 on: May 28, 2015, 12:57:18 pm »
Why do you want to switch the 1.5k pullup on a USB D+ dataline? To disconnect and reset die USB connection? If you are using a USB1.1 low speed device that resistor needs to go on the D- line.

Anyway, this should work, regardless of the resistor (as long as it is in the kOhms). Are you sure the problem is not something else. Did you check the 3.3 V actually reach the D+ line? Does the device work if you bypass the transistor and connect the resistor manually to 3.3V?
« Last Edit: May 28, 2015, 01:02:55 pm by con-f-use »
 

Offline apellyTopic starter

  • Supporter
  • ****
  • Posts: 1061
  • Country: nz
  • Probe
Re: Transistor bias. For a switch. Again.
« Reply #13 on: May 28, 2015, 01:21:47 pm »
Why do you want to switch the 1.5k pullup on a USB D+ dataline? To disconnect and reset die USB connection?
Correct. Also for late initialisation.

Anyway, this should work, regardless of the resistor (as long as it is in the kOhms). Are you sure the problem is not something else. Did you check the 3.3 V actually reach the D+ line? Does the device work if you bypass the transistor and connect the resistor manually to 3.3V?
This is 100% theoretical right now. I'm designing a prototype. it's 20 cents worth of parts, so I might as well include the footprints just in case.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf