Arduino Forum

Using Arduino => General Electronics => Topic started by: kimkash on Jul 04, 2013, 01:09 am

Title: Transistor types
Post by: kimkash on Jul 04, 2013, 01:09 am
Hi all
I'm new to arduino and getting back to electronics and im trying to learn about
transistors. I want to bu some general purpose type for general logic level use,probably something like 5v triggering voltage and can supply up to 12 volts,no more.
Tried to read some datasheets and get to shit bricks...mumbo jumbo...
Thank you for help!
Title: Re: Transistor types
Post by: larryd on Jul 04, 2013, 01:39 am
These may help:

http://www.jameco.com/webapp/wcs/stores/servlet/StoreCatalogDrillDownView?langId=-1&storeId=10001&catalogId=10001&categoryName=cat_10&subCategoryName=Transistors&category=1070

http://electronicsclub.info/transistorcircuits.htm
http://www.allaboutcircuits.com/vol_3/index.html
http://www.electronics-tutorials.ws/transistor/tran_1.html
http://www.electronics-tutorials.ws/transistor/tran_7.html
Title: Re: Transistor types
Post by: Grumpy_Mike on Jul 04, 2013, 04:34 am
Quote
5v triggering voltage

All transistors are switched on fully when there is 0.7V applied to the base. There is no such thing as a 5V triggering transistor.

Quote
and can supply up to 12 volts,no more.

Transistors do not supply voltage. They can only switch current. You have to supply the voltage and the transistor can in effect switch it on and off. Most simple transistors can switch voltages UP TO 60V. That means they can also switch lower voltages if you supply them.

Quote
Tried to read some datasheets and get to shit bricks

Try reading this:-
http://electronicsclub.info/transistorcircuits.htm (http://electronicsclub.info/transistorcircuits.htm)
Title: Re: Transistor types
Post by: dc42 on Jul 04, 2013, 08:01 am
If you are looking for part number recommendations then BC337 (npn) and BC327 (pnp) are good all-rounders, capable of switching up to about 500mA. I suggest you also invest in some logic-level mosfets. IRLU8726pbf is a favourite of mine.
Title: Re: Transistor types
Post by: fungus on Jul 04, 2013, 11:35 am
BC337 or 2N2222

Remember to put a 330 ohm resistor between Arduino and transistor base.

Title: Re: Transistor types
Post by: scottyjr on Jul 04, 2013, 01:54 pm
Quote
IRLU8726pbf is a favourite of mine.


Why? Is it because it can handle alot of current, has low RDS(on), has a built in snubber diode and is a logic level mosfet? Would you please give your interpretation of the graph of figure 1, page 3 of the data sheet. I think this is where it can be determined if it is a logic level mosfet. Do I read correctly that at a low operating temperature, that the mosfet if fully turned on with Vgs at 5v, when Vds is anywhere above around 2v?

- Scotty
Title: Re: Transistor types
Post by: fungus on Jul 04, 2013, 03:01 pm

Quote
IRLU8726pbf is a favourite of mine.


Would you please give your interpretation of the graph of figure 1, page 3 of the data sheet. I think this is where it can be determined if it is a logic level mosfet.


Either that, or ... the 'L' in the name.
Title: Re: Transistor types
Post by: AmbiLobe on Jul 04, 2013, 03:16 pm
I read the data sheet  for the IRLU8726pbf from Newark's website for International Rectifier:

http://www.irf.com/product-info/datasheets/data/irlr8726pbf.pdf

Figure 1 confirms that, "at a low operating temperature, that the mosfet if fully turned on with Vgs at 5v, when Vds is anywhere above around 2v".

Here are my notes:
The 85 amp limit is awsome.
The Vt threshold voltage is less than 2.5 volts at -55 degrees C. (Fig. 10)
The Reverse Transfer Capacitance is about 10% of the gate capacitance, good.

The Reverse Transfer Capacitance of 205 pF is connected with a 2150pF input capacitance to create a voltage divider. The 9% coupling of drain voltage to gate voltage is good enough for rock and roll. Some devices have 40%, which is not good. Watch that ratio and practice safe specs.
Title: Re: Transistor types
Post by: dc42 on Jul 04, 2013, 04:32 pm
The datasheet quotes a maximum value of Rds(on) at Vgs=4.5v and Id=20A. That means it is good for switching up 20A (subject to thermal considerations) with logic level gate drive. Another reason I like it is that it costs less and takes up less space than most power mosfets, because it is in a smaller package than the usual TO220.
Title: Re: Transistor types
Post by: fungus on Jul 04, 2013, 04:40 pm

Quote
5v triggering voltage

There is no such thing as a 5V triggering transistor.


There is if we include MOSFETs ...
Title: Re: Transistor types
Post by: kimkash on Jul 04, 2013, 08:31 pm
OK...from all your answers comes up some new Q's:
1.) If transistors switched ate 0.7v,then in order to control it with arduino i just need to write to the base leg\pin HIGH value? or is too much  5v for the base to handle?
2.) What is the difference between NPN and PNP? searched Youtube and looked at some videos-couldn't find adequate explanation and the one on Wiki is a little bit complicated for a begginer like me
the one thing i do understand is the one of them is 'switched on'(=connecting the collector and emitter like a switch) when the voltage on the base is high and the second one is switched on when the voltage on the base is low
Title: Re: Transistor types
Post by: larryd on Jul 04, 2013, 08:41 pm
Did you look at:
http://electronicsclub.info/transistorcircuits.htm
http://www.allaboutcircuits.com/vol_3/index.html
http://www.electronics-tutorials.ws/transistor/tran_1.html
http://www.electronics-tutorials.ws/transistor/tran_7.html
Title: Re: Transistor types
Post by: AmbiLobe on Jul 04, 2013, 09:25 pm
1.) If transistors switched at  0.7v,then in order to control it with arduino i just need to write to the base leg\pin HIGH value? or is too much  5v for the base to handle?

