Myth Busters 3 – Myth: “You must have a gate resistor”

I see it all the time, especially on this site, those “in the know” telling people they must always use a gate resistor when driving a MOSFET from an Arduino. The reason they give is that you need to do this to prevent more than 40mA being sourced by the ATmega328.

This has always seemed very odd to me. I mean, it's been painfully obvious to me that those “in the know” have never tried to verify this, because in my experience it’s simply just not been true. The really troubling thing is, who started this myth? Where did it come from? Did anyone ever actually do an experiment to see if it is true? Or are all those “in the know” just a bunch of lemmings?

I get called out a lot on this site for crossing sacred boundaries. Yeah, I guess I’m a rogue, but my background as an experimental physicist does not allow me to just believe everything I hear or see written down. I tend to actually do the math, or where facts and formulas are not available, do the experiment.

Up until now, I have to admit, I have not really put this myth to the test myself, but today I did. Let’s see what I found.

First a little background. Take note of two things taken from the latest version of the AtmegaXX8 datasheet on the Atmel web site, section 31. The opening page states the following:

“The current drawn from capacitive loaded pins may be estimated (for one pin) as CLVCCf where CL = load capacitance, VCC = operating voltage and f = average switching frequency of I/O pin.”

This formula should actually come as no surprise to anyone that knows even a little electronics, but I'm not convinced it's going to work well with pulses. There is also a graph labeled “Figure 31-355” in that section that is entitled “I/O Pin Output Voltage vs. Source Current (VCC = 5V)”. This is far more pertinent. We’ll use these two snippets in our investigation with the minor adjustment to the graph for our actual Vcc.

What I did:
I got 4 MOSFETs, 3 logic level - 2N7000, IRLZ24N, FDP8880, and 1 non-logic level – IRFZ20. I drove each of these directly off pin 9 of a ATmega328P without a gate resistor via PWM using the following code:

/*
  PWM
  Drive the gate of a MOSFET directly off OutPin.
 */
int OutPin=9;

void setup() {                
  // initialize the pin as an output.
  pinMode(OutPin, OUTPUT);
}

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

Each of the large MOSFETs were subject to both 16 ohm and 6 ohm drain loads and different pulse widths were tested. The 2N7000 was subject to a 47ohm drain load.

Let’s take a look at the biggest of these MOSFETs and use that first snippet to estimate the load in driving its gate to see if that might be where the myth came from. Qg(tot) is given as a fairly hefty 29nC. At 5V that’s roughly equivalent to 5.8nF. The PWM frequency of the Arduino is normally 500Hz, so with 50% duty cycle the average current draw can be estimated at 55005.8nF = 0.015mA. Well, that’s certainly not a lot is it? It doesn’t sound like it would hurt a flea, let alone an ATmega328. It’s pretty obvious that those “in the know” never did that calculation, eh? Well, it doesn't look right to me either and would only work with a sinusoidal wave form anyway, which we don't got here. Okay, rules of thumb be dammed. Let’s see what really happened.

Our Vcc measured at 4.96V

VGSon and VDSon are measured during the pulse. Timings are to 90% of final value.

2N7000 – RL= 47 ohms

PW		Vgson		Rise Time	Vdson		Ton
8uS		4.92V		52nS		244mV		48ns
256uS		4.92V		52nS		240mV		48nS
1024uS		4.92V		52nS		224mv		48nS
2000us		4.96V		52nS		216mV		48nS
100%		4.96V				216mV

Worst case was VGSon = 4.92 which is a drop of .04V from Vcc, according to the graph. This relates to about 1mA according to the graph, or about .5mA at 50% duty cycle. The myth is totally busted when it comes to a little 2N7000. No gate resistor needed!!!

IRLZ24N – RL = 6 ohms

PW		Vgson		Rise Time	Vdson		Ton
8uS		4.80V		128nS		400mv		118nS
256uS		4.80V		128nS		400mv		118nS
1024uS		4.84V		128nS		398mV		118nS
2000uS		4.88V		128nS		395mV		118nS

RL=16 ohms

PW		Vgson		Rise Time	Vdson		Ton
8uS		4.84V		108nS		280mV		86nS
256uS		4.84V		108nS		280mV		86nS

Worst case VGSon = 4.8V, implies a drop of .16V from Vcc, implies a peak current of about 5ma. At 50% duty cycle we are little better and would have an average of about 2.4mA. Again, the myth is totally busted. You don’t need any gate resistor with this one either, not even with PWM!!!

