EmbeddedRelated.com

Transistor

Category: Electrical

A transistor is a semiconductor device, typically with three terminals, that uses a signal at one terminal to control a larger current flowing between the other two, enabling amplification and switching. The two dominant families in embedded work are the bipolar junction transistor (BJT) and the field-effect transistor (FET), each with distinct control mechanisms and performance trade-offs.

In practice

In embedded systems, transistors most commonly appear as switches rather than analog amplifiers. A microcontroller GPIO pin typically sources or sinks only a few milliamps, far less than what a relay coil, motor, LED array, or solenoid requires. A single BJT or MOSFET between the MCU pin and the load bridges that gap, letting the MCU control hundreds of milliamps or more without damage. The "Byte and Switch" blog series covers this switching role in detail.

For low-side switching (load between supply and the transistor, transistor between load and ground), an N-channel MOSFET or NPN BJT is the typical choice. High-side switching is more involved: a P-channel MOSFET or PNP BJT is often used, but gate/base drive becomes trickier because the control signal must be referenced to a voltage near the supply rail. The "Which MOSFET topology?" post addresses these topology decisions directly.

BJTs are current-controlled devices: base current drives collector current at a ratio set by the DC gain (hFE or beta). MOSFETs are voltage-controlled: the gate draws negligible DC current, but the gate capacitance must be charged and discharged at switching transitions, so gate drive current matters at higher frequencies. For most low-frequency, logic-level switching in embedded designs, a logic-level N-channel MOSFET (with a gate threshold and RDS(on) specification both rated at or below 3.3 V) is a common default because of its low on-resistance (RDS(on)) and zero steady-state gate current.

Thermal behavior is a practical concern whenever a transistor carries significant current. Power dissipation in a BJT depends on VCE and IC; in a MOSFET operating in full enhancement, it depends on ID squared times RDS(on). BJTs are particularly susceptible to thermal runaway because the base-emitter junction has a negative temperature coefficient that can cause current hogging in parallel configurations. Power MOSFETs, by contrast, typically exhibit a positive temperature coefficient of RDS(on) in the relevant operating region, which provides a degree of self-balancing; however, any device can be destroyed if total dissipation is not managed within its thermal limits. The blog post "Voltage Drops Are Falling on My Head" discusses operating points and thermal runaway in this context.

Frequently asked

BJT or MOSFET -- which should I reach for first when switching a load from an MCU pin?
For most modern embedded switching tasks, a logic-level N-channel MOSFET is the more common default. It draws no DC gate current (sparing the MCU pin), offers low RDS(on) in small packages, and is available with gate thresholds compatible with 3.3 V logic. BJTs are still practical for simple, low-frequency switches and when driving inductive loads with well-understood saturation behavior, but require sizing the base resistor to ensure the device is driven into saturation.
What does 'logic-level' mean when selecting a MOSFET?
A logic-level MOSFET is specified to reach its rated low RDS(on) at a gate-to-source voltage (VGS) of 4.5 V or less, and sometimes at 2.5 V or 1.8 V. Standard MOSFETs may require VGS of 10 V for full enhancement. If your MCU runs at 3.3 V, a standard MOSFET may be only partially on, dissipating far more power than the datasheet RDS(on) implies. Always check the VGS threshold and the RDS(on) curve at your actual drive voltage.
Why do I need a flyback (freewheeling) diode when switching an inductive load with a transistor?
Inductors resist instantaneous changes in current. When the transistor turns off, the inductor's stored energy drives the switched node sharply negative (for low-side switches) or above the supply (for high-side), potentially exceeding the transistor's voltage rating and destroying it. A diode placed across the load in the reverse direction clamps this spike by providing a current path until the energy dissipates. Relays, solenoids, and DC motor windings all require this protection.
How do I calculate the base resistor for a BJT switch?
First determine the collector current IC needed by the load. Divide IC by the transistor's minimum hFE (use the datasheet value at that current, not the typical value) to get the minimum base current IB needed for saturation. Then apply a saturation factor, typically 5 to 10x, so IB(drive) = IC / (hFE_min / overdrive_factor). Finally, RB = (V_GPIO - VBE) / IB(drive), where VBE is approximately 0.6 to 0.7 V for a silicon BJT. Using a datasheet hFE at a collector current far from your operating point is a common sizing mistake.
Can I drive a transistor gate or base directly from a microcontroller GPIO?
For a BJT, the GPIO must supply the calculated base current continuously while the switch is on; verify the pin's source/sink current rating against your base current requirement. For a MOSFET used at low switching frequencies (say, below a few kilohertz), the GPIO charges the gate capacitance to the required VGS and then draws no steady-state current, so direct drive is usually acceptable. At higher switching frequencies, the gate charge (Qg) divided by the switching period sets the average gate drive current, which can exceed GPIO limits -- a dedicated gate driver IC is appropriate in those cases.

Differentiators vs similar concepts

BJT vs. MOSFET is the most common source of confusion. BJTs are current-controlled (base current -> collector current), have no gate oxide to protect, and exhibit a relatively predictable VCE(sat) in saturation. MOSFETs are voltage-controlled (gate voltage -> channel conductance), present a capacitive load rather than a resistive one, and are characterized by RDS(on) when fully enhanced. JFETs are a third family -- voltage-controlled and normally-on (depletion-mode) -- but are rarely used as digital switches in embedded designs; they appear more often in analog front ends and RF circuits. IGBTs combine BJT-like output characteristics with MOSFET-like gate drive and are common in high-voltage power electronics (motor drives, inverters) but uncommon in the low-voltage switching typical of microcontroller-level designs.