npn like 2n2222
Yes. Arduino pin high to resistor 1000 ohms to base of npn transistor. Emitter grounded. Collector to load.

5v is not too much across the 1000 ohm resistor to base. Base is at about 0.8v.
Resistor has about 5.0 - 0.8 = 4.2 volts

2.) What is the difference between NPN and PNP?

npn has emitter grounded
pnp has emitter at 5 volts

npn base at 0mA for off
npn base at 1mA for on

pnp base at -0mA for off
pnp base at -1mA for on

npn collector has voltage above emitter
pnp collector has voltage below emitter

read the links


searched Youtube and looked at some videos-couldn't find adequate explanation and the one on Wiki is a little bit complicated for a begginer like me
the one thing i do understand is the one of them is 'switched on'(=connecting the collector and emitter like a switch) when the voltage on the base is high and the second one is switched on when the voltage on the base is low
Title: Re: Transistor types
Post by: Grumpy_Mike on Jul 04, 2013, 09:58 pm
Sorry for repeating the information in the last post but this might be a bit more palatable packaging of the facts.

Quote
1.) If transistors switched at  0.7v,then in order to control it with arduino i just need to write to the base leg\pin HIGH value? or is too much  5v for the base to handle?

A resistor between the pin and base will make it compatible. The resistor does not reduce the voltage as some beginners think, it limits the current which in turn causes a voltage to be dropped across the resistor. This is not the same thing.

Quote
2.) What is the difference between NPN and PNP?

A PNP is often called an upside down transistor. You use it to switch things on where you need a source of power, that is you switch the positive. This is called current sourcing.

By contrast an NPN transistor switches the negative, it connects the load to ground it provides a sink for the current. This is called current sinking.

Most of the time it doesn't matter if you control something with sinking or sourcing, but occasionally it does. So normally you would use an NPN but if you mush have current sourcing you use a PNP.
Title: Re: Transistor types
Post by: polymorph on Jul 04, 2013, 11:20 pm
Kimkash, I cannot stress enough how important it will be to you to read up on those links that LarryD gave you. There are many kinds of transistors. People generally, but not always, mean Bipolar Transistor when they say Transistor. But it is bad form not to specify, it makes it more difficult for people to help you.

For instance, a MOSFET does not require a resistor between the Arduino and its Gate. However, MOSFETs have a large Gate capacitance so if you are trying to use the PWM Analog output of an Arduino to drive it, you may find it gets hotter than you'd thought as it takes time to turn on and off.

A bipolar transistor does require a current limiting resistor from the Arduino pin to the Base lead. You do need to take Beta (current gain) into account, especially when switching larger currents. Bipolar transistor gain goes down when saturated, so with a rated Beta of 100 you might find that you need 1/20th to 1/10th the current going into the Base.
Title: Re: Transistor types
Post by: fungus on Jul 04, 2013, 11:23 pm

For instance, a MOSFET does not require a resistor between the Arduino and its Gate.


Yes it does, and for the same reason as a BJT, ie. to stop more than 40mA coming out of the Arduino pin.
Title: Re: Transistor types
Post by: Grumpy_Mike on Jul 04, 2013, 11:34 pm

Bipolar transistor gain goes down when saturated,

No?
Title: Re: Transistor types
Post by: AmbiLobe on Jul 05, 2013, 12:10 am
polymorph proposed this advice: "a MOSFET does not require a resistor between the Arduino and its Gate."
The following calculation was done to confirm or refute that advice:
2nF gate capacitance on MOSFET is common (2000pF)

Assume 3.6ns rise time for Arduino output

i = c dv/dt
i is current from Arduino = 2.8 amps

c = 2x10^-9 F
dv = 5 volts
dt = 3.6x10^-9 seconds rise time

rise/fall time 3.6ns for SPI pin Atmega328P data sheet page 321


i = (2x10^-9) x 5 / (3.6x10-9) = 2.8 amp

data sheet

https://www.sparkfun.com/datasheets/Components/SMD/ATMega328.pdf
Title: Re: Transistor types
Post by: polymorph on Jul 05, 2013, 01:46 am
You don't really think an Arduino can source 2.8A, do you?

Look in that PDF, Pg 340, 27.1.8 Pin Driver Strength. In that section, on Pg 341, see the graph Figure 27-24. I/O Pin Output Voltage vs. Source Current(VCC = 5 V). It only tells part of the story, but if you assume that output current sourcing is linear, then with 4.5V @ 18mA of source current, that would extrapolate to about 180mA max in the initial short-circuited state when an uncharged 2nF capacitor is connected and the output is set to High. Since this decays from 180mA (or whatever the short circuit current max is) to 0mA as the 2nF Gate capacitance charges, you'll get a much longer rise time.

