retrolefty:
That is your show stopper reason to never choose a mosfet over a BJT in a arduino pwm application?
Where did I say "never"? All I said was "worse".
retrolefty:
That is your show stopper reason to never choose a mosfet over a BJT in a arduino pwm application?
Where did I say "never"? All I said was "worse".
Neither have I, but why would you?
Why not just use a BC548 (or whatever) and avoid the MOSFET maths altogether? Capacitance calculations are a pain in the ass, BJTs let you skip them.
fungus:
ruli00:
I'm looking for a MOSFET nowWell:
a) Thanks for wasting everybody's time with the TIP120
b) MOSFETs are worse for PWM use.
c) For 300mA you don't need either a Darlington or a MOSFET, a plain old BJT transistor will work just fine.
If you guys understood how MOSFETS work (both externally as switches and internally as totem pole output drivers in a microcontroller) you wouldn't be worrying about "gate capacitance" (known to real engineers as the "Miller Effect").
The misinformation and sarcasm that permeates this board amazes me to no end...
ruli00:
Hi,
I have multiple projects in mind that will require transistors. I've read many different topics about calculating a base resistor form around the web but am still confused.
I want to be able able to help myself without having to come to the forum to ask what resistor I should use.
The problem is I'm lost when it comes to figuring out "Beta HFE" I don't even know what this means.
I already understand the Base voltage and collector current/voltage.
Anyway, does anyone have any advice to simplify this for me?
"Beta" and Hfe are the same thing, and all it means is the ratio of collector current to base current (AKA "current gain").
For example, if you have a transistor with a current gain of 100, putting 1 milliamp into the base will make the collector pull 100 milliamps.
For the Arduino and most microcontroller circuits, a transistor is used as a simple switch, and it's gain is used to "ease the load" on a microcontroller's output pin.
If you have, say, an LED that draws 500 milliamps, that's WAY too much for an Arduino digital pin to drive, so you add a transistor as a switch (or a "helper").
If the transistor has a current gain of 100, then you need only 500/100 or 5 milliamps from the Arduino digital pin to turn on the LED.
Now, DEPENDING on a minimum current gain is a bad idea. Every transistor has a different current gain (even the same part numbers from the same lot number made on the same day). The current gain even varies with temperature.
When you design a circuit, you assume that the current gain is much lower than the spec.
Here's an example:
I want to run a high powered LED that draws 6 volts at 1.5 amperes. I want to turn it on and off with an Arduino digital pin. Let's assume that my LED power supply is current limited and all I need do is switch the LED in and out of the circuit.
I don't want the Arduino to have to put out more than 20 milliamps... in fact, I only want it to put out 10 milliamps when controlling the LED.
So, I need a MINIMUM current gain of 1500 milliamps / 10 milliamps = 150. And, I don't want to depend on the transistor having a gain of 150, because it may not. In fact, the higher power rating a transistor is, usually the lower the current gain is.
To be sure the transistor will work, I will use a factor of 5 (no, make that 10). A factor of 10 means I need a current gain of 1500.
A single transistor does not have such a high current gain, so I know I need a DARLINGTON transistor. A Darlington is simply one transistor standing on the back of another one. The gain of the first one, in turn, drives the base of the second one so to get a gain of 1500, each transistor in the darlington pair only needs to be about 40 (40 * 40 = 1600).
So now I know the current gain I need. Next spec is the collector current. The transistor I choose must handle a minimum of 1.5 amperes, and again I add a factor of... let's say... 5... so the transistor I want is a Darlington with a current gain of at least 1500 and an Ic of at least 7.5 amps.
The last consideration is the Vceo (voltage across the collector/emitter when the transistor is off. Since this is only a 6 volt or so circuit, almost any transistor will have a sufficient Vceo rating.
Now, to the data books (or experience). How about a TIP-120? Data sheet says:
Hfe minimum: 1000, typical 2500 (sounds good to me!)
Vceo: 60 volts (way good enough!)
Ic: 5 amps continuous (awesome!)
Base-emitter ON voltage: 2.5 typical
OK, so the transistor is more than good enough to handle the load, but how do we drive the base?
Remember we wanted no more than 10 milliamps load on the Arduino. When it's high, the digital pin is 5 volts. The transistor base-emitter ON voltage is 2.5, so the rest (5 - 2.5 = 2.5) needs to drop across the base resistor.
R = 2.5 / 0.01, R = 250 ohms, closest standard value is 270 ohms, so we use that.
Now let's see if it all works: Ibase = 2.5 / 270 = 0.0093 (9.3 milliamps).
9.3 * Hfe minimum 1000 = 9.3 amps.
When turned on, the transistor COULD pull as much as 9.3 amps on the collector if it could, but remember that the LED power supply is current limited, so we KNOW that the transistor is fully saturated (fully ON).
That's it. Easy. If it seems complicated, read it over a few times and you'll see that it's actually simple.
Hope this helps.
Krupski,
Thanks so much for that explanation, I get it and yes seems simple now. I'll post back when I calculate the resistance for a relay I'm going to use a little just to check my math.
Thanks again,
-ruli00
This question interests me as well!
In my case, I am using an Arduino to control 16 separate channels, each with a bunch of bunch of LEDs in series/parallel on 12V. Each channel group draws about 60ma. So I used 2N2222 transistors (cheap, easily available) for each channel. My concern is that I may want all 16 channels ON for extended periods of time, and I don't want the base current of all 16 transistors to exceed the max total power output for the AT328 chip.
So looking at the 2N2222 datasheet, where do I find the minimum base current I would need, and how do I calculate the maximum base resistor value I can get away with?
If your collector current is 60ma and your DC gain is 100 (from data sheet) you need .060/100=.0006A of base current, let's say 1ma.
The voltage base to emitter is about .6volts which leaves 5-.6=4.4 volts across the base resistor. Therefore 4.4v/.001A=4.4k will be your base resistor (4.7k)
Now when the led is turned on measure the voltage from the collector to ground (emitter). If it is less than .4v you can consider your transistor is fully on.
Saturation is when the base voltage is higher than both the emitter voltage and the collector voltage. hFE is not a single number, it depends on operating conditions. Below is a portion of a 2N4401 datasheet. hFE may be 100 or more for small-signal conditions when operating in the active region. But note the test conditions for the saturation specs, e.g. IC = 150mA, IB = 15mA. So hFE in saturation is only 10. This is fairly typical.
Listen to Krupski and Jack Christensen. You can't rely on small signal gain when using a transistor in saturation as a switch. And the small signal gain is only a typical value that varies widely from one transistor to another, and varies with temperature.
In addition, I don't see a current limiting resistor on the LED. Or is that a string made to run straight from 36V without any outside current limiting?
DrWizard:
In my case, I am using an Arduino to control 16 separate channels, each with a bunch of bunch of LEDs in series/parallel on 12V. Each channel group draws about 60ma. So I used 2N2222 transistors (cheap, easily available) for each channel. My concern is that I may want all 16 channels ON for extended periods of time, and I don't want the base current of all 16 transistors to exceed the max total power output for the AT328 chip.So looking at the 2N2222 datasheet, where do I find the minimum base current I would need, and how do I calculate the maximum base resistor value I can get away with?
Look at Figures 2 and 3 from the datasheet below. In Fig2, at 60mA, VCE(SAT) will be something less than 0.1V. In Fig3, VBE(SAT) will be about 0.8V.
Now, an Arduino will not give us 5V on an output pin. In fact, the datasheet only guarantees 4.2V at 20mA. But we will only be drawing 6mA (again, assuming hFE=?=10 as noted on the Fig2 and Fig3 charts), so 4.5V or 4.6V might be a better estimate. Of course, making a measurement might help here. I feel lucky, so let's go with 4.6V.
Therefore the voltage across the base resistor is 4.6 - 0.8 = 3.8V and given a 6mA current, Mr. Ohm tells us the resistance should be R = V / I = 3.8 / 0.006 = 633?. 620? is a standard 5% value so that'd be a good choice. I'd expect 680? would work just about as well since we made some conservative assumptions. If for whatever reason more drive is needed, drop down to 560?. Build the circuit, measure the collector voltage and if it's 0.1V or less, then declare success!
DrWizard:
In my case, I am using an Arduino to control 16 separate channels, each with a bunch of bunch of LEDs in series/parallel on 12V. Each channel group draws about 60ma. So I used 2N2222 transistors (cheap, easily available) for each channel. My concern is that I may want all 16 channels ON for extended periods of time, and I don't want the base current of all 16 transistors to exceed the max total power output for the AT328 chip.So looking at the 2N2222 datasheet, where do I find the minimum base current I would need, and how do I calculate the maximum base resistor value I can get away with?
There's no straight answer to that because there's no "minimum base current".
The "minimum base current" will depend on how much voltage drop from C to E you're prepared to put up with. That's your personal design decision, not written in stone.
This voltage drop also gives you the power dissipation of the transistor, ie. how hot it will get. More base current gives less voltage drop, it will run cooler. This is also a personal design decision.
OTOH: 60mA is very little current. You should easily be able to get away with 1K resistors (maybe higher). 5mA is easily enough to allow a 60mA load and Megas328s have no problem with 5mA on each pin.
Moral: Very precise calculations are only necessary when you're near the limits of the device.
Krupski:
If you guys understood how MOSFETS work (both externally as switches and internally as totem pole output drivers in a microcontroller) you wouldn't be worrying about "gate capacitance" (known to real engineers as the "Miller Effect").The misinformation and sarcasm that permeates this board amazes me to no end...
Huh?
When you're PWMing high power LEDs (or motors or whatever) with logic level MOSFETs and a 20mA I/O pin you most definitely have to worry about the values listed in the datasheet under "capacitance".
Real engineers have even designed special "mosfet driver ics" to help.
At <1kHz arduino pwm speed, you don't need to worry about gate capacitance and mosfet driver IC's or any of that.
I'd replace the 640 Ohm advised above for npn bipolar transister with gain "beta" of 10 with a couple of kOhm, just in case yours has more beta than 10, measure the current through your LED string, and adjust from that. I would not be surprised if you end up using 3.3kOhm +-60%
It might be a good idea to waste 0.6 volt in your LED string by inserting a 10 Ohm 3 Watt rated (>1 Watt) power resistor below your transister, if you can find anything like that, as then you can use a 10kOhm from the top of that to one of the a_in pins to measure that voltage and get an estimate of LED string current without the multmeter.
fungus:
Huh?When you're PWMing high power LEDs (or motors or whatever) with logic level MOSFETs and a 20mA I/O pin you most definitely have to worry about the values listed in the datasheet under "capacitance".
Real engineers have even designed special "mosfet driver ics" to help.
Worrying about I/O pin limitations of an AVR chip and reason for "motor driver chips" is two completely different things.
Lots of people here seem to think that the MOMENTARY high current spike which results from driving the gate of a MOSFET with an Arduino port requires a current limiting resistor. Indeed it does not.
The MOSFETS in the output pin drivers of the AVR have inherent ON resistance. An over current condition simply causes heat to be generated in the MOSFET. The VERY short time that the over current condition lasts due to charging or discharging a few picofarads of gate capacitance will not damage the device in any way. Any heat generated during that brief period is probably too small to even measure.
In fact, DURING the switching from logic high to logic low (or vice-versa), there is a brief period where both the top and bottom "totem pole" driver MOSFETS are conducting at the same time, causing a very brief short circuit across the power supply and a large current spike. This is why devices like the AVR need small but very low ESR and high frequency bypass capacitors across VCC and GND. Obviously, the brief short circuit condition does not hurt the device.
With motor drivers (or any other high power MOSFET controller), it is important to drive the gates with a low impedance source in order to minimize the switching time and therefore minimize the time that the MOSFET is in a partially conducting state. That's why high power MOSFET drivers are used.
With this in mind, using a series resistor between an Arduino and a MOSFET gate is the worst thing to do because it slows down the switching time, leaving the MOSFET in the partially conducting region longer and increasing power dissipation and heat.
It's BETTER to drive the MOSFET gate "hard" by directly connecting it to the AVR digital pin without a resistor.
Concerning the "sarcasm" part of my post, I'm sure you've seen the same few people instantly answer every post (presumably to run up their post counts) and then only write snotty things to the OP. Here are a few that I will look for right now and quote for you:
You don't check that there IS anything to read before reading. Stupid.
Dumb! Local variables with the same name as global variables are virtually never a good idea.
a) Thanks for wasting everybody's time with the TIP120
Try and talk to people who know what they are talking about.
I could go on and on, but I think you get my point. It makes me wonder, why should I go through the bother of trying to properly and politely explain something that the OP clearly doesn't understand and clearly wants to LEARN when terse, cryptic "answers" and sarcasm seem to be acceptable to the moderators?
Even when an answer IS half-helpful, it really isn't. I've seen so many times things like "1K is wrong, use a 220".
Well, fine, but WHY? What's the reason? How is it calculated? What happens if 1K is used? Why?
I've been involved with electronics for over 35 years. I very rarely post a question here, simply because I don't need to. I post here because I find it fun and relaxing to try to help and teach people, in the hope that they will end up loving electronics and having as much fun as I do.
And it REALLY ticks me off to see wannabe "engineers" spout off incorrect information, teach nothing and reply with sarcasm. Why bother? Is it FUN to hurt other people? I don't think it is.
Plus one, Krupski.
Krupski:
The MOSFETS in the output pin drivers of the AVR have inherent ON resistance. An over current condition simply causes heat to be generated in the MOSFET. The VERY short time that the over current condition lasts due to charging or discharging a few picofarads of gate capacitance will not damage the device in any way.
Where does it say that in the datasheet?
Krupski:
a) Thanks for wasting everybody's time with the TIP120
Gee, you really have to throw away a lot of text to get down to that single sentence.