Language: EN

arduino-transistor-mosfet

Controlling Large Loads with Arduino and MOSFET Transistor

In a previous entry we saw how to use a BJT transistor as an electrically controlled switch, to power loads at voltage and current levels much higher than those we could power with the digital outputs or the PWM outputs of Arduino.

In this entry we will see how to achieve the same behavior using a MOSFET transistor. MOSFETs have advantages in certain aspects compared to BJTs, but for what we are addressing in this entry, the greatest advantage is that they allow us to manipulate large loads.

However, MOSFET transistors also have their disadvantages and peculiarities, which we will see later. Thus, we will learn when it is convenient to use a BJT transistor or a MOSFET transistor, or even a combination of both.

Throughout this entry, we will constantly refer to BJT transistors and their operation, which we will take as a basis to explain MOSFET transistors. So if you are not yet familiar with their operation, it’s a good time to review the BJT transistor entry.

What is a MOSFET transistor?

A MOSFET transistor is an electronic device widely used in modern electronics. For example, it is the main component in most processors, where there can be millions of transistors in each integrated circuit.

MOSFETs are a subfamily of the FET transistor family (field effect transistor). There are many other subfamilies of FETs, such as JFETs (junction field effect transistor), CMOS, and TFT.

Like BJT transistors, FET transistors are useful in multiple applications. Some of the main ones are acting as an amplifier and acting as an electrically controlled switch. In this entry, we are interested in this latter function of the transistor.

Another similarity with BJT transistors is that there are many models of FET transistors, each with its own characteristics. They also come in a wide variety of packages, so it is not possible to distinguish the characteristics of a transistor at first glance, and you must consult its Datasheet to know its specifications.

arduino-transistor-bjt-componente

Just like BJT transistors, a FET transistor has three terminals, although their names are different from those found in BJT transistors.

  • Gate, similar to the base of the BJT
  • Source, similar to the emitter of the BJT
  • Drain, similar to the collector of the BJT

arduino-transistor-mosfet-curvas

Also, similar to BJT transistors, FET transistors have 3 operating modes, although the active region of the BJT is replaced by the linear or ohmic region. (And it’s not just a simple name change; both regions have very different operations)

  • Cut-off, the transistor behaves like an open circuit between Source and Drain
  • Saturation, it behaves like a short circuit between Source and Drain
  • Linear region, it behaves like a variable value resistor

And similar to the case of BJT transistors, to turn on a load we are interested in making the FET operate as an electrically controlled switch, for which we will use the modes in cut-off and saturation, avoiding the linear region.

However, FET transistors have important differences from BJT transistors. First, their operation is not based on the junction of semiconductor materials, but on the creation of a conduction channel between Source and Drain within a single semiconductor material. The width of this channel is controlled by the Gate terminal.

Another important difference is that the state of a FET transistor is controlled by the voltage applied to the Gate, unlike BJTs whose state depended on the current flowing through the base. Therefore, FETs are voltage-controlled devices, while BJTs are current-controlled devices.

Another great advantage is that in saturation mode, MOSFET transistors behave like a very low value resistor, while BJT transistors always imposed a voltage drop. This allows MOSFET transistors to handle enormous loads with little energy dissipation.

There are more differences between both devices that, although they do not directly influence this entry, it is worth reviewing.

MOSFETs are much more symmetrical devices than BJTs (the behavior from Drain to Source and vice versa is similar). They also have a high impedance from Gate (on the order of 100MΩ), which is a great advantage when combining them to form digital circuits.

In general, switching times are faster than BJTs. They also generate less noise and are less sensitive to temperature.

Finally, MOSFET transistors are easier to manufacture and can simulate the behavior of a resistor. This makes them great candidates for forming integrated circuits and processors.

Determining the state of the MOSFET

If we remember the BJT transistor entry, a BJT transistor behaves as a linear amplifier of the current at the base (Ib) and the collector current (Ic), with a certain hFE factor, leading to a series of models and calculations.

In the case of MOSFETs, the current flowing through the drain (Id) has a quadratic relationship with the voltage between Gate and Source (Vgs). Given this quadratic relationship, instead of proposing a mathematical model, we recommend consulting the graphs in the Datasheet to determine the transistor’s operating point.