This link seems to explain it:
http://joost.damad.be/2012/09/dimming-12v-led-strip-with-mosfet-and.html (http://joost.damad.be/2012/09/dimming-12v-led-strip-with-mosfet-and.html)
Title: Re: Transistor types
Post by: polymorph on Jul 05, 2013, 02:09 am
I should also point out that while you -can- connect many MOSFET gates directly to an Arduino output, it would be a better idea to use a driver circuit. Because the maximum rated current output of an Arduino is 40mA at any one pin, and driving into a 2nF capacitance is going to cause charge and discharge pulses significantly higher than this. Your Arduino may keep working, but that doesn't mean it is a good idea or that it is not damaging it.

We seem to be illustrating my point nicely: Read those links that LarryD posted. There is a lot more to know about transistors than can be imparted in a few posts on a forum.
Title: Re: Transistor types
Post by: polymorph on Jul 05, 2013, 02:21 am


Bipolar transistor gain goes down when saturated,

No?


Perhaps more accurately stated:

If you require 100mA with an NPN bipolar transistor as a saturated switch, with a rated Beta of 100, it would be unwise to drive the Base with only 1mA of current. Beta varies with time, temperature, and from transistor to transistor. So I would always overdrive the transistor a bit.

Again, this goes back to my point that the original poster really needs to check out LarryD's links.
Title: Re: Transistor types
Post by: kimkash on Jul 05, 2013, 02:19 pm
Thank you all for the comments and help,i found what i needed and those links are very helpful for the future!
Title: Re: Transistor types
Post by: BillO on Jul 05, 2013, 05:43 pm


For instance, a MOSFET does not require a resistor between the Arduino and its Gate.


Yes it does, and for the same reason as a BJT, ie. to stop more than 40mA coming out of the Arduino pin.



Not always.  Mostly in high frequency situations (such as PWM, but not limited to this) and only usually with those MOSFETS that have fairly high capacitance gates.  For most situations where you just want switch on and off a device now and then, there is usually no need for a gate resistor.

For instance, the gate capacitance of a 2N7000 is 20pf.  If an AVR could not drive 20pf without using a current limiting resistor they wouldn't be very useful, would they?  The internal resistance of the output circuit of an AVR would be enough to limit the average current into 20pf to under 40ma under almost any imaginable application.

Something like a FQP50N06 might be a whole different story.  With a gate capacitance of about 1200pf you would possibly need a resistor for PWM or other such continuous medium to high frequency applications.  But even it should not require a gate resistor for occasional on/off operation, like turning a relay, motor, solenoid or lamp fully on or off when required.  Taking a look at the specs of the AVR, and given that the output resistance of the AVR is about 25 ohms (at 5V) then the time to charge the gate of the FQP50N06 would be about 30ns.   So, the current would likely never exceed and average of over 40ma for the 30ns.  I guess this could be tested by actually measuring the current into the gate at various frequencies.

One thing I did notice in the ATmega328 specsheet that seems a bit odd.  they quote the clock period correctly at 50ns when running at 20mHz, but say that the clock rise an falls times are 500ns each.  Wouldn't that mean the max clock frequency would be 1mHz?  Odd.  Must be an error.
Title: Re: Transistor types
Post by: fungus on Jul 05, 2013, 06:12 pm

For instance, the gate capacitance of a 2N7000 is 20pf.  If an AVR could not drive 20pf without using a current limiting resistor they wouldn't be very useful, would they?


No, but that's a 2N7000 is a tiny little MOSFET that can't even handle the same current as an average BJT. TO220 size logic-level MOSFETs (the kind most breadboarding people will use) have a capacitance more in the region of 2uF.

As a rule of thumb, in a publicly readable forum where we have no idea what MOSFETs people are going to use, can we pretend that MOSFETs need a current limiting resistor?
Title: Re: Transistor types
Post by: BillO on Jul 05, 2013, 06:14 pm

Assume 3.6ns rise time for Arduino output


Not a good idea.  I'd be loath to assume the SPI outputs are typical as these pins are designed for general SPI compatibility .  Look at the spec for the 2-pin interface.  They are likely more typical (20+ ns).

I wish the Atmel datasheets were a bit more forthcoming with this sort of thing.  For instance, they say that the output current of any I/O pin should not exceed 40ma, but they tell us little else about this.  Is this the continuous rating?  What about 10us pulse?  or a 50ns pulse?  Seeing as the damage likely done by heat build up, what are the other conditions (temperature, voltage, etc...)?
Title: Re: Transistor types
Post by: BillO on Jul 05, 2013, 06:40 pm

No, but that's a 2N7000 is a tiny little MOSFET that can't even handle the same current as an average BJT. TO220 size logic-level MOSFETs (the kind most breadboarding people will use) have a capacitance more in the region of 2uF.

As a rule of thumb, in a publicly readable forum where we have no idea what MOSFETs people are going to use, can we pretend that MOSFETs need a current limiting resistor?


2uF? Not likely, maybe 2nF.

There are all sorts of MOSFETs available, yeah, the IRL540 has a gate capacitance in excess of 2nF, but in my personal estimation the IRL540 is pretty easy to beat in the spec department for most of the projects the Arduino is likely to be used for.  Like the FQP50N06.  There are even better still.  Also, the 2N7000 is plenty useful.  It seems ridiculous to use an IRL540 to switch a 120 ma load when a 2N7000 will do it for hugely less money and take up way less space, but I digress.

I do see your point, but I think it is better to get folks used to reading spec sheets and using a little common sense about their designs, no?