Okay, now for a pretty big MOSFET, the FDP8880
RL=6 ohms

PW		Vgson		Rise Time	Vdson		Ton
8uS		4.84V		260nS		168mV		232nS
256uS		4.84V		260nS		168mV		232nS
1024uS		4.84V		260nS		168mV		232nS

RL=16 ohms

PW		Vgson		Rise Time	Vdson		Ton
8uS		4.88V		232nS		108mV		152nS
256uS		4.88V		232nS		108mV		152nS
1024uS		4.88V		232nS		108mV		152nS

Worst case VGSon = 4.84V, implies a drop of .12V from Vcc, implies a peak current of about 4.5ma. At 50% duty cycle we would have an average of about 2.5mA. Yet again, the myth is totally busted. You don’t need any gate resistor with this one either!!!

I even tried (quickly) a non-logic level MOSFET a IRFZ20, and it worked surprisingly well!
RL=6 ohms

PW		Vgson		Rise Time	Vdson		Ton
256uS		4.80V		244nS		400mV		200nS

RL=16 ohms

PW		Vgson		Rise Time	Vdson		Ton
256uS		4.82V		212nS		240mV		156nS

You guessed it, busted again.

So there we have it, the myth is just that, a myth and totally ungrounded in fact. Even if all the measurements were off by a factor of two, the fact is, you can run any reasonably sane logic level MOSFET directly off the pin of and Arduino till the cows come home, PWM or not. Where this myth came from is anyone’s guess, but if you believe in it, you have my pity.

For small mosfets it is not really necessary, especially if you are switching at low speeds.

However...

I designed a data transfer circuit at one point in which a single output had to drive 30 input CMOS gates with a combined gate capacitance of around 200pF (measured, not theoretical). The switching frequency was around 8MHz.

(the following is muchly simplified math to show a point).

Given Xc = 1/(2Pi * f * C)

Then Xc in this case was: 100Ohms.

I = V/Xc = 5/100 = 50mA

So on average a current of 50mA was required to drive the circuit

So attempting to drive this just resulted in a noisy impossible to use signal. It took a buffer capable of sourcing up to 1A to be able to get nice square clock edges. You will notice that a square wave is made of many harmonics, with really up to the seventh being required to see a square wave, so actually the frequency is more like 60MHz which yields Xc=13Ohm, or I = 400mA being required.
Attached are some oscilloscope traces of the same signal on the same line being driven with and without a buffer.

In power applications, gate capacitances of >100pF are not uncommon, nor are high switching speeds. Clearly you can't just connect an unbuffered/unprotected output in these situations.

You tested 4 MOSFETs, in a small handful of tests with a PWM frequency of 500Hz. There are THOUSANDS of MOSFETs out there, and 500Hz is nothing for switching.
Perhaps in more hobby/arduino type applications, the resistor is unnecessary. But in much larger applications such resistors and even separate buffers become a must. Good practice can hardly be considered "Busted"

Unbuffered.png

Buffered.png

I used pulse widths as low as 8uS, that represents an extremely high frequency. In fact, not int the tables was a run on the FDP880 using 62,500 Hz with 50% duty cycle, the results were the same as the 8uS pulse.

The MOSFETs used are representative of the spectrum of logic level MOSFETs from small to fairly large.

Yes, I only drove 1 MOSFET at a time, not 30.

Your calculation for current is wrong. The ATmega328 has a minimal internal resistance of 25 ohms and it goes up from there to about 40 ohms at 40ma. The most current you can draw from the pin of an ATmega328P is about 88mA into a short.

Why don't you find yourself a logic level MOSFET, do the experiment. Bring back some results that refute mine.

This was more my point. In any case, if you going to drive 30 MOSFETs at 8mHz, you'd better off with an active driver, not a resistor.

I just did a simulation, and with a 0-5 V 1nS step, and a Ciss of 1000 pF a 1 ohm resistor causes a peak current of 3A! 150 ohms tames that to 33 mA, so it looks to me that the resistor is a good idea.

BillO:
This was more my point. In any case, if you going to drive 30 MOSFETs at 8mHz, you'd better off with an active driver, not a resistor.

You're right of course that an active buffer is required in this case, but it was just an extreme example. Even with single transistors switch much slower (say the 100kHz region as in many switching regulator circuits) you will find there are large peak currents when switching even if the average current is tiny.
I think my point in the end was, it can't hurt to use one. If you are sure in your application it is not needed, then of course don't use one, but if in any doubt, put one there and you won't find any nasty surprises. An in switching circuits always remember that the peak current is much higher than average (I=CVf is a highly unhelpful formula if not a tad inaccurate).