However, to be able to use and, above all, to be able to correctly choose a transistor model for our assembly, we must understand two aspects of FET operation.

On one hand, the MOSFET transistor behaves like a variable resistor between Drain and Source. In the linear region, the resistance value depends on the voltage Vgs. Beyond the saturation point, the resistance Rds decreases drastically (this value of Rds in saturation is often referred to as Rdson).

On the other hand, the Gate of the transistor behaves like a capacitor. That is, the transistor needs to absorb a certain amount of electrical charge (equivalently, current over a certain time) to change its operating mode.

In summary, to reach saturation in the MOSFET we will need two things:

  • To exceed a threshold in the voltage at the Gate (Vgs)
  • To provide enough charge for the MOSFET to saturate

These two facts are fundamental to understanding the operation of a MOSFET and being able to choose the appropriate model for our assembly, and when it is preferable to use a BJT transistor.

Power dissipated in the MOSFET

Another fundamental aspect for designing circuits with MOSFETs is the power supported by it, since the transistor must be able to dissipate this energy without damage.

The power supported by the MOSFET is the resistance of it, times the square of the current flowing through it.

Quantitatively, for each of the possible operating zones:

  • In the cut-off region Rds is determined by Vgs, but Ics is zero, so the power dissipated is zero.
  • In the saturation region Ids is large, but Rdson is very small, so the power dissipated is very small.
  • In the linear region Ids can be large, and Rds “is not small”, so the power dissipated can be large.

Therefore, a MOSFET transistor only has to withstand a really significant power in the linear region, especially as we approach the saturation point. Once saturated, the MOSFET can handle a large current, with low energy dissipation.

Thus, if we want to use the MOSFET as a switch, we will avoid the linear region because in this region the dissipated energy is high, which turns into heat and an increase in temperature that can damage the transistor.

If the power dissipated by the MOSFET is too high, we will need to add a heatsink.

Using a MOSFET with Arduino

We come to the part of choosing a MOSFET that works correctly with Arduino, and this is where our idyllic relationship with FET transistors becomes complicated.

When we are going to choose a MOSFET we can be dazzled by the high nominal current values (20-60A), which make them seem much better than a BJT transistor or a Darlington pair (0.5-4A).

Additionally, although somewhat more expensive than BJTs, MOSFETs are still cheap devices. We will find all kinds of prices, as there are many models with different characteristics. But, in general, we can say that a common price range is between €0.10 to €0.60.

However, to choose a MOSFET for Arduino, we must consider that the outputs of Arduino operate at a nominal voltage of 5V (or 3.3V, depending on the model) and provide a maximum current of 40 mA, with the recommended maximum being 20 mA.

Most MOSFETs have a nominal Vgs voltage of 10V, so at the 5V provided by the Arduino output, the maximum current that the MOSFET can provide is much lower than its nominal current. Even in some transistor models, it may not be enough to saturate the MOSFET. This situation, logically, is even worse for 3.3V Arduino models.

Moreover, even if we accept this Id current lower than nominal, it should be remembered that the MOSFET needs to absorb a certain amount of charge to change state. With the output current limitation of Arduino, the transitions are slower and the time the transistor spends in the linear region is greater, which means higher energy dissipation and heating.

MOSFET Models for Arduino

There are many MOSFET models available, but not all are recommended for direct use with a processor like Arduino due to the voltage and current limitations on their outputs.

Common MOSFET models are the IRF520, IRF530, and IRF540, with a nominal Id current of 9.2A, 14A, and 28A, respectively. However, when using these transistors with an Arduino and a Vgs of 5V, the Id values drop to 1A, 2A, and 11A.

On the other hand, the N series, IRF520n, IRF530n, and IRF540n, with a nominal Id current of 9.7A, 17A, and 33A, when connected directly to Arduino with a voltage Vgs of 5V, the Id values drop to 3A, 11A, and 12A, better than the previous ones but far from spectacular.

To solve this, there is a special type of MOSFET called logic level transistors, designed specifically to switch at the low voltages typical in TTL. However, their price is somewhat higher than regular MOSFETs.