I see it all the time on the internet.  People learn simple rules of thumb and go around wielding them like swords of truth.  Like the fable that to properly drive a BJT into saturation you need IBE=ICE/10.  I may be one of a few, but I do believe that it's better to use the right device for the job and try to get the most you can out of it.  After all, driving thumb tacks with sledge hammers might indeed work most of the time, but not always, and it's probably never even close to ideal.

So, yes, I think we should tell people in a publicly readable forum that MOSFETs do not always need gate resistors, because that is correct.
Title: Re: Transistor types
Post by: fungus on Jul 05, 2013, 06:55 pm

2uF? Not likely, maybe 2nF.


(looks in box...)

IRL540 - 2.2uF
HUF76137P3 - 2.1uF
RFP30N06LE - 1.3uF    (very low for a logic-level MOSFET)

etc.
Title: Re: Transistor types
Post by: BillO on Jul 05, 2013, 07:07 pm
(shakes head...)

Sorry, but I think there is a problem with your math.  When is 2,200pF = 2.2uF?

1uF =10-6F
1nF = 10-9F
1pF = 10-12F

1000pF = 1nF = 0.001uF
Title: Re: Transistor types
Post by: polymorph on Jul 05, 2013, 07:11 pm
I agree with BillO. Rules of Thumb are only useful in a very narrow range of circumstances, and the basic principles still need to be understood so that you know where and when they can be applied.

Which goes back to: Read LarryD's links.
Title: Re: Transistor types
Post by: fungus on Jul 05, 2013, 07:46 pm

(shakes head...)

Sorry, but I think there is a problem with your math.  When is 2,200pF = 2.2uF?


Oh, you're right. Duh!

It did seem a bit large when I was typing it.
Title: Re: Transistor types
Post by: polymorph on Jul 05, 2013, 08:55 pm
As far as using "add a resistor to drive a MOSFET Gate" rule-of-thumb, if you are using this with PWM, you'll make MOSFET heating even worse by extending the time spent in the linear region.
Title: Re: Transistor types
Post by: 1ChicagoDave on Jul 05, 2013, 09:47 pm

polymorph proposed this advice: "a MOSFET does not require a resistor between the Arduino and its Gate."
The following calculation was done to confirm or refute that advice:
2nF gate capacitance on MOSFET is common (2000pF)

Assume 3.6ns rise time for Arduino output

i = c dv/dt
i is current from Arduino = 2.8 amps

c = 2x10^-9 F
dv = 5 volts
dt = 3.6x10^-9 seconds rise time

rise/fall time 3.6ns for SPI pin Atmega328P data sheet page 321


i = (2x10^-9) x 5 / (3.6x10-9) = 2.8 amp

data sheet

https://www.sparkfun.com/datasheets/Components/SMD/ATMega328.pdf


The most common error in calculating gate current is confusing the MOSFET  input  capacitance,  CISS,  for  CEI  and  applying  the equation....

I = C(dv/dt)

to calculate the required peak gate current. CEI is actually much higher, and must be derived from the MOSFET manufacturer's total gate charge, QG, specifications.

The  total  gate  charge,  QG,  that  must  be  dispensed  into  the equivalent gate capacitance of the MOSFET to achieve turn-on is given as:

QG = QGS + QGD + QOD

where:
QG is the total gate charge
QGS is the gate-to-source charge
QGD is the gate-to-drain Miller charge
QOD is the "overdrive charge" after charging the Miller capacitance.

You'll notice by examining curves in datasheets that in order to achieve strong turn-on, a VGS well above that required to charge CEI (and well above VGS(TH)) is often required. The equivalent gate capacitance is determined by dividing  a  given VGS  into  the  corresponding  total  gate  charge. The required gate drive current (for a transition within a specified time) is  determined  by  dividing  the  total  gate  charge  by  the  desired transition time.

In equation form:

QG = (CEI)(VGS)

and

IG = QG/t(transition)

where:
QG is the total gate charge, as defined above
CEI is the equivalent gate capacitance
VGS is the gate-to-source voltage
IG is the gate current required to turn the MOSFET on in time period t(transition)
t(transition) is the desired transition time

Also, many MOSFET's total transition times are much greater than Arduino's "3.6ns rise time". A few I have are closer to 20+ ns. And have QG values from 15-50 nC at 5-10v. Using those numbers...

IG = QG / t(transition)
IG = 15nC / 20ns = 15C / 20s
IG = 0.750 A = 750mA = still more than Arduino could (safely) source at once.

The moral of the story --
I dunno? Always check your DATASHEETS?

The end.
Title: Re: Transistor types
Post by: dc42 on Jul 05, 2013, 09:56 pm

As far as using "add a resistor to drive a MOSFET Gate" rule-of-thumb, if you are using this with PWM, you'll make MOSFET heating even worse by extending the time spent in the linear region.


Only if you are using a combination of high pwm frequency (in which case you should definitely use a series resistor when driving a power mosfet) and too high a value series resistor. If a 100 ohm series resistor is too high to let the mosfet run cool, then you should be using a mosfet driver chip.

The rule of Ib=Ic/10 to saturate a bjt is a reflection of the fact that for most bjts, the datasheet doesn't guarantee that you can get a low saturation voltage with anything less, because Vce(sat) is quoted at that ratio and hfe is quoted at a relatively high Vce such as 10V.
Title: Re: Transistor types
Post by: BillO on Jul 05, 2013, 09:57 pm
Quote
IG = 0.750 A = 750mA = still more than Arduino could (safely) source at once.


