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 CL*VCC*f 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 5*500*5.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 V_{cc} measured at 4.96V

V_{GSon} and V_{DSon} are measured during the pulse. Timings are to 90% of final value.

2N7000 – R_{L}= 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 V_{GSon} = 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 – R_{L} = 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
```

R_{L}=16 ohms

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

Worst case V_{GSon} = 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

R_{L}=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
```

R_{L}=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 V_{GSon} = 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!

R_{L}=6 ohms

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

R_{L}=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.