Language: EN

arduino-transistor-mosfet

Controlling Large Loads with Arduino and MOSFET Transistor

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

In this post, we will see how to achieve the same behavior using a MOSFET transistor. MOSFETs have certain advantages over BJTs, but for our purposes in this post, 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. In this way, we will learn when it is convenient to use a BJT transistor or a MOSFET transistor, or even a combination of both.

Throughout this post, we will constantly refer to BJT transistors and their operation, which we will use as a basis for explaining MOSFET transistors. So if you are not yet familiar with their operation, this is a good time to review the BJT transistor post.

There are also commercial boards with MOSFET IRF520N to connect directly to Arduino.

What is a MOSFET Transistor?

A MOSFET transistor is a widely used electronic device in modern electronics. For example, it is the main component of 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 FET, such as JFET (junction field effect transistor), CMOS, and TFT.

Like BJT transistors, FET transistors are useful in multiple applications. Some of the main ones are to act as an amplifier and to act as an electricity-controlled switch. In this post, we are interested in the 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 are also presented in a wide variety of integrated circuits, so it is not possible to distinguish the characteristics of a transistor at first sight, and you must consult its Datasheet to know its characteristics.

arduino-transistor-bjt-componente

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 modes of operation, although the active zone of the BJT is replaced by the linear or ohmic zone. (And it is not just a simple name change, both zones actually have very different behaviors)

  • Cutoff, the transistor behaves like an open circuit between Source and Drain
  • Saturation, behaves like a short circuit between Source and Drain
  • Linear zone, behaves like a resistance of variable value

And similar to the case of BJT transistors, to turn on a load, we are interested in making the FET work as an electricity-controlled switch, for which we will use the modes in the cutoff and saturation modes, avoiding the linear zone.

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 that flowed 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 resistance of very low value, while BJT transistors always imposed a voltage drop. This allows MOSFET transistors to handle huge loads with little energy dissipation.

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

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

In general, the switching times are faster than those of 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 with them. This makes them great candidates for forming integrated circuits and processors.

DETERMINING THE STATE OF THE MOSFET

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

In the case of MOSFETs, the current that crosses the drain (Id) has a quadratic relationship with the voltage between the Gate and Source (Vgs). Given this quadratic relationship, instead of proposing a mathematical model, we recommend consulting the Datasheet graphs 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 the operation of the FET.

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

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

In summary, to saturate the MOSFET, we will need two things:

  • Exceed a threshold in the Gate voltage (Vgs)
  • Provide enough charge for the MOSFET to saturate

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

POWER DISSIPATION IN THE MOSFET

Another fundamental aspect for the design of circuits with MOSFET is the power supported by the transistor, since the transistor must be able to dissipate this energy without being damaged.

The power supported by the MOSFET is the resistance of the transistor, by the square of the current that crosses it.

Quantitatively, for each of the possible working zones:

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

Therefore, a MOSFET transistor only has to support really important power in the linear zone, especially as we approach the saturation point. Once saturated, the MOSFET is capable of supporting a high current, with low energy dissipation.

Therefore, if we want to use the MOSFET as a switch, we will avoid the linear zone because in this zone the dissipated energy is high, which becomes 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 heat sink.

USING A MOSFET WITH ARDUINO

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

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

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

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

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 in the case of 3.3V Arduino models.

Furthermore, even if we accept this lower Id current compared to the nominal, it must be remembered that the MOSFET needs to absorb a certain amount of charge to change its state. With the current limitation of Arduino outputs, the transitions are slower and the time the transistor spends in the linear zone is longer, which results in greater energy dissipation and heating.

MOSFET MODELS FOR ARDUINO

There are many models of MOSFETs available, but not all are recommended for direct use with a processor such as Arduino due to the voltage and current limitations in its outputs.

Common models of MOSFETs are the IRF520, IRF530, and IRF540, with a nominal current Id of, respectively, 9.2A, 14A, and 28A. 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 current Id of 9.7A, 17A, and 33A, when connected directly to Arduino and a Vgs voltage of 5V, the Id values drop to 3A, 11A, and 12A, better than the previous ones but still far from being spectacular.

To solve this, there is a special type of MOSFET capacitor called logic-level transistors, specifically designed to switch at low typical TTL voltages. On the other hand, the 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, respectively, 9.2A, 15A, and 28A.

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

CONNECTION DIAGRAM

Similar to BJT transistors, which are presented 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 on the “Positive” part of the circuit. The N Channel transistor is placed on the “Negative” part of the circuit

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

On the one hand, Rg, the resistance at the Gate, serves to limit the current that the Gate “demands”. Higher values ​​mean lower currents, and therefore lower consumption in Arduino. On the other hand, reducing the value of the resistance favors faster transitions, so that the transistor spends less time in the linear zone, and heats up less during the commutations. Usual values ​​are 470 to 4k7.

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

MOSFET WITH INDUCTIVE LOADS

Exactly the same as with BJT transistors, when using a MOSFET to power inductive loads (motors, coils, electromagnets), we must add a safety device called a Flyback diode.

This diode provides a path of minimum resistance, which allows it to dissipate the induced currents produced by the magnetic field of the inductive load when it is disconnected from the current, and that could damage the transistor or Arduino.

arduino-flyback

Therefore, 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 post, we saw that they were suitable for generating an amplified PWM signal, without the need to connect them to an Arduino analog output.

We might think that MOSFET transistors are even better for generating PWM outputs, since they are capable of powering 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 is not sufficient to quickly saturate the MOSFET. This causes the transistor to spend too much time in the linear zone, increasing the losses.

To deal with these limitations, we can:

  • Limit ourselves to small loads that require less than the nominal current
  • Consider replacing it with a Darlington pair
  • Make a previous power amplification stage with a BJT (we will see this below)

Before using a MOSFET in a PWM, it is advisable to reflect a little before making the assembly, and always take into account the power and temperature supported by the transistor.

USING A BJT STAGE AS A DRIVER

We have seen throughout the post that the voltage and current limitations imposed by the Arduino outputs (and in general by any processor or automaton) force us to reduce the loads that we can power with a MOSFET, or to use special logic level transistors.

This situation is even worse in the case of PWM outputs, since the current limitation forces the MOSFET to spend more time in the linear zone, increasing power dissipation and 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 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 saturate completely, and with fast switching speed.

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

Therefore, there is no single solution for choosing when it is more appropriate to use a BJT, a MOSFET directly, or a MOSFET with preamplification. It is a design decision that you must make individually for each of your assemblies, according to everything we have seen in this post.

Download the code

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