The AVR output resistance is about 25 ohm.  It will never pass more than 200ma, even into a short.
Title: Re: Transistor types
Post by: BillO on Jul 05, 2013, 10:14 pm

The most common error in calculating gate current is confusing the MOSFET  input  capacitance,  CISS,  for  CEI  and  applying  the equation....

I = C(dv/dt)

to calculate the required peak gate current. CEI is actually much higher, and must be derived from the MOSFET manufacturer's total gate charge, QG, specifications.

The  total  gate  charge,  QG,  that  must  be  dispensed  into  the equivalent gate capacitance of the MOSFET to achieve turn-on is given as:

QG = QGS + QGD + QOD

where:
QG is the total gate charge
QGS is the gate-to-source charge
QGD is the gate-to-drain Miller charge
QOD is the "overdrive charge" after charging the Miller capacitance.

You'll notice by examining curves in datasheets that in order to achieve strong turn-on, a VGS well above that required to charge CEI (and well above VGS(TH)) is often required. The equivalent gate capacitance is determined by dividing  a  given VGS  into  the  corresponding  total  gate  charge. The required gate drive current (for a transition within a specified time) is  determined  by  dividing  the  total  gate  charge  by  the  desired transition time.

In equation form:

QG = (CEI)(VGS)

and

IG = QG/t(transition)

where:
QG is the total gate charge, as defined above
CEI is the equivalent gate capacitance
VGS is the gate-to-source voltage
IG is the gate current required to turn the MOSFET on in time period t(transition)
t(transition) is the desired transition time

Also, many MOSFET's total transition times are much greater than Arduino's "3.6ns rise time". A few I have are closer to 20+ ns. And have QG values from 15-50 nC at 5-10v. Using those numbers...

IG = QG / t(transition)
IG = 15nC / 20ns = 15C / 20s
IG = 0.750 A = 750mA = still more than Arduino could (safely) source at once.

The moral of the story --
I dunno? Always check your DATASHEETS?

The end.



A little plagiarism there?  Oh well, who's to know anyway.
Title: Re: Transistor types
Post by: Grumpy_Mike on Jul 05, 2013, 11:37 pm

Quote
IG = 0.750 A = 750mA = still more than Arduino could (safely) source at once.


The AVR output resistance is about 25 ohm.  It will never pass more than 200ma, even into a short.


Not true I got over 270mA when I tested it and not even a short
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html (http://www.thebox.myzen.co.uk/Tutorial/LEDs.html)
Title: Re: Transistor types
Post by: BillO on Jul 05, 2013, 11:39 pm
Well, that's strange.  It's not what the graphs tell.

Update:

The graph shows 5V @ 0ma and 4.475V @ 20ma.

Since output resistance is given by Ro = <delta>Vo / <delta>Io  we get:

Ro = 0.525 / 0.02 = 26.25 ohms

I also notice that if we just look at the beginning of the curve we have

Ro = 0.125 / 0.005 = 25 ohms

And if we look at the last part of the curve we have

Ro = 0.145 / 0.005 = 29 ohms

So, according to the specsheet, the Ro actually rises as Io increases, which is exactly the behavior we would expect from a pull-up consisting of a small resistor and a teensy MOSFET, which is exactly how the AVR pin is configured for output.

Grumpy_Mike, are you suggesting the specsheet is wrong?
Title: Re: Transistor types
Post by: BillO on Jul 06, 2013, 12:54 am
Well,  I just tried this with one of my ATmega328's on pin 8.

I modified blink to turn pin 8 on for 3 seconds then off for 3 seconds, then I used a mA meter with an internal input resistance of 6.1 ohms and placed it directly across pin 8 and ground.  I measured a peak of 82.1 mA while pin 8 was high.

So we have:

Io = Vcc / (Ro + Rm),  where Rm is the resistance of the meter and Ro is the output resistance of the AVR.

We can rearrange that to get:

Ro = (Vcc / Io) - Rm = (5 / 0.0821) - 6.1 = 54.8 ohms

Which agrees well with what is predicted by the curve in the specsheet.  I have a lower resistance ammeter (0.3 ohms with test leads), but it has less resolution.  I'll give that a check and update this post, but I suspect the AVR will not pass much more than 100mA.

Update:  The verdict is 88mA max into a short (well, .3 ohms).  Which means the AVR's internal resistance tops out at

Ro = (5 / 0.088) - 0.3 = 56.5 ohms
Title: Re: Transistor types
Post by: polymorph on Jul 06, 2013, 02:34 am


As far as using "add a resistor to drive a MOSFET Gate" rule-of-thumb, if you are using this with PWM, you'll make MOSFET heating even worse by extending the time spent in the linear region.


Only if you are using a combination of high pwm frequency (in which case you should definitely use a series resistor when driving a power mosfet) and too high a value series resistor. If a 100 ohm series resistor is too high to let the mosfet run cool, then you should be using a mosfet driver chip.

The rule of Ib=Ic/10 to saturate a bjt is a reflection of the fact that for most bjts, the datasheet doesn't guarantee that you can get a low saturation voltage with anything less, because Vce(sat) is quoted at that ratio and hfe is quoted at a relatively high Vce such as 10V.


Yes! Exactly the point, you must first understand much more before applying a rule of thumb, in order to understand where it is and isn't appropriate.

For instance, for a quick-and-dirty circuit using generic BJT transistors (2N2222, 2N3904, 2N3906, etc.), I liberally apply the Ib = Ic/10 or 20 rule-of-thumb. For a final circuit, I use known transistors and read the datasheet.
Title: Re: Transistor types
Post by: Grumpy_Mike on Jul 06, 2013, 07:26 am
Quote
Grumpy_Mike, are you suggesting the specsheet is wrong?

The data sheet is right, you are interpreting it incorrectly.
That is a specification, that is worst case, not what you get.
As the pin is on for so long there is probbly a heating effect limiting your current. My measurements were done with rapid pulses.
Title: Re: Transistor types
Post by: fungus on Jul 06, 2013, 11:21 am
What happens if you connect 8 MOSFETs to a port (ie. 8 pins) and turn them all on simultaneously? With no resistors there's part of the chip with (maybe) one amp going through it. That's going to hurt the chip eventually even if it's only for a microsecond at a time. In a PWM controller that microsecond might be hundreds of times per second.

(And that's without getting into the decoupling problems it would cause).

And don't think this doesn't happen ... I wrote a software PWM for last year's Xmas tree. Every PWM cycle started with "PORTB=0xff" to turn all the lights on.

And before you start with "You could turn them on one at a time in sequence!", remember that the real problem is in posting "MOSFETs don't need resistors" in public forums. If you start arguing technical exceptions to rules then pretty soon we're back to "LEDs don't need resistors!" (in the eyes of the public).
Title: Re: Transistor types
Post by: BillO on Jul 06, 2013, 12:46 pm

The data sheet is right, you are interpreting it incorrectly.
That is a specification, that is worst case, not what you get.


No, I'm not.  I know how to calculate internal resistance.  

I also used a scope.  There were no "heating effects" observed.  Pfffft... What a ridiculous thing to say.  The fact is both MOSFETs and normal resistors actually conduct more when heated!

However, I do not want to argue.  If you want to believe what you believe, then go right ahead.  Everyone, including yourself, that wishes to repeat the experiment can.  I did, with several chips and got the same result.  That result agrees with the datasheet.  

Quote
"MOSFETs don't need resistors"

@fungus.  I'm not sure I know what you are talking about.  I said that MOSFETs don't always need resistors, not that you should never use resistors.   The needs of MOSFETs and LEDs are nearly opposite.  MOSFETs need arbitrarily high current drivers while LEDs need current limiting drivers.  The fact is, both of these needs are best accomplished by means other than just series resistors, but resistors sometimes suit our needs even if they are not ultimately the right way to go.

As I am fond of saying, the facts just don't care if you ignore them.  It turns out, neither do I.
Title: Re: Transistor types
Post by: fungus on Jul 06, 2013, 01:35 pm

@fungus.  I'm not sure I know what you are talking about.  I said that MOSFETs don't always need resistors, not that you should never use resistors.


I'm saying that when you post in public forums where people even know the difference between a BJT and a MOSFET, let's pretend that they always need resistors.

Because:
a) It's a good habit to get into
and
b) It's 99.99% likely to be the correct thing to do (and the 0.01% of cases where it isn't, you're probably better off with a MOSFET driver anyway...)
Title: Re: Transistor types
Post by: BillO on Jul 06, 2013, 04:38 pm

