Turning on/off 12 VDC LED with Mosfet IRF520N

Hi all,

I do have a problem with getting my Mosfet IRF520N working. In my project, I have a 12 VDC external power source which I need to use in order to get a special LED lighting up. Now I want to turn the LED on and off using the Mosfet IRF520N module. However, I cannot make it work. I have created a diagram to make the current situation visible:

Mosfet IRF520N

The Mosfet does work actually. I have tried to use it with a 3 V LED wherefrom the powersource came from the Arduino Uno (3.3 V). This worked since the LED did turn on and off as I expected it to do so. But with this new external powersource, it seems not to work anymore.

Note: the LED is on continuously. Meaning it just won´t switch off.

Does someone see what is wrong with the setup? What should I do to make it work?

Are you using this module?
What kind LED you want use?

Parameters to consider when selecting a logic level N-channel MOSFET

Gate-Source Threshold Voltage - Vgs(th)(min) and Vgs(th)(max): Gate voltage at or below the minimum threshold value turns the MOSFET off. Common minimum gate voltages for 5 V logic may fall between 0.5 V and 1 V. Gate voltages above the maximum threshold value turn the MOSFET on. Gate threshold voltages between the minimum and maximum could turn the MOSFET on or off and must be avoided. Notice how the minimum and maximum values roughly coincide with the illegal region in Figure 1.

Figure 1

Drain-Source ON Resistance - Rds(on): When turned on, there is resistance between the drain and source that decreases as the gate-source voltage or Vgs increases. Choose a MOSFET whose lowest Rds(on) values occur at or near the ideal logic high voltage value and do not decrease substantially with higher Vgs values. See Figure 2.

Figure 2

Example: According to its datasheet, an Infineon IRLZ44 MOSFET has 25 mOhms of drain-source resistance at 5 V, 35 mOhms at 4 V and 22 mOhms at 10 V. At 5 V, its Rds(on) value is only 3 mOhms higher than the value at 10 V but is 10 mOhms lower than the Rds(on) value at 4 V making it a good choice with respect to Rds(on).

Figure 3

Input Capacitance - Ciss: The combination of the gate, oxide layer, and the body connection of a MOSFET act as a small capacitor that begins charging when voltage is present at the gate. It takes time to charge which results in an ON-state delay. Choose a MOSFET with the lowest input capacitance possible to avoid long delays and to minimize in-rush current which can be very high initially but lessens as the capacitor charges. Ideally, the ON-state delay is extremely short but may create enough surge to damage an I/O pin that has limited current sourcing capacity.

A current limiting resistor between the pin and gate prevents excessive I/O pin current draw.

When using a MOSFET connected directly to a microcontroller output pin, the MOSFET gate should be pulled either high or low as needed using an external resistor to prevent floating gate logic and unwanted output from the MOSFET during MCU startups and resets.

The above parameters are a basic start to selecting a MOSFET for logic circuits or gate designs that may be fine-tuned with additional consideration for heat dissipation and other performance parameters. Don’t be afraid to give MOSFETs a try in your next project design.

Ref: How to Select a MOSFET | DigiKey

Hi, @mklaassen
In this diagram you have the 12V supply connected the wrong way around.
12V negative to the gnd and 12V positive to Vin
image

Can you please post some images of your project?
So we can see your component layout.

Can you please post your test code?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

Very good explanation, however the schematic shown will only supply ~2.75 to the gate with a 3V3 processor, R2 should be connected to the port pin or the other side of R1. This is because the resistor configuration performs a voltage divider function. The threshold Vgs of the OPs MOSFET is per the data sheet: VGS(th) Gate Threshold Voltage 2.0 ––– 4.0 V VDS = VGS, ID = 250µA so it may not turn on.

Yes, I'am using this module. When it comes to the LED, I'm not sure what kind of LED it is since it came with a kit I bought.

The component layout is just like I have drawn in the diagram. However I now changed the position of the resistor between the MOSFET and the LED.

Below you can see the simple code I used

image

Your circuit shows the MOSFET module connected to D3 but your code uses pin 2.
Change your code to pin 3

1 Like

That was a mistake. Actually pin D2 was connected

Does the LED on the module blink

Yes. It does. I have tried multiple modules but all with the same result. The Led om the module blinks, but the led which I want to control doesn’t.

If it's connected like this, it should work

ML

As a test, disconnect D2 from SIG and connect SIG to GND
If the LED should go OFF

The light on the module itself doesn’t go on anymore (obviously). However the LED I want to control remains on.

My conclusion would be that the MOSFET is damaged (shorted) or the module was bad when you bought it.
If you decide to buy another, I recommend this one.

If it's any consolation, I made a very similar circuit using the same MOS module (except controlling a solenoid instead of LED) and it worked nicely. Bought 4 more of the same MOS module from Temu to hook up more solenoids and... none of them work. After hours of fiddling I'm beginning to think the problem is just dodgy electronics from Temu, not my stupidity.

The IRF520 has an Rds(on) specified for a Vgs of 10V only. So it may or may not work with 5V.
If Temu is claiming they all work at 5V, then you have been mislead.

1 Like

That module is commonly marketed as arduino friendly, not just on Temu. The previous one I bought from a local supplier works perfectly (goes with this datasheet: https://www.jaycar.com.au/medias/sys_master/images/images/10221806780446/XC4488-dataSheetMain.pdf)
Is there something about the module that makes the IRF520N work at 5V?

No. It's only useful to switch small currents up to a few hundred mA at most from a 5V signal. And that's already stretching it.

The IRF520 is an ancient model and it's a very unfortunate choice in this application.