Questions about driving Mosfet by Digital Aurdino pin. - Page 1
Forum section: electronics / beginners

author: josr
author_rank: Contributor
timestamp: August 21, 2020, 07:39:22 pm
content: Hi,As professional Software engineering I am new in the electronics hobby. I am trying to drive a 12-volt fan via a Logic MOSFET IRL540.I have a few questions about this:Is there any reasons to place the MOSFET in the positive or negative side of the FAN/load? See the pictures below. Should I choose design 1 or 2 or does it not matter? Why?The MOSFET is connected to a digital output pin on a Aurdino (5V max 40 mA). Should I add a current limit resistor (R2 in the schematic below) and if yes how can I calculate the value? What is the minimum current the MOSFET need to 'turn on'? Which property in the datasheet is explaining this?Is there any need to place a pull down resistor (R1 in the schematic below). And if so, what value?Is there anything other missing?Thanks,

author: newbrain
author_rank: Super Contributor
timestamp: August 21, 2020, 08:08:29 pm
content: QuoteIt matters.If you are using a N-channel mosfet (as the IRL540), the more positive is the gate is with respect to the source, the more current can go through, following the curves on the datasheet.Take your Design 1: what happens when the gate becomes more positive?More current arrives to the source from the drain, but this current goes also through the load (let's consider it a pure resistance), and by Ohm's law it generates a voltage difference across the load.This difference raises the potential at the source, so the the voltage difference from gate to source is less -> less current.With this mechanism, the source will never be able to raise to more than the voltage at the gate, and will stay well below, depending on the characteristics of the mosfet (at least 1-2 V below, given the threshold voltage for 100 µA).In practice, it's a negative feedback and the equilibrium point is usually found graphically (on the curves) or with simulation/models.So, you should definitely go for Design 2, that does not have this problem: Vgs is always the same, independent of the load.As for the resistor, yes, a small resistor is in general used to the gate, and - as a safety measure not to leave the gate floating if it's disconnected - a pull-down too, but not in your R1 position, rather directly from gate to ground.The gate resistor depends on the speed you want/need the mosfet to switch, but in this case I would go for something in the 100 Ω ballpark.The pull-down resistor can be in the 10 kΩ range.

author: Manul
author_rank: Super Contributor
timestamp: August 22, 2020, 12:25:57 am
content: Most was already answered. Some additional comments.Quote from: josr on August 21, 2020, 07:39:22 pmMOSFET is controlled by gate voltage relative to source terminal. To put it simply, gate has a capacitance to source, called Input Capacitance. You can find that in a datasheet. So gate does not need current, but current is needed tochangeits voltage. Hope that makes sense. Imagine that a capacitor is at zero volts. If you apply 5V from MCU output, that capacitor is like a short circuit and current is big until it charges. You may call it inrush current, yet this terminology is more used for power circuits. Once the capacitor is charged and the voltage equalizes - there is no current. Its like filling a cup with water.Resistor R2 will limit the current and consequently the speed of voltage change. In case of driving it directly from MCU you may wish to limit the current to be on the safe side in regard to output pin current limit. So for example 5V and 100 Ohms resistor will limit the current to 50mA maximum possible, plus because Arduino output also has some internal resistance, around 30 - 60 Ohms I believe, the current will never ever, even for a short moment exceed the 40mA limit. Thats good design. So you select this resistor based on MCU you are using.Quote from: josr on August 21, 2020, 07:39:22 pmNo, if the fan does not have big capacitance or inductance and it is more or less resistive load.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 22, 2020, 02:52:25 am
content: The ways in which the different transistors workbipolar, NPN & PNPJ-Fet N-channel and P- channel,MosFET's, Als N & P channel and on top of that Enhancement (most) and depletion. versions.A great way to learn is to add practical experience to theory.So build both circuits on a breadboard, and instead of the "arduino pin", use a potentiometer.Also do some experiments with other transistors, such as the bipolar NPN and PNP transistors.A few extra remarks:The gate of a mosFet is quite sensitive to ESD damage. If you are planning to experiment a lot with them, it's a good idea to solder a bipolar 15V TVS diode directly between the gate and Source.When using a potentiometer as a variable voltage source, on a breadboard, then always use a series resistor from the wiper to limit the current if the potentiometer is in the extreme positons, or else you can easily damage the potentiometer. (Been there, done that).Bipolar transistors react to currents though the base (Base- emitter voltage is almost constant around 600mVmosFET's react to voltages on the gate (relative to Source) Depending on the fet, it "opens" at a voltage around 2 (sometimes even lower) to 5 Volt.5V is not always enough to reliably "open" a mosFET.- Depletion mosFET's are "normally open" and need a negative gate voltage to close (these are not so common)-A fun experiment is to put a capacitor between Gate and source, then touch the gate with one hand, and alternate the other hand between GND and 5V (or 12V).Your body will conduct enough current to charge the capacitor and open / close the fet. (Without a capactor it also works, just quicker).If you don't use a capacitor, the gate will "float", and your mosFET may switch at seemingly random intervals.

author: Peabody
author_rank: Super Contributor
timestamp: August 22, 2020, 03:13:43 am
content: Quote from: newbrain on August 21, 2020, 08:08:29 pmI disagree. The location of R1 is correct as shown in Design 2. If you move it over to the gate, you will create a voltage divider, and the gate will see the midpoint of the divider, not the full 5V output of the GPIO pin.

author: ledtester
author_rank: Super Contributor
timestamp: August 22, 2020, 03:18:25 am
content: Quote from: Peabody on August 22, 2020, 03:13:43 amBut generally the pull-down is 10K while the gate protection resistor is ~ 100R, so it only attenuates the voltage by 1%.

author: DrG
author_rank: Super Contributor
timestamp: August 22, 2020, 03:37:00 am
content: I have used the design shown in #2 in the original post several times. I always use a pull-down (R1) and, yeah, 10K or so. I admit that I struggle with R2 and its value, especially when I am not going to be turning it on and off rapidly.So, as a Non-EE, I probably have little of value to offer on the circuits shown, except....the OP is showing a typical 4 pin PC fan. The Arduino out pin (one of those that can be used as PWM out) can/should go directly to PWM input (with some protection against errant 12V if you worry). No need for the IRL540 at all as the driver circuitry is inside of the fan. There is GND pin on the connector (which needs to be connected to both the Arduino GND and the 12V fan GND. In fact, I'm not sure it would work with either of those circuits unless PWM is tied to 5V.Am I way off?Edit: Of course, the specs on the fan should be consulted but it sure looks like the typical 4 pin PC fan as labelled.Edited again: There is a reason why you still might want to use one of those circuits if it is a PC 4-pin fan because, as I recently learned, even with a 0% PWM, the fan will still run...and that is by design (see this threadhttps://www.eevblog.com/forum/beginners/fan-controller-circuit-with-an-op-amp-and-a-led/msg3178298/#msg3178298and the link to the standard in one of the messages). So, if you need the fan to be completely off at some times, maybe you do want an additional circuit. It will use another Arduino GPIO though.

author: josr
author_rank: Contributor
timestamp: August 22, 2020, 10:14:55 am
content: Quote from: Doctorandus_P on August 22, 2020, 02:52:25 amThanks for all replies. Can I also use 400V TVS?What is the purpose of all this volt rating?

author: Circlotron
author_rank: Super Contributor
timestamp: August 22, 2020, 11:44:17 am
content: Quote from: josr on August 22, 2020, 10:14:55 amA 15V TVS diode will allow up to approx 15 volts across it in the reverse direction and beyond that voltage it starts to grab on tight and not let the voltage become greater than that. Think of a 15 metre length of rope gradually being drawn out straight. No effect until you run out of length, then it won't let it go any further. But you *can* break your rope or TVS if you try hard enough. A 400V TVS won't do anything until the voltage across it gets to 400V, and by that time the mosfet gate-source junction is long dead. Last time I looked, mosfet gate-source were generally rated to +/- 20V and some I tested once failed at about 35-40V. With a normal mosfet it is not usually necessary to go beyond 10-15V and with a logic level mosfet like you have, 5V gets things happening just fine.

author: josr
author_rank: Contributor
timestamp: August 22, 2020, 03:31:53 pm
content: Sorry for keeping asking questions, but should that TLS be an uni- or bidirectional diode? I assume uni-directional is OK? So with cathode attached to the gate, and anode to the source/GND?

author: Manul
author_rank: Super Contributor
timestamp: August 22, 2020, 07:14:19 pm
content: Quote from: josr on August 22, 2020, 03:31:53 pmYes, it can be uni-directional if you do not use negative gate voltage drive. And you do not. So it will clamp not symetrically, positive lets say 15V and negative around -0.7V or so.But do not be very scared about esd, normally if you do not have wool carpets and synthetic cloth everywhere you will not damage mosfets every day, especially big ones, with high input capacitance.