That is a specification, that is worst case, not what you get.


One more note on this.  I was just going through the ATmegaXX8 specsheet again this morning and just noticed that the part of the specsheet that has the Vo / Io graphs is entitled "Typical Characteristics".
Title: Re: Transistor types
Post by: pwillard on Jul 06, 2013, 06:22 pm
Datasheets provide "nominal" operating conditions so that some lazy peon who loosely designs something... might actually gets his "appliance" to work reliably every time.   Using the experiment approach to dispute datasheets might be slightly educational, but I understand what G M is saying.  While it may not be specifically "heating" causing damage as described, consistently exceeding datasheet nominal values, without taking the time to design a circuit properly... as is common with someone new, will most likely result in a forum thread titled "I think I burned a pin... now what do I do?"  

Using a 2 cent resistor can prevent this... I would say, as does Grumpy Mike, that you use caution first... and then when you know what you are doing and can prove to yourself on your own you don't need a "component"... remove at will.   For now...  with a standard small signal BJT, use a 1K ohm resistor... with a mosfet, use 150 Ohm.  remove it when you can prove to yourself you don't need it.

Blindly taking some advice to leave out a component designed to "protect" your design when you don't understand the reasons it's there, has a high probability of having you replace a UNO or ATMEL 328 because you didn't insert a part that costs 2 cents.  
Title: Re: Transistor types
Post by: BillO on Jul 07, 2013, 06:20 am

Blindly taking some advice to leave out a component designed to "protect" your design when you don't understand the reasons it's there, has a high probability of having you replace a UNO or ATMEL 328 because you didn't insert a part that costs 2 cents.  


Well, I think this thought comes close to what I am saying.  I'm not sure how that was missed.  What I am saying is, try to fully understand what it is you are doing and don't blindly take any advice.

There is a lot of misinformation passed out on this site, and many, many others, that propagate ignorance under the umbrella of "it's safe" when indeed that just obfuscates the reality.

In any case, you may have missed, or misunderstood, the entire thread because I'm not asking anyone to blindly do anything.  Where the heck are you getting that?.  We initially talked about whether it is required that you use a resistor every time you use a MOSFET or not, but it went a little beyond that.  From my perspective, as one of the contributors so far, it edged toward the behavior of the AVR and how that would affect the original thesis, then to just how the AVR behaves.  A lot of ground covered.  And over none of it did I advise anyone to blindly do anything.  In fact, I strongly suggested that folks open their eyes.  Maybe this is the remedial forum.

