MOSFET
MOSFET Explained: Types, Switching, Gate Drive, and Safe Use
A MOSFET (metal-oxide-semiconductor field-effect transistor) is a voltage-controlled semiconductor device used for switching and amplification. In embedded projects, MOSFETs are commonly used to drive LEDs, motors, solenoids, fans, and other loads that require more current than a microcontroller GPIO can provide. They are also fundamental to switching regulators, motor controllers, and digital electronics.
The gate voltage controls the conductive channel between drain and source. Unlike a bipolar junction transistor, a MOSFET's gate ideally draws very little steady-state current, but it has capacitance that must be charged and discharged during switching. This is why gate-drive strength, switching speed, and voltage ratings matter even when the control signal comes from a low-power microcontroller.
This guide focuses on practical N-channel and P-channel MOSFET behavior, logic-level selection, switching circuits, gate resistors, protection, and common troubleshooting. A MOSFET is not automatically safe for every load simply because its current rating looks large. The datasheet's conditions, thermal design, switching losses, load transients, and board layout determine whether it will work reliably.
1. MOSFET terminals and operation
A discrete MOSFET usually has three main terminals: gate (G), drain (D), and source (S). Some devices expose a body or substrate connection internally tied to one of the terminals. The exact pin order depends on the package and part number, so always use the datasheet rather than assuming that all TO-220 or surface-mount devices share the same layout.
The gate is insulated from the semiconductor channel by a thin dielectric. Applying a gate-to-source voltage (V_{GS}) changes the channel conductivity. For an N-channel enhancement MOSFET, a sufficiently positive gate-to-source voltage forms a conductive channel. For a P-channel enhancement MOSFET, the relevant gate-to-source voltage has the opposite polarity.
A MOSFET's gate voltage must be measured relative to its source, not merely relative to circuit ground. This distinction matters in high-side switching and circuits where the source voltage moves. A GPIO may output 3.3 V relative to ground, but if the MOSFET source is also near 3.3 V, then (V_{GS}) may be close to zero and the device may not turn on as intended.
2. N-channel and P-channel MOSFETs
An N-channel MOSFET is often preferred for low-side switching because its source can be connected to ground and a microcontroller can drive the gate above the source. When the gate is driven sufficiently high relative to the source, the device conducts from drain to source in its intended switching configuration.
A P-channel MOSFET is often used for simpler high-side switching in positive-supply circuits. Its source is connected toward the positive supply, and pulling its gate lower than its source turns it on. The gate must not be driven beyond its maximum gate-to-source rating. When the source voltage is higher than the controller's GPIO voltage, a transistor or dedicated gate driver may be needed to control the P-channel device safely.
These are common arrangements, not universal rules. The load polarity, voltage, current, switching frequency, and protection requirements determine the correct topology. For higher-power or fast-switching applications, a dedicated driver or a different MOSFET arrangement may be more appropriate. Check the body-diode direction and the manufacturer's circuit guidance when the load can return energy, as with motors and inductive loads.
3. Threshold voltage is not the fully-on voltage
A frequent selection mistake is choosing a MOSFET based on its gate threshold voltage (V_{GS(th)}). Threshold voltage indicates the point at which a small specified drain current begins to flow under test conditions; it does not mean the MOSFET is fully enhanced or suitable for carrying the intended load current.
For microcontroller switching, look for the on-resistance (R_{DS(on)}) specified at a gate voltage the controller can actually provide, such as 2.5 V, 3.0 V, or 4.5 V. If the datasheet only specifies low on-resistance at 10 V gate drive, the device may not switch efficiently from a 3.3 V ESP32 output. A partially enhanced MOSFET can dissipate substantial heat.
On-resistance typically increases with junction temperature, so use thermal and current margin. A headline drain-current rating often assumes ideal mounting or case temperature conditions that are difficult to achieve in a small board. Read the electrical characteristics and thermal graphs, not just the first-page maximum current number.
4. Low-side switching an LED or DC load
A common low-side circuit connects the load between the positive supply and the MOSFET drain, with the source connected to ground. The gate receives the control signal through an appropriate drive arrangement. When the N-channel MOSFET turns on, current flows from the supply through the load and MOSFET to ground. When it turns off, the current path is interrupted, except for any transient or alternate path in the circuit.
For a simple LED, use a current-limiting resistor unless the LED module already includes suitable current regulation. Calculate the resistor from the supply voltage, LED forward voltage, and desired current using Ohm's law. Choose a MOSFET whose gate-drive specification, voltage rating, current capability, and power dissipation suit the load. Tie the controller ground and load-supply ground together when the circuit topology requires a shared reference, and ensure the supply and wiring can handle the current.
A microcontroller GPIO should not power a motor or relay coil directly. Use a properly rated switching device, a suitable external supply, and appropriate transient suppression. For inductive loads, current can continue flowing when the MOSFET turns off; the circuit must provide a designed path or clamp. Keep high-current paths short and separate from sensitive signal returns where possible.
5. Gate resistor and pull-down resistor
A small series gate resistor can limit peak charging current, damp ringing, and reduce electromagnetic interference. The best value depends on the MOSFET's gate charge, driver strength, switching speed, and layout. Too much resistance slows transitions and increases switching loss; too little can produce ringing or excessive peak current from a weak driver. Follow the driver and MOSFET datasheets when switching quickly or at significant power.
A gate-to-source pull-down resistor on an N-channel low-side switch helps keep the MOSFET off while the controller is resetting or its GPIO is high-impedance. Without a defined gate state, noise or leakage can cause unintended switching. A P-channel high-side design may use a pull-up from gate to source to default the device off, with a suitable control transistor pulling the gate in the turn-on direction.
The pull resistor is not a substitute for correct gate-drive design. Check its interaction with the gate driver, switching frequency, power consumption, and required startup behavior. For safety-related loads, design the default state deliberately and test reset, power-up, and fault conditions rather than assuming firmware will always drive the gate correctly.
6. MOSFET losses and thermal limits
When a MOSFET is fully on, conduction loss is approximately (P=I^2R_{DS(on)}) for a resistive channel under the relevant operating conditions. Because loss rises with the square of current, doubling current can produce roughly four times the conduction loss if resistance remains constant. In practice, resistance changes with temperature and gate voltage, so use datasheet curves and thermal calculations.
During switching, the device spends time transitioning between on and off states. Voltage across the device and current through it can overlap during these transitions, producing switching loss. Gate charge, driver strength, switching frequency, load characteristics, and parasitic inductance all affect the result. A MOSFET that works cool at low frequency may overheat at a much higher switching frequency.
The junction temperature must remain within the datasheet limit with adequate margin. Package thermal resistance, PCB copper, heatsinking, ambient temperature, airflow, and mounting conditions matter. The maximum current figure is not a guarantee that the device can continuously carry that current in a particular project. For a power design, calculate conduction and switching losses, assess thermal paths, and validate under worst-case load and ambient conditions.
7. Inductive loads and protection
Motors, relays, solenoids, and coils store energy in magnetic fields. When the MOSFET turns off, the current cannot stop instantly, so the load can produce a voltage transient that stresses the transistor. A protection path—such as a correctly selected flyback diode for a suitable DC coil, or a TVS/clamp network in applications requiring faster decay—must be designed into the circuit.
A diode across a DC relay coil is normally reverse-biased during energization and conducts when the switch turns off, allowing current to decay. Its polarity, current rating, and reverse-voltage rating must be correct. The simple diode clamp can slow relay release; a higher-voltage clamp may be appropriate in some designs, but must keep the MOSFET voltage within safe limits.
Do not assume the MOSFET's body diode will protect the circuit. Its direction and rating may not provide the needed path for the load's current. Check the complete current loop and transient voltage. For motors with braking or regenerative behavior, use a driver topology designed to handle returned energy. Probe switching nodes only with instruments and methods suitable for the circuit's voltage and transient behavior.
8. Datasheet parameters to check
Drain-source voltage (V_{DS}): must exceed the maximum voltage expected across the MOSFET, including transients with appropriate margin.
Gate-source voltage (V_{GS}): has a maximum positive and negative rating. A gate drive that exceeds it can damage the device even if drain current is low.
On-resistance (R_{DS(on)}): check the value at the actual gate voltage and relevant temperature.
Gate charge (Q_g): helps estimate the driver current and switching behavior. Gate capacitance alone may not fully describe dynamic drive needs.
Safe operating area (SOA): defines permitted combinations of voltage, current, and time. It is especially important for linear operation and some fault conditions.
Thermal resistance and package: determine how heat moves from junction to ambient through the package, PCB, and heatsink.
Body diode and avalanche ratings: matter in inductive switching and transient events, but should not be used as a substitute for proper circuit protection.
Use the manufacturer's datasheet for the exact suffix and package. Parts with similar names can have different pinouts, gate characteristics, and thermal performance.
9. Common MOSFET troubleshooting
The load never turns on. Check the pinout, source reference, gate-to-source voltage, supply polarity, load path, and whether the MOSFET is specified for the available gate drive. A threshold-voltage number alone does not prove it will be fully on.
The MOSFET becomes hot. Possible causes include high on-resistance at the available gate voltage, excessive current, switching loss, insufficient thermal design, or a load transient. Measure the actual operating conditions safely and compare them with the datasheet.
The load remains on after the GPIO goes low. Check the circuit topology, gate waveform, pull resistor, source reference, wiring, and whether the MOSFET was damaged. In a high-side arrangement, verify (V_{GS}), not just the GPIO voltage relative to ground.
The controller resets when switching a motor or relay. Investigate supply dips, shared return-path impedance, inductive transients, and inadequate decoupling. Add the correct suppression and improve current-path layout instead of relying on software delays.
The MOSFET fails immediately. Check drain-source polarity, gate overvoltage, supply transients, load current, short circuits, and whether the selected device's voltage rating is adequate. Inspect the entire circuit before replacing the part.
10. A safe design checklist
Before building a MOSFET switch, write down the supply voltage, normal and peak load current, load type, switching frequency, controller logic voltage, and required default state. Select a device using the gate-drive voltage actually available, not only its threshold voltage. Confirm voltage rating, on-resistance, gate charge, SOA, thermal performance, and package pinout.
Then design the gate circuit, default-state resistor, load current path, and any flyback or transient clamp. Use an external supply for loads that exceed the controller board's capability, with a common reference where required by the topology. Check that wiring, connectors, PCB traces, and the power source are all suitable for the load current.
Test initially with a current-limited low-voltage supply and a modest load. Verify gate-to-source voltage and load behavior before increasing current. Monitor temperature and inspect the circuit for unintended heating. Do not work on mains-connected or high-energy systems without appropriate training, isolation, and rated equipment.
A MOSFET is a versatile switch, but reliable design depends on its complete operating conditions. Correct gate drive, thermal margin, transient protection, and careful layout matter as much as the printed current rating. With those basics in place, MOSFETs can provide efficient control for a wide range of electronics projects.