Help me understand N-channel MOSFET transistors

Hi,

I am still a beginner and finally starting my first "real" project (in my very short free time). It is a small LED project, in which several LEDs are powered by a 9V battery and their brightness is controlled via an Arduino Uno and its 6 PWM pins switching the transistors.

I ordered the required parts, including the transistors. I chose MOSFET, because someone recommended those to me. I chose IRFZ24N (https://www.infineon.com/cms/en/product/power/mosfet/n-channel/irfz24n/) not 100% knowing, if these are appropriate.

OK, after many fails of using it, I found this video (in German) MOSFET RICHTIG ansteuern für Lüfterprojekt? Eigene Schaltung ausführlich erklärt | Arduino #6 - YouTube which mentions that N-channel transistors need to be used behind the consumer. In addition the pins and their use is different than I remember from my (more then two decades ago) physic lessons.
Applying this to my early prototype on the breadboard, I got the LEDs finally blinking and can not continue.

Although I know now, how to use the MOSFET, I am curious, WHY I have to use it this way.
More concrete questions:

  • Why does the location in the circuit makes such a difference
    • I places if initially before the LEDs and had unexpected results
  • Is MOSFET right here?
    • What other transistor types would also be possible? Do these have advantages
  • MOSFETs have the cooling part. Is it somehow getting dangerous? Under which conditions do I expect a significant heat and could this even cause fire?
    • Will other transistor types will also get hot?
  • When should I chose N-channel over P-channel?

No, for this you need a logic level FET. The one you have requires a 10V signal for it to fully close, you need one that is fully closed with a 5V signal.

Only use a P-Channel FET when you want to top switch, that is switch the positive supply. The better FETs are for switching the ground, known as bottom switching.

I would need to see a schematic to explain why what you did gave unexpected results, but it will not matter which order you place parts in a series circuit.

This sounds muddled as well as being wrong.

I would guess this is an illusion, because if you actually understood FETs then you would not be asking these questions.

3 Likes

"Regular little" LEDs don't normally need a driver unless you are driving lots of them. An Arduino output pin can supply 40mA "absolute maximum" with 20mA maximum recommended so you can drive one or two LEDs from an I/O pin (or more if you lower the current). And the chip is limited to 200mA total, so you could drive 10 LEDs at 20mA.

If you wanted to control more LEDs, or multiple LEDs from one output-pin a MOSFET driver is a solution.

LEDs are "current operated" and a regular LED requires a current-limited resistor.

LED strips have the resistors built-in and since they require more current (and often more voltage) that the Arduino can supply. This is where MOSFETs would most-often be used.

"High power" LEDs normally use a constant current (or controlled current for dimming) power supply/driver. These are usually built-around a MOSFET but it's NOT an easy thing to build yourself.

Regular bipolar transistors are current amplifiers. It only takes about 0.7V to saturate the transistor and turn it fully-on. Similar to an LED you need a current-limiting resistor (or something limiting the base-emitter current).

Bipolar transistors have higher saturation voltage than a MOSFET. Saturation is when the device is "fully-on" and an ideal device would have zero-resistance and zero-voltage across it with all of the voltage appearing across the load. Since power (and associated heat) is calculated as Voltage x Current you want the more voltage "loss" across the device the hotter it gets and the more power is wasted. This is the main advantage to MOSFETs in high-power switching applications.

MOSFETs are voltage operated and it takes more voltage (but virtually no current) to turn it on. However, the gate has capacitance which means current flows with it's first turned-on (or off) as the "capacitor" charges & discharges. So in order to protect the Arduino from excess current spikes there is usually a current-limiting resistor for MOSFETs too.

And, since there is no DC current path into the gate the voltage can "float up". So another "pull-down" resistor is used to make sure the MOSFET stays off when no gate-voltage is applied. (A P-MOSFET would have a pull-up resistor.)

The "problem" with a P-MOSFET is that in order to turn a MOSFET off the gate-source voltage should be zero. That's no problem in a 5V circuit because you can supply 5V to the gate & source. But if you're switching 9 or 12V you'd have to feed 9 or 12V into the gate, and the Arduino can't do that (without adding another transistor or MOSFET).

2 Likes

When looking at MOSFETs you reference the Source for the Gate voltage, not ground. A N-Channel MOSFET needs the gate positive by at least Vgs to turn on up to its max generally in he +15V range. P-Channel needs its gate negative by at least Vgs or more to turn on. It will survive with a max of about -15V. The gates are normally rated +- about 15 V depending on the MOSFET. Putting a negative voltage on the gate of a N-Channel MOSFET or positive on the gate of the P-Channel will not enhance ( turn them on). With the Avalanche rated devices generally you do not need a flyback diode, Check the data sheet and look up the maximum under pulse., the flyback is not steady state. The forward voltage drop is calculated by using the RDS(on) to calculate the voltage drop which is depending on the load as well. The pull resistor goes from the gate pin of the micro to the MOSFET source voltage, not at the gate as it forms a voltage divider. I use something fo the 20 - 50 Ohm resistor for the gate circuit.

1 Like

Thank you for your replies so far.
I guess I need to get some new transistors :slightly_frowning_face:

For more background information: I plan to have a 36 LED array, of 12 blue, 12 red and 12 green LEDs.
To power so many LEDs, I use the 9V battery. This allows me to have 12 parallel chains of 3 LEDs. Without any switching, the battery is enough to power all LEDs and the Arduino Uno.

But now I want to have 6 groups (2 blue, 2 red and 2 green 3LED-Groups) and control their brightness via the 6 PWM pins. Therefore I planned to use the PWM pin as Gate, while the drain and source feed the LEDs.

When I placed the transistor directly after the anode of the battery, the LEDs were off, but after watching the mentioned video, I placed it directly before the cathode, and now it seems to do, what I am expecting.

Unfortunately, I don't have time to draw an sketch or continue on that, in the moment. I am just happy, that I see an expected result for my first group, 6 LEDs turn slowly on and off, while the others stay on. Although I am not sure, if the fading LED group reaches the brightness of the fully switched on LEDs. I will definitely take a closer look, the next time, I sit in front of the breadboard.

Never ceases to astound me, the arrogance of thinking you don't need a schematic, any yet you ask questions that show you haven't got a clue as to what you are doing.

Batteries do not have anodes, and there are at least three ways you can place a transistor, but you don't want to know. Well our crystal balls are all out of battery.
Get serious.

1 Like

What 9 V battery?

1 Like

I understand, that I might annoy you by being inaccurate or using wrong terms, but by no means I intended to appear arrogant. Your really live up to your name.

But putting the personal level aside, you pointed it out correctly. I have no clue and this is exactly why I opened this topic the first way.
The MOSFET behaves totally different to my expectation. I realize, that transistors are not just transistors and the factors to consider to pick the right one are overwhelming.
I am willing to learn and all of you gave me hints how to look deeper.

I get I should have had a schematic in the first place. I didn't, because I only work on this in my rare free time and with low priority. But before I order new parts, I wanted to understand, what I did wrong.

So if any of you are still willing to help, this is what I created on Tinkercad and using the blinking sketch, it LEDs are blinking.

The final project shall have 6 of these 6-LEDS groups, so that there is a total of 36 LEDs. Each groups shall be controlled via a transistor, which is switched via the PWM pins.

The way I drew it, is also the way I have it on my real life breadboard, now. However, it took me a while to get this far, and the mentioned video helped me a lot.
Before, I tried to place the transistor closer to the positive pole of the battery, but this didn't work. I tried several locations in the circuit, but I got it only working close to the ground.
And this is why all my questions came up.

In any case, thank you for the help.

1 Like

Exactly such a 9V block.
The Arduino Starter Kit comes with a connector and I saw several videos, where people connected such a block to VIN pin.

In the moment everything is fine, although I use the battery only for testing right now and it is never connected for more than two or three minutes.

I wonder, why those batteries are not appropriate for Arduino projects.

Kind regards

Wiki says batteries had anodes since 1834. They lost them for some reason recently?

Because they have neither the capacity to supply substantial current (mA) nor to supply it for a reasonable time (mAh).

In practical terms, if you must power an Arduino from a 9 V battery - not a good idea in itself as it is ffar better to provide the proper regulated 5 V - then use a carrier with six "AA" cells which has a battery snap to match the one on the poor "PP3".

1 Like

Battery anodes & cathodes are industry-talk. In electronics discussions it's down to the negative or positive terminal.

Hi, for the completeness sake, this is the way I originally did it, but it did not work. I also played around with the pin order, but the LEDs where either always on or never.

But I learned a lot. Thank you. I will definitely take a closer look at the transistors. I was not aware, that there is a "logic level" type.
Indeed I wonder now, why the current version is running at all. But the LEDs definitely blink and I cannot distinguish the ones switched on by the MOSFET from the ones, which are not yet connected to a MOSFET. they seem equally bright.

I know I picked the wrong transistors, but would what I did not fully get.

  • Would bipolar do the job in my scenario as well?
    • I got, that they drain more current and switch more slowly, but in my case, I am not sure if this matters
  • Will my current setup with the MOSFET damage the Arduino or is the 220Ohm limiting resistor in conjunction with the 10kOhm pull down sufficient to protect the device
    • What would be the problem of continuing with my selected MOSFET. They are definitely not ideal, but are they sufficient
  • Will the 9V block cause issues, except for short lifetime?
    • Will the decreasing current flow damage the Arduino?

I don't want to appear ignorant. I totally got your recommendation. I just cannot tell, when I have the opportunity to order new parts again and if, I am not yet sure, which transistor to pick.
I am really thankful, but this was also overwhelming and definitely need to digest the whole information and the fact I was so wrong with the parts.

Thank you

Isn't the FET pinout G-D-S ?
You have the LEDs between Source and GND.
The Source should be conn'd to GND.
The LEDs (&resistors) should be between +9V and Drain.

(NPN) BJT would also work here.

The resistors are OK.

Low current should not damage the Arduino. It can cause unexpected resets or the LED brightness may be low. It will be worse when all LEDs are on or when the battery is capacity is low.

In this application it is unlikely some problem happens with your MOSFETs. Those are powerful MOSFETs intended for much heavier load, definitely an overkill for a few LEDs. They cannot be damaged in this setup.

For all of this I assume you are driving small 5 or 3 mm LEDs.

1 Like

Not all are pinned out the same, look at the data sheet for the part you have. It is probably by the picture in the top right hand corner.

I did look at the datasheet/link provided by the OP --

1 Like

The video I mentioned above also said, that it is G-D-S. He talks there about a slightly more powerful transistor than mine. Tinkercat also uses G-D-S for the nMOSFET transistor.

Thank you, I did not find it directly in the datasheet. In my case, I just assumed, that it is G-D-S. Or said otherwise: I found had to find it out the hard way since my naïve assumption was: G is in the middle and the order of S and D doesn't matter, and if it does I just flip the orientation of the transistor on the bread board.

It is a very private project. Nothing, which will ever go into production. I just got started (more by coincidence) and I am happy to do my first project which doesn't follow a tutorial.
It build something, I needed several years ago. It is a little bit late, but I think it is a great thing to start.

Yes, 36 5mm LEDs.

Looking back to the circuit.

Assuming the LEDs including resistors are the consumer X, the gate is always closed and there is a pulldown resistor and an current limiting resistor, there are the following combinations possible.

1) +9V -> X -> S -> D -> GND   <-- not possible, since current flows from D to S
2) +9V -> X -> D -> S -> GND
3) +9V -> S -> X -> D -> GND   <-- not possible, since current flows from D to S
4) +9V -> S -> D -> X -> GND   <-- not possible, since current flows from D to S
5) +9V -> D -> S -> X -> GND
6) +9V -> D -> X -> S -> GND

This eliminates 5).

That would be 2) which is also my upmost scheme and the only way I got it working.

I expected 5) and 6) also to work, especially if I consider the transistor as a "normal" switch.
But as you mentioned, 5) does not work and I haven't tried out 6), yet.

I actually hoped, that 5) would work, because this would allow all my 12 LED groups to connect directly to a common GND. But I guess I have to lead them back to the transistor. Fortunately, I have enough wire and the LEDs are far enough apart, to fit the wires there.

I have 5 from the starter kit, but I need 6 and I want to keep a few, in case I redo some of the projects. Nevertheless I will try, if the behave more then my original expectation, especially if I can achieve to make something compared to 5) running, i.e. the switch is before the LEDs.

Thank you very much for all the help. I learned a lot and gained a lot of experience.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.