In any case, we are talking about a device that cost's less than a bottle of beer.  WTF!  If, and it's a big if (because I just shorted out pin 8 on 3 different 328s and it did not even affect their internal resistance characteristics, and no, no, no, I'm not saying it's the right thing to do), you demolish one by being brave or inquisitive, what the hell is the big deal?  The lack of testicles amongst the Arduino fold is astonishing!  So, because you partially or totally disable a $4 chip your going to just tear your life apart?  Get over it, for Pete's sake!  Have one less McDouble next week and carry on your exploration.

However, that is not even the point.  It's the whole attitude.  "Man, don't ever do that because I heard from some one in another post (or on another site) that that is a no no.".  Shinola!!! You should at least have tried it to know if it is fact or fiction, or try to educate yourself about the basics and put the BS aside.

In this thread I did.  What I found in what I tried was that the common sludge is just hokem fiction.

What are we afraid of?  That some MCU deity will strike us dead for threading on sacrosanct ground?  Or loosing a $4 part?  Well, I'm here to tell you this is not going to happen.  Yeah, you can destroy a ATmega328 if you try really hard, but it ain't all that easy and it ain't the end of the world either if it happens.

Okay, so here are the facts.  88mA is all I could get out of an (actually several, and BTW, I'm not the only one. Google it or try it.) AVR output, that means it will take more time than previously assumed to charge a MOSFET to the point where it operates properly, and as such it changes the nature of the "story" that has been propagated so far.  It's up to you if you want to use this information.  I really couldn't care less.

I know, I know, they hang or burn people for this sort of blasphemy.  So please, just ignore me.  I have no idea what I'm talking about.  None whatsoever.  Please, go on as you were.   I'm sure the experts here will have many like reasons to attack my responses in the future, no matter what they are based on, or how they misinterpret them, so I'll try to repent.  I've seen the light... I'll try to be a good boy and not say anything that disturbs the sacred beliefs.  LF!

You folks kill me. :-)

The fact still remains, you do not always need a gate resistor on a MOSFET
Title: Re: Transistor types
Post by: retrolefty on Jul 07, 2013, 06:48 pm
Quote

The fact still remains, you do not always need a gate resistor on a MOSFET


I can live with that statement. I frequently use small 2N7000 mosfets for switch smaller loads and never use a series gate resistor with them. But I'm also aware that there are applications of using very high current mosfets where anything short of using purpose designed gate driver chips is very risky. In between there are situations where a series gate resistor wired directly to an arduino output pin is the best method.

I think you main point is that unless one actually learns fundamental electronics theory and practice including semiconductor theory for themselves, but rather instead relies on memorizing a lot of 'rules' posted by random people, then you will always be at the mercy of randomly useful information and yes even wrong information.

http://xkcd.com/386/

Lefty
Title: Re: Transistor types
Post by: BillO on Jul 07, 2013, 09:07 pm
Thanks Lefty, you sate my intentions far more eloquently than I did.  You're right on the button.

Not to belabor this too much, but I tried to recreate some of the results found here: http://www.thebox.myzen.co.uk/Tutorial/LEDs.html (http://www.thebox.myzen.co.uk/Tutorial/LEDs.html)

I did not have a 10R or 4R7 but did have 7.5R 1%.  I measured the resistor with a Fluke DMM and it measured at exactly 7.5 ohms.  The results presented at that site would imply that I should see a current of approximately 200mA with the 7.5 ohm resistor.

I soldered the resistor to a green LED and two short leads to ensure the circuit had the best possible connectivity and to reduce the possibility of bad connection on a bread board creating higher than actual resistances.  I used the circuit shown on the site with the resistor between the LED and ground.

I wrote a small sketch to output  a 500Hz square wave loaded it up to a brand new ATmega328,  I initially did this on pin 9 and connected the lead from the anode of the diode to pin 9 and the lead from the resistor to ground.  Then I attached a scope across the resistor as shown to measure the voltage across the resistor.  Here are my results.

The voltage across the resistor, when the output was high, was 284mV.  This implies the current through the circuit was 37.9mA.  Not any where close to 200mA.

I did a little further digging to see if any of this made sense with respect to the "Typical Characteristics" section of the 328 data sheet and the LED.  I measured the voltage coming from pin 9 to be at 3.88V when the output was high.  This meant there was 3.6V drop cross the LED, which is in line with green LED voltage drops at such currents (~40mA).

Given that the current calculated was Io = 37.9 and Vo = 3.88, this implies the output resistance of the 328 was (5-3.88) / 0.0379 =  29.6 ohms.

Looking at figure 29-162 of the ATmegaXX8 data sheet we see that at 20mA the ATmega328's output is expected to fall to around 4.48V.  We can also do calculations from the graphed values to determine the output resistance as the current increases.  We find it is about 25 ohms at 0-5 mA and about 29 ohms at 15-20 mA.  Leading us to two follow-on conclusions:

1) The output resistance increases as the current increases.  For the design of the output, this is expected behavior, implying that it would even be higher at 37.9 ma.  I measured 29.6, so this is in agreement.

2) Consequently we'd expect that if the output voltage drops .52V in the first 20 mA of load, it will drop measurably more than that in the following  20 mA of load.  What we find is that at 37.9 mA the voltage has dropped by 1.12V.  This too then, is in agreement.

