DISCLAIMER: If you choose to attempt any of these modifications, you assume all risks thereof. I just wanted to share my experiences here. Neither Eaglemoss, nor myself, are responsible for any damages that may occur.
While we can usually connect low-current circuits directly to our Arduino DIGITAL/ANALOG input/output (IO) pins without much trouble, there is only so much current that the Arduino can safely supply. When a Uno or Nano is connected to a power supply (not via USB), the Arduino’s onboard power regulator is used. Therefore, each IO pin has a maximum current output limitation of 40 mA. However, it is recommended to keep the max current output per IO pin to about 20 mA. Also, the maximum current allowed across all output pins is 200 mA. If we were to exceed these limits, we could easily pop one of the Arduino’s internal fuses or worst case, fry the Arduino. Either way, the Arduino becomes unusable.
This limitation quickly becomes a problem when we want our Arduino to switch things ON and OFF that draw more than 20mA. For example, the LED Strip in my saucer section for the Windows alone draws about 2 Amps (2000 mA). We simply cannot hook this directly to an Arduino IO pin as it would far exceed the current capability of the pin (and the entire Arduino for that matter). Therefore, we need to use ‘external’ switching to control circuits like this. The two most common ways to do this are relays and transistors. I will cover both here.
Relays are mechanical switches that are activated by energizing an electromagnet that pulls two metal contacts together against the force of a spring. They are cheap and effective and can be easily purchased online For example, here is an example of 5VDC-triggered relays I found on Amazon:
We could power a relay module like this with 5VDC to the DC+ and DC- terminals, then send either a 5V (HIGH) signal or 0V (LOW) trigger signal to the IN terminal via a digitalWrite command via our Arduino. Many Relay Boards have jumpers on them that let you choose which input signal state will energize the relay (HIGH or LOW). This trigger signal would then activate the relay hiding inside the large blue box.
On the other end of this relay board, we find the connections to the relay itself. They are typically marked NO, COM, and NC:
- NO = Normally Open
- COM = Common
- NC = Normally Closed
When there is no trigger signal, the relay is not energized and the spring inside the relay forces the Common terminal to contact the Normally Closed terminal. Normally Closed is the default state of a relay, leaving the Normally Open contacts disconnected.
When we then apply a trigger signal, the electromagnet inside the relay is energized and it pulls the Common terminal into contact with the Normally Open contacts, leaving the Normally Closed contacts disconnected.
The point of using a relay in this way is that we can energize the relay with a very low power trigger signal. However, the relay itself can switch ON and OFF a much higher power throughput. For example, the board I have shown here only takes 5 mA of current at 5 VDC to trigger the relay. But between the relay terminals we can pass up to 30VDC at 10 Amps. That equates to 300 Watts of power throughput, way more than our poor Arduino could handle! If we again think about my saucer LED Strip, it takes about 10 Watts (2A @ 5VDC). A relay like this one could easily handle the power needs.
While relays would easily solve the problem of switching higher currents, there are indeed some drawbacks:
- Relays are bulky
- Since relays are mechanical by nature, they have moving parts that could fail over time
- You can usually hear the relay click when it is energized and de-energized
- A relay only has two states, energized or not energized. This means we could not use a relay to dim LED circuits with PWM
- It takes some time for the relay to change state as the switching contacts are physically moving back and forth
Because of the limited space inside my Enterprise model, and I wanted a quiet model because I use sound effects, and the higher-current circuits I need to switch are all on PWM Arduino pins for dimming capabilities, I decided to use transistors instead.
Transistors are electronic components that can amplify or switch electrical signals. They can be found in all sorts of shapes and sizes:
Knowing exactly how a transistor works can get complicated, so I will try to keep this simple. When using a transistor as a switch, it operates very similar to a relay. A small electric current passing through one part of a transistor can make a larger current flow through the other part.
Transistors can basically be split into two types: the original Bipolar Junction Transistor (BJT) or the newer Field Effect Transistor (FET). BJTs are controlled by current (Amps), while FETs are controlled by voltage (Volts). Since BJTs require different currents to trigger them and we cannot control the current output of Arduino pins, BJTs are not a great choice when using an Arduino. Additionally, BJTs consume power while operating which is wasted in the form of heat. This heat also affects how the BJT works. Both of these things are undesirable in most projects.
Therefore, I decided to go with FETs for my Model Remodel. There are many different FETs available, but the ones I am using for my Model Remodel are MOSFETs.
What is a MOSFET?
A MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor) is by far the most dominant transistor in use today. MOSFETs (also called a MOS) are popular because of the low voltages needed to trigger the transistor, low heat generation, and extremely fast switching capabilities. The CPU and memory chips in the device you are reading this article on are crammed full of MOSFETs.
MOSFETs themselves are available in different configurations. For my project, I am using Logic Level Enhancement-Type N-Channel MOSFETs. This configuration can be described as follows:
- Logic Level means the transistor turns fully ON with a fairly low trigger voltage, somewhere between +3 and +5 volts DC.
- Enhancement-Type means the transistor is in the OFF state by default (similar to using the Normally Open contacts of a relay). In contrast, a Depletion-Type FET would be in the ON state by default.
- N-Channel means it is meant to be placed on the negative (Ground) side of the load being switched. In other words, between the negative terminal of the load and Ground. In contrast, a P-Channel MOSFET would be placed on the positive side of the load – between the positive (+) power supply and the positive terminal of the load. While both N-Channel or P-Channel MOSFETs could be integrated into Arduino projects, I went with N-channel as they are more efficient, switch faster, and run cooler.
Using a MOSFET with Arduino
A typical MOSFET has three terminals: Source, Drain, and Gate. These terminals may or may not be marked on the transistor itself, and they can be in any order. Check the datasheet on your specific MOSFET to be sure:
With an N-channel MOSFET (also called an NMOS), the Source terminal is where the negative (- or Ground) side of the power source is connected. The Gate terminal is where the lower positive (+) voltage/current trigger input signal is connected. The Drain terminal is then connected to the negative (-) side of the load.
In this basic diagram, a LED (the load) is connected through a N-channel MOSFET via a resistor. If we were to turn pin 3 ON by using the digitalWrite(3, HIGH) command, the MOSFETs Gate would be energized and power would flow through the LED:
Of course, we could just power this single LED straight from the IO pin as it only needs 20 mA. But, that is not what we are doing here. We want to be able to switch a higher current than the Arduino can supply on its own.
If we had lots of LEDs to turn on (such as those found on a LED Strip), this is where a transistor shines. The MOSFET can be switched ON and it would handle the ~100 mA needed to drive all five LEDs shown here – the Arduino cannot:
If we were to connect a multimeter between the negative power source and the MOSFET’s Source terminal, we can verify how much current is passing through the MOSFET. There is just no way the Arduino would survive if we powered all these LEDs off an IO pin directly. This is why I am using MOSFETs to act as switches for my high current components!
I wanted to mention one more benefit of using MOSFETs: most of them can support PWM signals into their Gate terminal (see my Dimming LEDs page for an explanation of PWM). This means we can easily use the PWM-enabled pins of our Arduino to dim a high-current component such as an LED Strip by running it through a MOSFET.
Everything up to this point has been to help explain how MOSFETs can help us control currents larger than the Arduino can provide. Luckily, pre-made MOSFET boards are common and readily available. For my Enterprise model rebuild, I found these High-Power MOSFET Boards on Amazon and they have been working perfectly so far. They can switch up to 400 Watts, have parallel MOSFETs for redundancy, a low voltage trigger, support for PWM, solder terminals for both the Arduino Ground and Trigger (Gate) connection from an Arduino IO pin, and larger screw terminals where the positive and negative high-currents pass through. We don’t even have to worry about correctly connecting the Source and Drain terminals at all! I will be be using four of these module in my build (one in the saucer and three in the stardrive).
Next Arduino Page
PLAYING SOUNDS – Using a external sound board to play audio with Arduino