Thus, the series of logic transistors IRL520, IRL530, and IRL540 saturate without problems at 5V, providing an Id of 9.2A, 15A, and 28A, respectively.

But they are not the only logic MOSFETs available. Among the many models, we find the IRLZ44 that provides an Id of 50A, or the IRLB3034PbF that provides a brutal Id of 190A.

Wiring Diagram

Similar to BJT transistors, which came in two subfamilies called NPN and PNP, there are two variants of FET transistors called N-Channel and P-Channel.

arduino-transistor-mosfet-esquema

The operation of both variants is analogous, but it determines the position in the assembly.

arduino-transistor-mosfet-montaje

Mnemonic rule: The P-Channel transistor is placed in the “Positive” part of the circuit. The N-Channel transistor is placed in the “Negative” part of the circuit.

The two resistors used in the assembly are necessary for the correct operation of the system and serve different functions.

On one hand, Rg, the resistor at the Gate, serves to limit the current that the Gate “demands.” Higher values mean lower currents, and thus less consumption in Arduino. Conversely, decreasing the resistance value favors faster transitions, allowing the transistor to spend less time in the linear region, thus heating less during switching. Common values are from 470 to 4.7k.

On the other hand, Rs simply puts the transistor in a known state (GND) when the Pin is in an indeterminate state (high impedance), for example, during the program startup, which could cause the MOSFET to turn on and off unexpectedly. A high resistance value, from 100K to 1M, is sufficient to ground the Gate.

MOSFET with Inductive Loads

Just like with BJT transistors, if we use a MOSFET to power inductive loads (motors, coils, electromagnets) we must add a safety device called a flyback diode.

This diode provides a low-resistance path that allows dissipating the induced currents produced by the magnetic field of the inductive load when it is disconnected from the power supply, which could damage the transistor or Arduino.

arduino-flyback

Thus, for inductive loads and incorporating the flyback diode, the assembly would be as follows.

arduino-transistor-mosfet-montaje-inductiva

MOSFET with PWM Outputs

In the BJT entry, we saw that they were appropriate for generating an amplified PWM signal, with no more need than connecting them to an analog output of Arduino.

We might think that MOSFET transistors are even better for generating PWM outputs since they can power larger loads and their switching time is much faster than BJT transistors.

However, this is not the case. In general, MOSFET transistors are not suitable for generating PWM signals simply by connecting them directly to an Arduino output, not even in logic level transistor models.

This is because both the voltage and, above all, the current provided by an Arduino output are not sufficient to quickly saturate the MOSFET. This causes the transistor to spend excessive time in the linear region, increasing losses.

To deal with these limitations, we can:

  • Limit ourselves to small loads that demand currents lower than nominal
  • Consider replacing it with a Darlington pair
  • Create a previous power amplification stage with a BJT (we’ll see that next)

Before using a MOSFET in a PWM, it’s advisable to think a bit before making the assembly, and always keep in mind the power and temperature supported by the transistor.

Using a BJT Stage as a Driver

Throughout this entry, we have seen that the voltage and current limitations imposed by Arduino outputs (and generally by any processor or controller) force us to reduce the loads we can power with a MOSFET or to use special logic level transistors.

This situation is even worse in the case of PWM outputs, as the current limitation forces the MOSFET to remain longer in the linear region, increasing the power dissipated and its temperature.

One way to eliminate these restrictions is to use a preamplification stage between the Arduino output and the MOSFET. This stage, or driver, can be a circuit formed by a simple small-sized BJT (N2222, BC337, or similar).

arduino-transistor-driver-bjt-mosfet

This stage receives the Arduino output and provides the MOSFET with the voltage and current it needs to fully saturate, with a fast switching speed.

With this type of circuit, we can fully utilize the MOSFET, allowing us to provide large currents even in PWM outputs. However, it adds components and complexity to the assemblies.

Therefore, there is no one-size-fits-all solution for choosing when a BJT, a MOSFET directly, or a MOSFET with preamplification is more appropriate. It is a design decision that you must make individually for each of your assemblies, based on everything we have seen in this entry.

Download the Code

All the code from this entry is available for download on Github. github-full