I had actually wondered why whenever I saw someone post "Hey, you should install a series resistor with that MOSFET" I was wondering why. Thanks for your explanation. Can someone explain to me exactly what the danger is beyond "Drawing more than 40mA from the uC?" What condition is producing this relatively large current?

The reason I ask is when I was in school, we worked with MOSFETs as having an enormous impedance on their gates. However, as I have learned, this is only the case at DC. I've been working with high power electronics (Though I am in no means an authority on the subject), where we use high power MOSFETS and IGBTs (Basically think of it as a MOSFET that drives a BJT and giving a lot of the benefits of both), and we do add a gate resistor on those (also in part due to the driving chip). However, that is because we are driving our circuit in the 100kHz range, and it is even more a concern if you are working in the MHz or GHz ranges, as the gate becomes a capacitor to ground (When Frequency goes Up, impedance goes down for Caps). So I understand why you would want to do it there, as well as some topology issues with power electronics needing to balance out internal currents.

However, the Arduino is generally NOT driving signals at MHz, nor are you using "large" FETs where power distribution can be an issue. There is some issue of wasting energy and heating up the FET due to slow transition times (Staying too long in the linear region), but not from overloading the driving chip. Is the concern shorting out the Gate if it fails (Fair enough concern considering hobbyists and electricity)? Is there some other concern?

High currents damage the tiny interconnects and transistors inside microcontrollers. Sure you can draw 80mA from an Arduino pin, but boy does it get hot, and will undoubtedly shorten the lifespan of the uC.

When switching a speeds even in the 100kHz ranges, the gates of MOSFETS are nothing but a small capacitor. At steady state they are high impedance, but at transitions between states, they get charged and discharged. This charging and discharging can result in short but high peak currents. These current surges if done repeatedly, such as 100000 times a second for a prolonged period, will inevitably lead to degradation of the uC pin driver circuits. 100kHz may not sound like much but a square edge is made up of many high frequency harmonics, so you will find the frequency is much higher than you think.

I like the "Myth Busters" series, indeed :slight_smile:

  1. 40mA myth - the atmel says clearly in the datasheet the maximum current they guarantee as safe is 20mA
  2. output resistance myth - the output resistance of a pin is not XYZ ohms, but it depends on many factors
  3. your measurement myth - the only way how to measure the gate inrush current is with oscope during the rising/falling edges, voltage drops are not much relevant
  4. 8us extremely high frequency myth - it does not matter how is the frequency of the pwm signal, but it matters how steep are the rising/falling edges, as the inrush current is largest during that time..

You may try to simulate the stuff with spice, I did it already in an another topic, but I will do it for you again..
(edges are 10ns):

Many reasonably priced N-channel, logic level, low Rds MOSFETs have a decent amount of input gate capacitance
http://www.digikey.com/product-detail/en/NTD5867NL-1G/NTD5867NL-1GOS-ND/2401422 675pF
http://www.digikey.com/product-detail/en/AOI518/785-1569-5-ND/3152481 951pF
http://www.digikey.com/product-detail/en/AOI516/785-1568-5-ND/3152480 1229 pF
http://www.digikey.com/product-detail/en/PSMN022-30PL,127/568-7512-5-ND/2606361 447pF

I'd like to see some scope measurements on those.

Input capacitancen on 74CH595 is 10pF.
I don't see it listed for TPIC6B595;
I have driven 20 of them in parallel (SCK, SS) across two boards with no noted operational problem. Didn't look at the signals with a scope tho.
I regularly drive TPIC6B595s at 4 MHz clock speeds & get expected results as long as 0.1uF decoupling caps are installed on their Vcc pin.
Same with MAX7219, they work fine at 4 MHz clock.

KeithRB:
I just did a simulation, and with a 0-5 V 1nS step, and a Ciss of 1000 pF a 1 ohm resistor causes a peak current of 3A! 150 ohms tames that to 33 mA, so it looks to me that the resistor is a good idea.

Do the experiment, not a simulation. The Arduino will not pass 3A. Ever!

First, the ATmega328 can never pass more than 88ma. The rise times I measured were in the range of about 100ns to 300ns. I will bet my last ATmega328 that it will sustain 88ma for 300nS until something else breaks. Averages are important. There is time for whatever heat can build up with 88ma for 300ns to go away. Even the thermal mass will be in effect.

