August 18, 2017
It’s time for an easy MOSFET wiring guide. There haven’t been too many, so I’ll add mine to the list. I’ve mainly seen the use of high-amperage micro-switches in this community, but as tech in blasters (microcontrollers, brushless motors) continues to expand and the motor-arms-race delivering new, high-draw motors to the scene, it’s time for another MOSFET guide without confusing the beginners while at the same time, enlightening the experienced modders.
This guide will be super in-depth, and will hopefully cover a ton content so you could start it off as a beginner, and come back to it as a pro, and learn something every time. No prerequisites required - just a basic understanding of electricity! For the more advanced and technical parts, a high-school level understanding of physics and chemistry may be required. Read what you understand, and skip what you don't. There will be some parts which will be intimidating to beginners, but that’s the point! There’s always something new to learn in electronics, whether that be more electronics, physics, or microcontrollers.
MOSFET
A MOSFET is a type of transistor. A transistor is a switch relying on an electrical signal to allow current to flow, rather than a physical movement like a switch.
I know the first time someone told me that, I got super confused. Immediately below is a beginner friendly description of a transistor, and a the further down you go, the more technical it will get. If you understand above, that’s all you need to know about a MOSFETS’s functionality. Feel free to read more below, or skip to the next section: CTRL + F - “MOSFET PINOUT”.
Let’s take a look an an example of a switch. For this example, a light switch. In its resting state, electricity will not flow - the light bulb is not on. But when you flick the switch, the light turns on - electricity is flowing. Notice how it relies on manual mechanical energy, your finger pressing on it, for the current to flow. Whats often happening in these switches is the movement of a metal piece which touches different metal things for electricity to flow as desired.
Internals of rocker switch
Now that you know how a switch works completely, let’s look at a transistor now. Remember, a MOSFET is a type of transistor, so they work exactly the same. If you didn’t already know, transistors are one of the most amazing inventions ever, on-par with fire and the wheel (not joking!). Everything computer/digital = transistors. They revolutionized computing technology, and all of our computers (laptops, phones, microcontrollers, watches, calculators) are based on transistor architecture. In your Intel Core i7 processor, there are over fourteen billion transistors! For comparison, the earth is only about 25,000 miles in circumference. In your phones, transistors can be as small as seven nanometers, and the smallest ones invented are around one nanometer. A nanometer is a billionth of a meter, so transistors have gotten down to the size of a few atoms across now.
Okay, enough lecture on how amazing transistors are (hint: they’re really amazing!). Let’s see how they work. Remember how a switch relies on a manual input to control the electrical behavior? Well, a transistor uses electrical input to control the electrical behavior.
A transistor
Imagine a switch which has two pins. The two pins will conduct electricity when the switch is pressed, and will not conduct electricity when the switch is not pressed. Observe the above picture of a transistor, and notice how it has three pins. Two of the pins will allow for electricity to conduct when the other pin is fed electricity. We’ll call this “other pin” the signal pin, since it acts as a signal which signals when the other two pin should conduct electricity.
So transistors are like switches, but they’re awesomer. They can be MUCH smaller and MUCH faster.
Tl;dr Transistors are like switches, but are awesomer since they rely on an electrical input, rather than manual input like a switch.
Now that you know how a transistor works, it would be extremely helpful to understand the pins as well
A MOSFET is a transistor, and a transistor has three pins. Therefore, a MOSFET has three pins.
MOSFET Pinout
Take a look at that picture. The pins are labeled:
“Two of the pins will allow for electricity to conduct when the other pin is fed electricity” is the same as “The Drain and Source will conduct electricity when the Get gets fed electricity.
You can think of the gate that acts like a gate. When the gate is open (it gets fed electricity), electricity can flow through the MOSFET.
You don’t really need to remember these fancy names, but they will be Extremely helpful for the rest of this write-up. Don't fuss too much over remembering them, the concept is much more important. The more you are exposed to the words in context, the better and faster you will understand them. Hopefully I use them enough in this write-up that you’ll know them front-and-back by the end of this.
And that’s all it is for understanding MOSFETs! I hope you completely understand how they work, and the pins. It gets a bit more technical from here on about MOSFETs, so feel free to read through it or skip to the next section: CTRL + F - “Why Should I Even Use a MOSFET?”.
There are two different types of MOSFETs, an “N-Channel MOSFET” and a “P-Channel MOSFET”. You can think of it like this: an N-channel MOSFET connects negative of the battery to negative of the load, and a P-channel MOSFET connects the positive of the battery to the positive of the load. Since the N-channel MOSFET connects the negatives, we call it “Low-side switching”, and the P-channel MOSFET as “High-side switching”. If you’re more familiar with BJTs, a P-channel MOSFET would be equivalent to a PNP BJT, and an N-channel to an NPN.
Although both can be used, in this build, an N-channel MOSFET will be used. Here are some advantages of N-channel MOSFETs over P-channel ones:
MOSFET is an acronym:
Metal-Oxide Semiconductor Field-Effect Transistor
MOS, or metal-oxide semiconductor, describes the chemical properties of the semiconductive materials which makes the MOSFET work. Recall from the media and chemistry class that a semiconductor includes elements such as Silicon and Germanium. Many transistors rely on Silicon chemistry, with special enhancement substances injected, or ‘doped’, for enhanced performance.
This metal-oxide layer insulates the input voltage from the output current as well, so the input voltage interacts with the output current through electromagnetic fields, as described below.
FET, or field-effect transistor, describes the type of transistor. A more ‘traditional’ transistor, such as a BJT, works using current, assuming the threshold voltage has been exceeded, to determine its conductive behavior, as the current flowing through the base directly interacts with the current flowing through the collector and emitter. While a BJT’s conducive behavior is more reliant on current, a FET’s conductive behavior is more reliant on voltage.
FETs work on electric fields, as described in the name. When an electric potential difference between the gate and source is observed, an electric field is created. Since we are using an enhancement mode FET, rather than a depletion mode FET, pulling the gate-source voltage (Vgs) to high will turn the FET on, so current can flow through the drain and source. The strength of the electric field formed is proportional to Vgs, and the stronger the electric field, the lower the internal resistance of the device. Therefore, a input higher voltage will result in better current flow of the device.
Remember, more internal resistance, or resistance between the drain and source (Rds) means the less energy goes to your load, so a decrease in efficiency. A higher resistance will also result in more heat generation, and more heat is often not a good thing. A higher junction temperature also results in a higher resistance, and this higher resistance results in more heat generation, and so on. It’s like an infinite loop. Extremely high junction temperatures (Tj) can also destroy the internal chemistry of the FET. The MOSFET linked below in the parts section can handle up to 175C, so you won’t need to worry about heat too much in your build. The chemical and electrical properties of a FET will vary a little bit based on Tj, so check your datasheets on that. If you’re reading this part, I assume you have the technical capability to be able to read data sheets. Luckily, most MOSFETs include a heat-sink integrated into the device, as well as decently high operating temperature thresholds.
Ideal Vgs for MOSFETs are between eight and twelve volts, depending on the specific model. Check the data sheets. Voltage from your LiPo battery, whether that be 2S or 3S, works perfectly fine. Depending on the particular MOSFET, Rds may be as low as a few mΩ, at an ideal state. The MOSFET linked in this write-up has an Rds of around 2mΩ.
To summarize MOSFETs:
All this fancy talk about MOSFETs, and I didn’t even explain what’s so good about them.
When we modify blasters, we often do a few things:
One of the above modifications results in or is a result of the avalanching modification requirements. Motor replacement calls for a higher ability of discharge from a battery = battery replacement. Battery replacement = higher current = rewire + switch replacement.
Let’s take a look at the few options we have for controlling our high-amperage circuits:
Top of the line motors, at the moment, may draw close to 50A at stall. The highest rated microswitches in in the community I’ve seen are 21A microswitches. 50A > 21A. But high end motors only draw 50A for a fraction of a second, so the switches should be safe, right? For now. I’ve never heard of anyone damaging a 21A switch from high-draw motors anyways.
But in the time of a motor-arms-race, more motors are being release, and these motors are getting more powerful. This means higher current draw. Soon, even our 21A switches won’t be able to keep up with all these motors. But MOSFETs will. Well, they already do. They are currently used today to control high-power appliances, including street lights and airplanes.
High-amperage switches don’t fit directly into blasters. You’ll need to dremel out a lot of the stock switch mounting area, orient the switch correctly, and then adhere it into place. You also have possibly 100A of current running through your grip, millimeters away from your hand. That doesn't sound safe.
Tl;dr Requires shell modifications, not future-proof
A relay
Although I haven’t personally seen the use of relays too much in builds, they are another basic option to control high-draw motors. They are also quite advantageous over high-amperage microswitches.
Relays are literally switches controlled by a magnet. But that magnet, known as an electromagnet, can be turned on and off. So there is a physical moving part which toggles position based on whether the electromagnet is on or not. A low power signal controlling the electromagnet will determine whether current can flow, similar to a transistor/MOSFET.
Relays can be advantageous over high-amperage microswitches since shell modification may not be necessary. The stock NERF switch may be used as a ‘signal’ to control electricity flow through the relay.
Although relays are reign supreme over high-amperage switches in terms of shell modifications, they fall short in the same ways. Some of the highest-power relays, automotive relays (yep, the stuff used in cars), can get quite expensive and are rated for only 30A - 40A.
Cons of MOSFET: May be electrically complex for beginners. This write-up changes that, so there is no excuse not to use MOSFETs.
Tl;dr MOSFETs are better.
Now that you know why MOSFETs are objectively superior, feel free to go onto the technical part where. If not, skip ahead to the next section: CTRL + F - “How it all Works - Putting all the Concepts Together”
I’ll be going over pulse-width-modulation (PWM) here, and specifically, its relevance to tech in blasters. When I say tech in blasters, I don’t mean 3D printed components or wiring looms, I mean programmed microcontrollers, such as in Eli Wu’s builds, Project FDL, Ammo Counters by AmmoCounter.com, and my upcoming Smart Blaster kits.
So what is PWM? Other than sounding super fancy, it’s also super useful. First, I need to discuss the difference between digital and analog components.
What does it mean, digital? Well, I’m sure we’ve all heard of it, “The digital age” and stuff like that. Digital often induces imagery of computers, and binary, 1’s and 0’s. That’s exactly what digital describes, binary. Digital means involving only two values. For example, your light would be digital, since it only has two values, ON and OFF, or the status of your phone power being at 100% battery, TRUE, or FALSE. Your phone is either at 100% battery, or it’s not at 100% battery. Tying this to computers, remember how computers only “see” in binary, 1, and 0: 101010001001. Binary only has two values, 1, and 0, therefore, it is called a digital value.
What about analog? While digital pertains to states which only have two values, analog pertains to states which may have more than one value. For example, the temperature. There are many different values the weather can be, 78F, 92F, or even 23F. Those are only three, but there are an unlimited number of different temperatures (mathematically, not physically) possible when we include decimals. Another example would be the speed of your car. It could be going at 60mph, or 61mph, or 73mph, or 5mph.
Tl;dr Digital = only two values (light - ON or OFF), analog = more than two values (speed - 60mph, 25mph, 3mph, etc.)
Now, what about our motors in our blasters? What would best describe their output state - analog, or digital? Well, in our blasters, they really only have two states, ON, or OFF. But motors, like a car, can be analog. They can be off, on, in the middle, and anything in between.
So we know it is physically possible to control the speed of our blaster’s motors. This yields us a variable control of dart velocity, power consumption, and rate of fire (Hint Hint an upcoming Smart Blaster kit). If we want our darts traveling at 130fps instead of the maximum 150fps for confusion tactics against our enemies, we can crank down on speed of the motors a bit. If we want to shoot our Rapidstrike a bit slower in terms of darts/sec, to conserve ammo without burst-fire (Hint Hint another upcoming Smart Blaster kit) then we could slow down the pusher motor a bit. And we can control these speeds using a microcontroller.
A microcontroller is just like a computer, but quite a lot smaller than your laptops. They're also mounted on ICs. Some examples include an Atmega328 and a TI MSP430G2452IN20, but NOT a Raspberry Pi. A Raspberry Pi as a microprocessor. An Atmega328 and a TI MSP430G2452IN20are NOT microprocessors. An Arduino and a Teensy is NOT a microcontroller or a microprocessor, it simply houses a microcontroller. DON’T call an Arduino a microprocessor, because it’s not. Call it a microcontroller, since it’s basically a shell for one. I’m super anal about these terms but I don't know why lol.
But explained above is how computers are digital, and motor speed is analog. Analog != digital, so how do we do this? Well, there’s this fancy thing called PWM. It’s basically just returning an analog output, such as motor velocity, from a digital device, such as a computer/microcontroller. It works by toggling output power super super fast, sometimes many kHz, depending on the device outputting the power.
Let’s say we have a 10W power source. We’re only talking about power here, but remember Power = Voltage * Current, Watts= Volts * Amps. PWM controls power. And a circuit that looks like this. Notice how the power source goes through a PWM device, and the PWM device then outputs to a motor. The PWM device is a digital device.
PWM circuit
If we leave the PWM device at high the entire time, then the output will be at 10W. If we leave the PWM device at low the entire time, then the output will be at 0W. If we toggle power (power ON and OFF, a digital value, compatible with the computer) in the PWM device so fast that on average, 50% of the time, the power is high (10W), and the rest 50% of the time, the power is low (0W) it will average out at 5W, so the output will be 5W. Now, what if we toggle the PWM so fast that on average, 70% of the time, the power is high, and 30% of the time, the power is low?
It will average out at 7W, so the output will be 7W.
Notice how I’m getting an analog value (10W, 0W, 5W, 7W, and anything in between) out of a digital device (PWM device). Now, we can replace the PWM device with something like an Arduino, and accomplish the same thing.
I won’t be going over too much how PWM works, but I hope you understand the basics. Now let’s tie this back into MOSFETs.
Recall how power must be toggled in the PWM device “super super” fast. When working with Arduino, this will be around 600 Hz, or 600 times a second. With dedicated PWM devices, this can get up into the Kilohertz, or even Megahertz. Can you move your finger on the trigger that fast? If you could, then theoretically, you would be able to achieve PWM with your hands. Unfortunately, the switch can’t. Even with a relay, PWM can’t be practically achieved. Relays take about 20 milliseconds to change state, so only about 50 Hz. Not even close to fast enough. So we need to switch from electromechanical to electrochemical.
Here’s where the MOSFET comes into play. Remember how the MOSFET is a transistor, and transistors are in computers. Consumer computers can clock as fast as a a few Gigahertz, or a few billion times per second. Yep, that’s how fast transistors are. So MOSFETs are more than suitable, because of their speed, for variable motor control.
Tl;dr MOSFETs are so fast you can do analog outputs with them.
Almost time for wiring! I truly believe the concepts behind how this build works is much more important than how to assemble it. A robot can assemble this, but can’t understand the concepts. You can do both.
Let’s combine all the concepts of the transistor, MOSFET, and MOSFET pinout together to create a basic operational diagram of the circuit.
First, the MOSFET needs some sort of electrical signal to turn on. This signal will come from a switch, any switch can be used, but I use the stock switch. Super little current will flow through the switch, so you won’t need a huge 21A switch. That’s what’s so great about a MOSFET setup, the stock switch can be reused, so zero shell modification is necessary.
Signal diagram
Now, this electrical signal needs to go into the MOSFET, to the Gate pin. You can see in the diagram above that when the switch is pressed, the gate is fed electricity, so electricity can flow through the other two pins of the MOSFET, the drain and source.
Source-drain diagram
Now, let's look at the complete diagram. The Signal Diagram has just been expanded upon. Now, when the switch is pressed and the MOSFET allows electricity to flow through the drain and source, we see that the entire circuit is complete! Positive of the battery goes into the load, and the load is connected to ground/negative. A full circuit!
It’s about to get a bit technical here. I’ll go over the functionality of a the resistor and diode, it’s pretty complex stuff. You know the drill to skip: “Parts and Tools Required” This will be the last technical section.
I will discuss two components here, why they’re needed: the resistor, and the diode. The diode is much more complicated in its functionality.
A Sneak Preview of Some Schematics:
Schematics of pulldown resistor
This resistor is known as a “pull-down” resistor, since it connects between the gate of the MOSFET and ground. When working with electronics, you will see “pull-up” and pull-down resistors a lot. pull-up/down resistors are used to ensure given no other input, a circuit assumes a default value. In the case of this build, since a pull-down resistor is being used, the default value is pulled to low. This makes sense, since when the MOSFET is off, the Vgs (input voltage, or potential difference between the gate and source), is zero.
But why would we need this pull-down resistor if no current is flowing to the gate when the switch isn't pressed? Well that’s the thing. It’s not that simple. The voltage as the gate is said to be “floating”. This means the voltage could be many different values, and that will of course mess up how the MOSFET will behave. A small input voltage, say, from the electrostatics of your finger, could be all that’s needed to turn the MOSFET on. This isn’t good, so we use the pull-down resistor to ensure that when the MOSFET is off, it’s off for good.
A Sneak Preview of Some Schematics:
Schematics of flyback diodeF
This diode is known as a “flyback diode”
Motors are extremely interesting works of techonology. Simply put, it’s a converter between mechanical energy and electrical energy, and it can work in both directions: as a generator, and as a motor. When the motors act as a generator, a voltage in the reverse direction is formed. Voltage is the force driving the current, so we also call it electromotive force, or EMF. Because the voltage is in the reverse direction, we call it counter-EMF or back EMF (BEMF).
Okay, let’s go over that again.
So when does the motor act as a generator? Well, in real-world applications, this is used in power plants, both nuclear, coal, and natural gas. They’re all taking some sort of mechanical energy, and converting it to electrical energy.
Remember! A motor and generator are the same. The only difference is the direction of the conversion of energy.
In media, we’ve seen someone pedaling on a stationary bicycle to power a light bulb. This is a generator/motor. A generator/motor apparatus is attached to the bike in a way so when the pedal is turned, it turns the shaft of the motor/generator. It’s converting mechanical energy (the biker moving his legs to pedal the pedals) into electrical energy (to power the light bulb). If I were to power the same generator/motor apparatus using a battery, the pedals will actually turn. In this case, I’m turning the motor/generator apparatus into a motor: a converter between electrical energy (stored in the battery) into mechanical energy (to move the pedals).
So in a blaster, power from the battery is going to the motors when the rev trigger is pressed. The motor is acting like a motor, converting electrical energy to mechanical energy. When the rev trigger isn’t pressed, the power from the battery is cut off, so no more power from the battery is going into the motor. But, the we observe the motor is still spinning. It may not be spinning as fast as when the rev trigger was being pressed, but the motors are still spinning. And what happens to a motor when it’s spinning, but not powered? It’s a generator. The motor is converting the mechanical energy (flywheels spinning) into electrical energy. We can harness this energy to charge our batteries (this is how some vehicles like the Toyota Prius work), but a more complex circuit will be necessary, and it won’t be too effective. Also recall that the energy being generated is BEMF.
The concept of a motor/generator is very important to describe the functionality of the flyback diode.
A diode
Notice how the anode, or positive part, of the diode is connected to Vcc. This is so current doesn’t flow through the diode when the motor is on. But, when the motor is powered off, a BEMF is created. Now what was previously the negative of the motor becomes the positive of the power source, since it’s acting as a generator and the EMF created is in the opposite direction, hence BEMF. Now, the negative of the motor/generator is connected to the cathode, or negative part, of the diode, and the positive is connected to the anode. Current can now flow through the diode, but only when the motor/generator is generating BEMF. That’s why the orientation of the diode matters.
Now this is where many people get confused, myself previously included. They think that this BEMF may produce high spikes in voltage, which may damage the MOSFET. So, a flyback diode is required to take care of those high spikes in voltage. This is not entirely correct.
To debunk this theory, we need to remember that the BEMF ONLY from the motor turning into a generator generating voltage from the flywheel’s inertia will never exceed the battery voltage. The voltage generated only by the freewheeling of a motor will not exceed that of the supply.
But, the BEMF consists of two components: freewheeling voltage, and flyback voltage. The flyback voltage is what can damage the MOSFET, since they can be extremely high and unpredictable.
The source of this flyback voltage results from the functionality of the motor. Motors use coils. If you’ve ever opened one up, accidentally or purposely, you'll see coils. Some motors have permanent magnets, and others have electromagnets, which means more coils. When current passes through coils, it creates a magnetic field. This is called induction, as described in Faraday’s law. Okay, induction, no big deal. It’s just how a motor operates. When the circuit is open, no more magnetic field is being induced, since the flow of current has stopped. But a magnetic field already exists from the previous flow of current, and according to the first law of Thermodynamics, energy cannot be created or destroyed. This energy in the field can’t be destroyed, so it needs to go somewhere, so it goes back into the coil. This collapsing magnetic field feeds back into the coil, or inductor, and it become the source in the circuit. This “inductive spike” can generate high voltages, and this high voltage is what we protect our MOSFET from using a flyback diode.
Yum physics!
Tl;dr Resistor to ensure that when the MOSFET should be off, it is off. Diode to protect MOSFET from high voltages from the motor
This is already page 16 on the Google Docs, and I just rambled about MOSFETs that entire time. Let’s get started with some legit write-up. Here are the parts required. Don't skip out on any part just because you don’t know what it does, because you’ll blow stuff up.
Total cost: $4.35
I recommend buying all electronics from Digi-Key. They are a trustworthy electronics distributor, I’ve been shopping with them for years, and you won’t run into any knock-offs exploding in your face. Also offer great selection and prices.
Buy from China only if you know what you’re doing. You’ll save some money when buying from China, but of course it will take longer. I’ve bought thousands of electronics from China, just make sure to read datasheets and product descriptions.
Also note how many of the electronics come in kits with many different values, and a decent quantity of each value. I would recommend purchasing these kits if you plan on continuing to get more in depth into electronics, as these are basic parts which will be used throughout electronics.
Okay, here comes the fun part! A basic understanding of how the circuit works is greatly beneficial when it comes to wiring. Please look it over so you don’t explode any MOSFETs.
Exploded MOSFET
.Here are some wiring diagrams to wire everything together properly, once you’ve gathered all the required tools and parts.
Simple wiring diagram, items not drawn to scale
Refined wiring diagram, credit to Not Not Not Not Not Not Not Ryan on Discord
Schematics
If you're doing this in a Rapidstrike, Hyperfire, or any other blaster involving three motors (two for flywheels, one for pusher), things will need to work a bit differently. Since there are two separate motor systems being individually controlled (flywheels and pushers), you'll need two MOSFETs, just like how you have to replace both switches in a switch-replacement-rewire (eww). So you'll need two of each of the materials (two MOSFETs, two resistors, and two diodes).
Tips:
Notice how the legs of the resistors wrap around the MOSFET’s pins.
Close up your blaster and
Whoo! Finally done. It sure took me a long time to make this, and I hope it takes you a long time to read and understand the concepts here. If I have made any mistakes in terminology or concepts, or you need something clarified, please do notify me! as I am still learning.
Video Tutorial: One day
Imgur Album with all the images
A Google Doc of this (may not be up-to-date)
To learn more cool stuff, check these out. No Wikipedia links since my school says they’re evil and because they can oftentimes be too technical for beginners, and it’s usually the first search result:
How does a MOSFET work? (Title says Transistor, but video describes a MOSFET)
Controlling High-Current Loads
Arduino vs. Microcontroller vs. Microprocsessor
Pull-Up and Pull-Down Resistors
If there are any topics you want covered in-depth by a tutorial like this, leave a comment on it! I do mainly electronics and coding, to too much hardware stuff. Here are some future tutorials I have in mind:
They will probably be write-ups such as this one, since my video production quality sucks :P
It took a good amount of time to make this twenty-two-page long document on Google Docs, so any feedback - on content, writing style, diagrams, etc. - would be greatly appreciated! Thanks so much for reading this much!