I tired 2 different chips, and pins 0 to 9 on both of them.  The results all agreed to within 0.2mA.

Conclusion:  This experiment shows that an ATmega328 driving a green LED trough a 7.5 ohm resistor will pass a current of approximately 37.9 mA and that this agrees with what is presented in the ATmega328 datasheet.  It also shows that a previously predicted current of 200 mA was not observed.  This too agrees with the published datasheet.

It should also be noted, that while the current of 37.9 was 17.9 mA in excess of the LEDs recommended operating current, it was a peak current and did not exceed the maximum allowable for the ATmega328.  In fact, the average current of approximately 19ma is well in line with the safe area of both devices.


So, how does all the relate to the OP?  If you are going to delve into electronics, it pays to learn how to read the datasheet of the devices you use, understand the basics of how they work and  become familiar with the governing principles of electronics as anything else is really the mumbo jumbo.



Title: Re: Transistor types
Post by: Grumpy_Mike on Jul 08, 2013, 05:50 pm
Quote
Conclusion:  This experiment shows that an ATmega328 driving a green LED trough a 7.5 ohm resistor will pass a current of approximately 37.9 mA and that this agrees with what is presented in the ATmega328 datasheet.

Fair enough.

Quote
It also shows that a previously predicted current of 200 mA was not observed.

First off that was not a predicted current it was actually measured.

So basically do you think I made some sort of error in the measurements or setup or are you suggesting I made the whole thing up?

I noticed that you did not duplicate exactly what I did, which on re reading the page I see I did not explain in full detail.
I drove the LED through a PWM pin and set the PWM value to 1 giving the LED only a short pulse. It was also a yellow LED so that voltages would have been a bit different. I used a $5000 Tectonicx scope with X10 probes. Unfortunately I don't work for that company anymore so I don't have access to that equipment. However I will try and repeat the experiment, in the light of what you found and if necessary correct the web page.
However the whole point of that page is that you always need a resistor when driving an LED from an arduino pin ( or constant current supply ) which i am sure you will not disagree with. 
Title: Re: Transistor types
Post by: BillO on Jul 08, 2013, 07:46 pm

Quote
It also shows that a previously predicted current of 200 mA was not observed.

First off that was not a predicted current it was actually measured.


It was predicted in my case from your results because a value of 7R5 was used by me, which was not a value recorded in the original experiment.

Quote
So basically do you think I made some sort of error in the measurements or setup

Possibly, I am not sure.  I tried to conduct the experiment as you have explained in your write-up.

Quote
or are you suggesting I made the whole thing up?


No, that is never done.  The largest component of my job as an experimental physicist was to set up and run experiments that were original work done by others in order to see if the results are repeatable.  This is never intentionally done to ferret out false results.  It is generally a welcome practice as it helps the creator of the original work perfect his hypothesis and methods and reduce errors.  Generally speaking, if an experimental result is important enough it may get repeated 5 or more times by others.  There are invariably adjustments made to the original methods, but this process of test and improve is what experimental research is all about.  In the cases where I did do original work, as soon as I had my first results I would be on the phone to other physicist to ask them to repeat my work for verification.  Cases where this is not done, and they do happen, can result in spectacular failures.  Do you recall cold fusion?

Quote
I noticed that you did not duplicate exactly what I did, which on re reading the page I see I did not explain in full detail.  I drove the LED through a PWM pin and set the PWM value to 1 giving the LED only a short pulse. It was also a yellow LED so that voltages would have been a bit different. I used a $5000 Tectonicx scope with X10 probes.


I use a Textronics 465 analog scope along with a UNI-T 100mHz digital scope and well as various DMMs from Fluke and others.  Though I don't think it would matter too much, for our purposes, if we used Eico or Rigol, etc...  A mV or 2 here or there is fine for hobbyist work.  If I have the time I'll try it with your additional info.  The basic set-up is still on my bench.  Being retired, you'd think I'd have more time, but...

Quote
...you always need a resistor when driving an LED from an arduino pin ( or constant current supply ) which i am sure you will not disagree with.  


Yes, I fully agree with this.
Title: Re: Transistor types
Post by: BillO on Jul 10, 2013, 09:15 pm
Okay,

My guests left this morning so I had a chance to get back to this.

Here are the changes I made:
LED was changed from Green to Yellow
Used PWM and set analogWrite to 1

Since the 7R5 is the lowest value resistor I have, it was used again.

Here is the Code I used:
Code: [Select]

/*
  PWM current test
  Turns an Yellow LED on for 8us then off at 490Hz
*/
int OutPin=9;

void setup() {               
  // initialize the pin as an output.
  // Pin OutPin is connected to a Yellow LED then to a 7R5 resistor to ground
  pinMode(OutPin, OUTPUT);
}

void loop() {
  analogWrite(OutPin, 1);
}


Here are my measurements:
Frequency - 490Hz
Pulse width - 8uS
Voltage across the resistor - Vr = 518mV
Output Voltage @ OutPin - Vo = 2.74V
Vcc = 4.92V

Here are my calculations:
Output current Io = Vr / R = .518 / 7.5 = 69.1mA
Voltage drop across LED VD = Vo - Vr = 2.74 - .518 = 2.22V
Internal resistance of ATmega378 Ri = (Vcc - Vo) / Io = (4.92 - 2.74) / 69.1 = 31.5 ohms

The average current draw from the Arduino was 69.1mA * 8uS / 2037uS = 0.27mA and the LED was just barely lit.