Putting 100ohm resistor in the gate will only increase the turn on time. This is most likely where people will experience problems at higher frequencies. Their MOSFETs will over heat.

An active buffer, or diver is the real solution. Not a resistor.

  1. "The Arduino will not pass 3A. Ever!" myth - why do you think it is not possible? A capacitor (quality one) charged to 5V and discharged quickly can produce a 3A current easily (in a short pulse)..
  2. " I will bet my last ATmega328 that it will sustain 88ma for 300nS until something else breaks." myth - maybe yes, maybe not, however it is not a good engineering practice. You have to design the stuff such it never exceeds any parameter under any conditions..

Steady state yes, but for 300nS while you turn your MOSFET on, nothing bad will happen.

pito:
I like the "Myth Busters" series, indeed :slight_smile:

  1. 40mA myth - the atmel says clearly in the datasheet the maximum current they guarantee as safe is 20mA

No. they say 40mA

  1. output resistance myth - the output resistance of a pin is not XYZ ohms, but it depends on many factors

Yeah, that what I said. Many times in the last few weeks
.

  1. your measurement myth - the only way how to measure the gate inrush current is with oscope during the rising/falling edges, voltage drops are not much relevant

Yup, measurements were done with a scope. Rise times on input, and fall time on output are shown. The other times were comparable so were not shown. You can do you own calculations given the facts. If you have an issue, get to work.

  1. 8us extremely high frequency myth - it does not matter how is the frequency of the pwm signal, but it matters how steep are the rising/falling edges, as the inrush current is largest during that time..

Again, times were provided. Do the math.

You may try to simulate the stuff with spice, I did it already in an another topic, but I will do it for you again..
(edges are 10ns):

Well, that's cute, but unless your models are correct, it ain't worth snail turds. Sorry. Do the experiment.

No. they say 40mA

Where did they say 40?

CrossRoads:
Many reasonably priced N-channel, logic level, low Rds MOSFETs have a decent amount of input gate capacitance
http://www.digikey.com/product-detail/en/NTD5867NL-1G/NTD5867NL-1GOS-ND/2401422 675pF
http://www.digikey.com/product-detail/en/AOI518/785-1569-5-ND/3152481 951pF
http://www.digikey.com/product-detail/en/AOI516/785-1568-5-ND/3152480 1229 pF
http://www.digikey.com/product-detail/en/PSMN022-30PL,127/568-7512-5-ND/2606361 447pF

I'd like to see some scope measurements on those.

Don't let me stop you. This was silly easy to do.

Input capacitance on 74CH595 is 10pF.

It's not just the input capacitance, it's the total gate charge. The equivalent capacitance will depend on the drive voltage and the VDS, which is a time dependent function.

I don't see it listed for TPIC6B595;
I have driven 20 of them in parallel (SCK, SS) across two boards with no noted operational problem. Didn't look at the signals with a scope tho.
I regularly drive TPIC6B595s at 4 MHz clock speeds & get expected results as long as 0.1uF decoupling caps are installed on their Vcc pin.
Same with MAX7219, they work fine at 4 MHz clock.

pito:
5. "The Arduino will not pass 3A. Ever!" myth - why do you think it is not possible? A capacitor (quality one) charged to 5V and discharged quickly can produce a 3A current easily (in a short pulse)..

Because I shorted one out and measured the current.

  1. " I will bet my last ATmega328 that it will sustain 88ma for 300nS until something else breaks." myth - maybe yes, maybe not, however it is not a good engineering practice. You have to design the stuff such it never exceeds any parameter under any conditions..

That is just preposterous. Where did you get that gem?

Ahhh..., I don't even want to go there.

pito:

No. they say 40mA

Where did they say 40?

Really?

Interesting thread. Especially as I was trying to work out what value gate resistors were required a while back.

As suggested above, I set up an actual test. Unless I misread his post the OP has not actually measured current, but rather voltages.

Surely the relevant test is: does the output pin have to supply more than 20 mA (or 40 mA if you don't mind the absolute maximum rating) at any time?

Here is my test circuit:

I put the scope leads on A and B and set up the maths "difference" to find the current through the 0.2 ohm resistor.

Results:

So, a 140 mV pulse for 10 nS.

Using Ohms Law:

I  = 0.140 / 0.2 = 0.7

Thus unless I have made a mistake somewhere, that is a pulse of 700 mA. This is well out of spec for the output port.