On using an IRF510 as a switch…

This posting begins with a caveat: while I’m pretty experienced as a programmer and software engineer, I’m actually a bit of newbie when it comes to electronics. I’m entirely self-taught, and because of my inherent laziness, I find it hard to learn anything before I actually need to know it. This means that I often get in a bit over my head, and only then start to figure things out and find out where my preconceptions and misunderstandings have lead me astray.

This happened with a project I was working on last night.

The basic idea is that I wanted to use PWM to control a high power (1W) Cree LED. I had the program running nicely on my little ATtiny13, and if I hooked an ordinary (20ma) LED to the pin through a current limiting resistor, all was well. But I knew that the Arduino couldn’t supply the current necessary to light the Cree, so I needed a switch.

And so, I’m off into territory I hadn’t been in before.

In my junk box, I have a bunch of IRF510s. I think to myself, they can handle high power, I could use them to switch the LED. So, I hooked it up. I put the LED in series with a 100 ohm resistor for safety, and wired that through the source/drain of the MOSFET to a 9v supply. I sent the voltage from the PWM on the microcontroller to the gate, and added a 10K resistor from the gate to the ground. I powered it up, and… well… it worked!

I then decided to drop the current limiting resistor’s value. The easiest way on the breadboard was to parallel another 100 ohm resistor in place. Sure enough, when I switched in that resistor, the LED got visibly brighter. Good deal, think I.

But then I moved on. I had been powering the ATtiny13 from the 5v supply on my USB port. I didn’t really want to do that in the final configuration. I didn’t have a spare 5v regulated supply, but I know that the ATtiny can operate down to 2.8v. I had a pair of fresh AA batteries, so I plugged those in, and sure enough, the processor booted and ran just fine.

But then I noticed that the overall brightness of the LED display seemed pretty weak. And when I paralleled in the extra resistance to drop the current limit, the LEDs got no brighter.

It only took me a few minutes to figure out what the deal was: the voltage driving the gate of the MOSFET wasn’t strong enough to open the MOSFET entirely. The MOSFET itself must be limiting the current.

That sent me back to the web to look at datasheets (which mostly confused me) but one thing became clear: the IRF510 wasn’t meant to be driven from logic levels. The important figure would seem to be specified as the Drain to Source Resistance (rDS(ON)). For a gate to source voltage of 10V, and a drain current of 3.4A, the resistance is typically about 0.4 ohms. But if the gate to source voltage is only 5v, what happens? What if the gate to source voltage is only 3v?

I stared at the Fairchild datasheet some more. Figure 6 was telling: it showed the graph of the saturation characteristics of the IRF510 at a variety of gate/source voltage levels, ranging from 4V to 10V. For each VGS value, the graph shows the relationship between the VDS and ID, the current through the drain. For a VGS of 5V, the curve is remarkably flat right around 1 amp. But if you look at the curve around 4V, it’s flat right at zero. In other words, the MOSFET doesn’t switch any current at all. And who knows what happens below that.

When I am running my circuit at 3V, I’m barely tickling the output. In fact, the specifications say that it shouldn’t work at all at 3V. My hypothesis is that it’s just a fluke: my transistor is actually just conductive down at that voltage level. (The appropriate specification would appear to be VGS(TH), the gate to source threshold value, which is specified to be between 2.0 and 4.0 V)

Interesting.

By the time I got all this figured out, I started tinkering with LTSpice. I learned a bit, but it really would be helpful if I had a model for the LED that I am using. But I did discover that by mucking around with the LED supply voltage and the gate/source voltage, I could emulate some of the features I saw in my actual circuit. It does seem possible to limit the LED current to 200ma or so with a 5V VGS, but it won’t reach anything close to that level of current with only a 3V VGS.

Thus, what seems like a very simple electronics project turns into a lesson. I can proceed along a number of possible avenues to make it work:

  • I could try to make it work with a 5V logic level, still using the IRF510. I suspect that since I don’t need a full ampere of current through the drain, that is at least possible. I plan on using a 6V lantern battery for the LED supply. I could inject 5v onto the gate, and empirically test the current through the LED by just measuring it with my multimeter, and adjusting the current limiting resistor until I get the current I desire.
  • I could ship to using a common Darlington (maybe a TIP120 or similar, which you can even get at Radio Shack). That will let me run the processor from just two batteries, but a lot more power will go into driving the Darlington than is consumed by the entire rest of the chip. I could of course use a Darlington at 5V as well just fine.
  • Did I mention overall power? It would be great if this thing could be powered by a 6v lantern battery, but if I want to drive the chip at 5V, any of the common 7805s I have in the box won’t work (drop out voltage would be too high). Maybe just a Zener diode supply?

I have to remind myself: projects like this are like musical scales to a budding pianist.

7 thoughts on “On using an IRF510 as a switch…

  1. Rob AK6L

    Two thoughts occur: 1) You could run the LED from a lantern battery and the AVR from a 9V+7805, just tie the battery grounds together. (A 5V zener is probably a better solution.) 2) Perhaps the 2N7000 would be a more suitable device than the IRF510. They’re also quite common, though apparently not common enough to be carried at RadioShack. Jameco undoubtedly carries them, though.

  2. Lee Felsenstein

    You don’t need to use a big TO-220 driving transistor like the TIP120. The 2N2222 (PN2222 from Fairchild) has enough gain (150 at 200ma collector current) to require only 2 mA base current (I’m de-rating the 150 gain to 100 here). A 1K resistor in series with the I/O pin and base will limit the current appropriately and allow fast turn-off.

    As for the regulator, you should look into low-dropout regulators (check the Jameco catalog), but if you need only 2.8V you can use the batteries with no regulator.

    This has been another public service consult from the Fonly Institute.

  3. madscifi

    One could construct a voltage doubler to drive the gate. See “Dickson charge pump” on the wiki page http://en.wikipedia.org/wiki/Voltage_doubler. The capacitor on the output is not needed (the circuit can use the gate capacitance of the MOSFET). I have not actually constructed the circuit but a spice simulation says that it will work as long as you keep the PWM modulation under 100% and the supply voltage minus the diode drops is not enough to turn on the MOSFET by itself. An ugly hack. It would be better to buy logic level MOSFETs, but as a quick solution to the lack of parts…

  4. madscifi

    The rightmost diode in the circuit is not actually needed for the purposes of doubling the voltage to drive the gate with a PWM signal (and most non-Schottky diodes will not work according to LTSpice). I’ll have to breadboard this tonight – I’m curious to see how well (or poorly) this works in reality.

  5. Pingback: And a Quarter Gets You Coffee » Blog Archive » A Hack to Boost the Gate Voltage of a PWM Driven MOSFET

  6. miXania

    Mark, Thank you very much for sharing your experience. I just bought three IRF510 MOFSET transistors from RadioShack but when I tested them out they didn’t work. Now I know how to roll, thanks!!

  7. Eggmatters

    Thanks! Just naively bought some IRF510’s to switch a PWM circuit for a motor driver controlled by an Arduino Uno board. Having no idea what Vgs should or shouldn’t be, was troubleshooting for hours (or rather learning how to troubleshoot) the issue. I had the same behavior you described. The gate will switch on, but then it will stay on – even if I physically yank the gate input. I have to remove the mosfet from the circuit.

    The Uno sends aprx. 5V signal voltage, to make a long story somewhat shorter, the datasheet I found puts the switching current along the steepest part of the curve.

    http://www.futurlec.com/Transistors/IRF510.shtml

Comments are closed.