Hi, I am using a MOSFET(IRF 520) to drive a few LEDs with my arduino. I have a problem with selecting the proper gate resistance and whether to connect the resistor from gate to source or from gate to drain.
My initial schematic is also attached.
R3 should be connected from the mosfets base down to Gnd and should be at least 10K
It should work ok for those few leds, but next time you purchase a mosfet its better to use the Logic Level types, as when ON from the 5v Ardunio port it will not get full power though theIRF520 as it needs 10v on its base to do so.
Actually, "from the mosfets base" should read "from the mosfets gate". Many people also recommend a resistor in series with the Arduino to the Gate to limit the current into the gate at switching time (330 ohms or so). MOSFET gates tend to have quite a high value of capacitance and as such, there is a spike in the drive current to the gate any time you switch it on or off (virtually no current in steady state though) The Logic level version of that FET is the IRL520 (which is what I have a bag of that I use), but others here have pointed out there are much newer ones with a much lower on resistance (Rds) that will not need any heat sink for currents above an amp or two.
Thanks guys, but which of the configurations should I use ? Connect the MOSFET gate in series with a resistor to the arduino or connect a resistor from the gate to source (GND) of the MOSFET ?
This discussion from exactly a year ago may help, from when I had never used a mosfet...
malgwi:
Thanks guys, but which of the configurations should I use ? Connect the MOSFET gate in series with a resistor to the arduino or connect a resistor from the gate to source (GND) of the MOSFET ?
You want both - a resistor between the Arduino pin and the MOSFET gate to limit switching current to a safe level for an Arduino pin, (220 ohms would limit current to 23mA), and also a higher value resistor from the gate pin to ground. 10K would do for this one. It's purpose is to hold the MOSFET gate low when the Arduino is starting up, before it takes over control of it's pins.
OldSteve:
also a higher value resistor from the gate to ground. 10K would do for this one.
In the discussion to which I linked above, Paul__RB says that pull-down should be on the Arduino side of the gate resistor, not the mosfet gate side.
Would it be possible to connect a MOSFET gate to one side of a piezo disk without frying the FET?
The piezo is low current but pushed hard can be beaucoup volts.
I look at piezo disks and see capacitors you can charge by squeezing....
JimboZA:
In the discussion to which I linked above, Paul__RB says that pull-down should be on the Arduino side of the gate resistor, not the mosfet gate side.
Oops. I just corrected my last post. I meant to write 'pin', not 'gate'.
Thanks for pointing it out.
GoForSmoke:
Would it be possible to connect a MOSFET gate to one side of a piezo disk without frying the FET?The piezo is low current but pushed hard can be beaucoup volts.
I look at piezo disks and see capacitors you can charge by squeezing....
Good question. It doesn't take much current to kill a MOSFET with over-voltage.
A lot of FET and MOSFET preamps for piezo elements use diodes or Zeners for protection. I think I'd personally do the same, just to be sure.
Thanks guys, this has been really helpful.
That looks OK except for one thing - the IRF520 isn't a 'logic-level' MOSFET, and needs more than 5V to turn on fully. A better proposition is it's brother, the IRL520. It has a low gate threshold voltage and will turn fully on at < 5V.
Edit: The datasheets say that the IRF520 can have a threshold voltage as high as 4V, whereas the IRL520 has a threshold below 2V. In practice, this gives the IRL520 a much lower 'on' resistance when controlled by 5V.
Here's your schematic for easier viewing:-
(Right-click and 'View Image' or similar for full size view.)
I pointed out the difference between the IRF and IRL all the way back in #2 but I don't think anybody took me seriously There are newer / better logic level ones out there, the the IRL520 is what I use since I have a bag of them I got some time ago for this sort of thing.
gpsmikey:
I pointed out the difference between the IRF and IRL all the way back in #2 but I don't think anybody took me seriouslyThere are newer / better logic level ones out there, the the IRL520 is what I use since I have a bag of them I got some time ago for this sort of thing.
That's right, now that you mention the bag of them it jogs my memory. I didn't read right back through the thread and just went by the schematic that was presented.
Reading back now, ricky101 mentioned the problem with the IRF520 back in reply #1. For this relatively low-current application, there's nothing wrong with using an IRL520 if it's easier to get than a newer one. The 'Rds on' isn't too critical.
I could not get my hands on any logic level MOSFET that was why I chose the IRF520. The IRF520 has a minimum threshold voltage of 2V that was why I chose it.
malgwi:
I could not get my hands on any logic level MOSFET that was why I chose the IRF520. The IRF520 has a minimum threshold voltage of 2V that was why I chose it.
You need a MAXIMUM threshold voltage of about that.
Some could be 4volt, so e.g. a 3.3volt Arduino couldn't even "open" them at all.
You could measure Vgt of the fets you have.
Source to ground, gate connected to drain, 1k resistor from gate/drain to 5volt.
Measure the voltage on the drain. That's roughly the threshold voltage.
Keep anything <=2.5volt for your 5volt-Arduino projects.
Leo..
malgwi:
I could not get my hands on any logic level MOSFET that was why I chose the IRF520. The IRF520 has a minimum threshold voltage of 2V that was why I chose it.
An IRF520 is not suitable for 5V operation. You have to work from the maximum stated value, not the minimum. The maximum threshold value is 4V, and the MOSFET will not be turned fully on with 5V.
(Sorry Wawa, I didn't see your post saying exactly the same until I'd posted.)
You can't have searched too hard. I just did a quick eBay search and immediately found IRL520 MOSFETs. I'm in Australia, so this search shows on eBay Australia, but they only cost AU$5.31 for 5, with free delivery. The seller is in China, and they post worldwide.
I'm sure that if you do a search on your local eBay you could find similar. You would also be able to find later logic-level MOSFETs with an even lower 'Rds on', but for your application that's not necessary.
5 x New IRL520 IRL 520 Power MOSFET TO-220 IR
Note that in this graph from the IRF520 datasheet, the graph doesn't even show voltages below 4V. There's a good reason for that.
Edit: N.B. Ignore the filename of the attachment. I meant IRF520 not IRL520.
Thanks @Oldsteve, but ebay shipments to my country take about a month to arrive and other services like ali express and amazon are no better. Most atimes I just stick to locally available components. The IRF520 is not the best choice I know that now but I dont have any other option rather than to use a BJT which I HATE using.
I am pretty sure that the BJT can switch high enough voltage to switch the FET.
malgwi:
Thanks @Oldsteve, but ebay shipments to my country take about a month to arrive and other services like ali express and amazon are no better.
If you'd ordered a logic-level MOSFET straight after my last reply, it might have been here by now.
(That was March 29 and it's April 26 now. Exactly 4 weeks have passed)
GoForSmoke:
I am pretty sure that the BJT can switch high enough voltage to switch the FET.
A PNP transistor could be used to pull the gate of the IRF520 MOSFET to +12V, but it's base couldn't be directly switched by the Arduino, so an NPN transistor would be needed as well, to level-shift.
Actually, I take that back. As long as a momentary LED flash on power-up is OK, an NPN transistor could be used to turn the MOSFET off, and a pullup resistor could turn it on.
The Arduino output would be high to turn the LEDs off, and low to turn them on. The transistor would have to be energised the whole time the LEDs are off though.
CIRCUIT #1 - 'active-low':-