IRF520 versus IRF540

Hi,

After spending a lot of time working with the Raspberry Pi in its various guises, I got hold of a copy of Getting Started with Arduino. Working through that, I hit this page. My local electronics supplier didn't have the IRF520 MOSFET, but they did have the IRF540. Borrowing a 520 from a friend and adding in a 1k resistor to stop the PWM pin floating allowed me to get the circuit to work. Putting in the IRF540 causes the motor to run away completely. The FET also gets really warm. My guess is that there's not enough internal resistance in the IRF540 FET (0.27ohm in the 520 versus 0.07ohm in the 540) to keep the motor from running away and it needs a second resistor. Where would I put that second resistor in? I'm thinking between the Vin line and the source pin on the MOSFET. Does that sound right? If so, what value would be good?

We cannot access that page. If you are driving the MOS FET with 0-5 volts you need a logic version. IRL540

That's the thing. With the IRL540, the circuit runs away. The motor rpm quickly reaches maximum and won't return when the PWM signal comes back down. I just removed the 1k pulldown resistor and the circuit performs the same with the IRF540. The motor runs away. The FET still gets very hot as well. The question remaining is why. Why does the 540 get hot when the 520 doesn't? Why does the 520 work but the 540 doesn't? It's going to be interesting finding out.

You said IRF, I said IRL.

The plot thickens. The IRF540 works with much lower light levels, with and without the pulldown resistor. Which means adjusting the constant in the code for PWM. Is there a setting I need to implement so you can view the Google Books page? It would help if you could see what I was talking about. The text I'm working from recommends the IRF series. From what I can read online, the difference is that the IRL series will switch on with much lower voltage levels, suitable for use in logic circuits. As I'm just tinkering and supply is limited where I am, would the IRF series be fine?

Your transistor is getting hot because it is not turning on all the way.

IRF540 requires 10 volts Vgs to get .077ohms Rds IRL540 requires 5 volts Vgs to get .077ohms

Also, you need a 220 ohm resistor in series with the gate and I would put a 10K from the gate to ground.

.

Let see your sketch and take a picture of the wiring and attach it to a post.

Firstly, thank you for taking the time to help me here. I can see where you're coming from in using the IRL series of MOSFETs, but unfortunately I can't get those easily. As I've not got the ability to host pictures or sketches, that might be difficult. It's a pity you can't see the Google Books page. A Google search for 'Getting Started with Arduino MOSFET' has it as the first link. Looking at this link I've got mine wired exactly the same way. The only differences are that I'm using a IRF520 or IRF540 MOSFET and that I've got a 1kohm resistor instead of a 10kohm. Seeing as both the 520 and 540 are N-channel MOSFETs, it should work the same. I'm thinking I'll need to alter the resistance of the pull-down resistor to get one MOSFET to work the same as another.

Do you have a NPN transistor ex: 2N2222 ?

If so, you can use it as a driver to the MOSFET. There will be an inversion, but you will get the IRF540 running properly.

For a 12 volt supply, see the image on the right:

|500x236

Two small transistors is better. No inversion and no motor running when the Arduino boots up. Leo..

Tashen: Firstly, thank you for taking the time to help me here. I can see where you're coming from in using the IRL series of MOSFETs, but unfortunately I can't get those easily. As I've not got the ability to host pictures or sketches, that might be difficult. It's a pity you can't see the Google Books page. A Google search for 'Getting Started with Arduino MOSFET' has it as the first link. Looking at this link I've got mine wired exactly the same way. The only differences are that I'm using a IRF520 or IRF540 MOSFET and that I've got a 1kohm resistor instead of a 10kohm. Seeing as both the 520 and 540 are N-channel MOSFETs, it should work the same. I'm thinking I'll need to alter the resistance of the pull-down resistor to get one MOSFET to work the same as another.

The pull down resistor has almost no effect. It is just there to discharge the gate lead when the arduino powers up and floats the output pin for some time. You need to increase the voltage to the gate, using the buffer transistor shown in the second schematic of the previous post. Dwight

Wawa: Two small transistors is better. No inversion and no motor running when the Arduino boots up. Leo..

The inversion is a simple software fix. A 10K pullup on the output pin will solve the full speed issue on powerup. Dwight

dwightthinker:
The inversion is a simple software fix.

A 10K pullup on the output pin will solve the full speed issue on powerup.
Dwight

  1. True.

  2. Still an issue if you power up the motor before the Arduino.
    Leo…

As I've not got the ability to host pictures or sketches, that might be difficult.

No it is very easy. Please read this:- How to use this forum

Thanks everyone for replying to my post and giving me such useful information. If I'm reading this right, then a 10kohm resistor on either the source or drain pins of the MOSFET should stop the runaway motor. I'll experiment and see what happens. From what I can read about MOSFETs, it shouldn't make too much difference which pin I use.

What would happen if the motor was powered up before the Arduino? Would that cause damage? I've got a diode in place between the drain and source to prevent the flow of current when the motor switches off.

If I understand the diagram right, you're using the 5V PWM signal through the NPN transistor (I've got a BC547 that I can use) to turn on 12V to turn on the MOSFET, thereby allowing 12V to flow through the motor. The diode is across the motor to prevent current flowing back when the motor is switched off and still turning.

I've got a 12V 1.5A external HD power supply with a 2.1mm centre positive barrel connector. I should be able to put that into the Arduino and then take 12V from the Vin pin and use that to run the MOSFET.

Again, thank you everyone for all your help. A small question has given me a whole heap of learning.

All these ancient MOSFETs are pretty abysmal in performance compared to modern devices,
they are from the 1980’s, not this century even.

Get a modern MOSFET with Ron < 0.02 ohms and logic level - all the usual sites stock something like
this, sparkfun, adafruit, coolcomponents etc…

larryd: Do you have a NPN transistor ex: 2N2222 ?

If so, you can use it as a driver to the MOSFET. There will be an inversion, but you will get the IRF540 running properly.

For a 12 volt supply, see the image on the right:

|500x236

Sorry to query an old post, how do you post circuit diagrams on this forum. Best regards.

Posting images: https://forum.arduino.cc/index.php?topic=519037.0