Transistors

Introduction

Transistors make our electronics world go ‘round. They’re critical as a control source in just about every modern circuit. Sometimes you see them, but more-often-than-not they’re hidden deep within the die of an integrated circuit. In this tutorial we’ll introduce you to the basics of the most common transistor around: the bi-polar junction transistor (BJT).

Introduction image

In small, discrete quantities, transistors can be used to create simple electronic switches, digital logic, and signal amplifying circuits. In quantities of thousands, millions, and even billions, transistors are interconnected and embedded into tiny chips to create computer memories, microprocessors, and other complex ICs.

Covered In This Tutorial

After reading through this tutorial, we want you to have a broad understanding of how transistors work. We won’t dig too deeply into semiconductor physics or equivalent models, but we’ll get deep enough into the subject that you’ll understand how a transistor can be used as either a switch or amplifier.

This tutorial is split into a series of sections, covering:

  • Symbols, Pins, and Construction — Explaining the differences between the transistor’s three pins.
  • Extending the Water Analogy — Going back to the water analogy to explain how a transistor acts like a valve.
  • Operation Modes — An overview of the four possible operating modes of a transistor.
  • Switches — Application circuits showing how transistors are used as electronically controlled switches.

There are two types of basic transistor out there: bi-polar junction (BJT) and field-effect (FET). In this tutorial we’ll focus on the BJT, because it’s slightly easier to understand. Digging even deeper into transistor types, there are actually two versions of the BJT: NPN and PNP. We’ll turn our focus even sharper by limiting our early discussion to the NPN. By narrowing our focus down—getting a solid understanding of the NPN—it’ll be easier to understand the PNP by comparing how it differs from the NPN.

Symbols, Pins, and Construction

Transistors are fundamentally three-terminal devices. On a bi-polar junction transistor (BJT), those pins are labeled collector (C), base (B), and emitter (E). The circuit symbols for both the NPN and PNP BJT are below:

NPN and PNP symbols

The only difference between the NPN and PNP symbols is the direction of the arrow on the emitter. The arrow on an NPN points out, and on the PNP it points in. A useful mnemonic for remembering which is which is:

NPN: Not Pointing iN

Backwards logic, but it works!

Our previous readings covered two-terminal devices (i.e., resistors and diodes), which meant that for any device there was only one current and one voltage to worry about. Because a transistor has three terminals, we'll be concerned about two currents (through) and two voltages (across).

Transistor Construction

Like diodes, transistors rely on semiconductors to work their magic. A semiconductor is a material that’s not quite a pure conductor (like copper wire) but also not an insulator (like air). The conductivity of a semiconductor—how easily it allows electrons to flow—depends on variables like temperature or the presence of more or less electrons. Let’s look briefly under the hood of a transistor. Don’t worry, we won’t dig too deeply into quantum physics.

A Transistor as Two Diodes

Transistors are kind of like an extension of another semiconductor component: diodes. In a way, transistors are just two diodes with their cathodes (or anodes) tied together:

Transistors as two diodes

The diode connecting base to emitter is the important one here; it matches the direction of the arrow on the schematic symbol, and shows you which way the control current is intended to flow through the transistor.

The diode representation is a good place to start, but it’s far from accurate. Don’t base your understanding of a transistor’s operation on that model (and definitely don’t try to replicate it on a breadboard, it won’t work). There’s a whole lot of weird quantum physics level stuff controlling the interactions between the three terminals.

(This model is useful if you need to test a transistor. Using the diode (or resistance) test function on a multimeter, you can measure across the BE and BC terminals to check for the presence of those “diodes”.)

Transistor Structure and Operation

Transistors are built by stacking three different layers of semiconductor material together. Some of those layers have extra electrons added to them (a process called “doping”), and others have electrons removed (doped with “holes”—the absence of electrons). A semiconductor material with extra electrons is called an n-type (n for negative because electrons have a negative charge) and a material with electrons removed is called a p-type (for positive). Transistors are created by either stacking an n on top of a p on top of an n, or p over n over p.

Simplified NPN construction

Simplified diagram of the structure of an NPN. Notice the origin of any acronyms?

With some hand waving, we can say electrons can easily flow from n regions to p regions, as long as they have a little force (voltage) to push them. But flowing from a p region to an n region is really hard (requires a lot of voltage). But the special thing about a transistor–the part that makes our two-diode model obsolete –is the fact that electrons can easily flow from the p-type base to the n-type collector as long as the base-emitter junction is forward biased (meaning the base is at a higher voltage than the emitter).

Active transistor current flow

Let's briefly unpack this diagram. It shows how conventional currents (IB, IC, and IE) flow through a transistor, but it also highlights the direction (and magnitude) of the electron flow as well. The NPN transistor is designed to pass electrons from the emitter to the collector (so conventional current flows from collector to emitter). The emitter “emits” electrons into the base, which controls the number of electrons the emitter emits. Most of the electrons emitted are “collected” by the collector, which sends them along to the next part of the circuit.

The BJT is a current-controlled device; with enough voltage to overcome the diode-like threshold from base to emitter, a little bit of base current IB causes a much larger amount of collector current IC. Because all that current needs to go somewhere, the emitter current is their sum. This explains why you see a big stream of electrons moving from the emitter to the collector, with a tiny stream being diverted out the base.

How would such currents come about? The voltage rise VBE shows that the voltage at the base needs to be higher than the voltage at the emitter, and the voltage rise VCB shows that the voltage at the collector must also be higher than at the base.


The transistor is kind of like an electron valve. The base pin is like a handle you might adjust to allow more or fewer electrons to flow from emitter to collector. Let’s investigate this analogy further…

Extending the Water Analogy

If you’ve been reading a lot of electricity concept tutorials lately, you’re probably used to water analogies. We say that current is analogous to the flow rate of water, voltage is the pressure pushing that water through a pipe, and resistance is the width of the pipe.

water analogies for current, voltage, and resistance

Unsurprisingly, the water analogy can be extended to transistors as well: a transistor is like a water valve—a mechanism we can use to control the flow rate.

There are three states we can use a valve in, each of which has a different effect on the flow rate in a system.

1) On — Short Circuit

A valve can be completely opened, allowing water to flow freely—passing through almost as if the valve wasn’t even present. (There is a slight reduction in pressure).

Valve open, water flowing, short circuit

Likewise, under the right circumstances, a transistor can look like a short circuit between the collector and emitter pins. Current is free to flow through the collector and out the emitter with a only slight voltage drop.

2) Off – Open Circuit

When it’s closed, a valve can completely stop the flow of water.

valve closed, water stopped, open circuit

In the same way, a transistor can be used to create an open circuit between the collector and emitter pins.

3) Linear Flow Control

With some precise tuning, a valve can be adjusted to finely control the flow rate to some point between fully open and closed.

Valve half-open, water flow rate controlled

A transistor can do the same thing—linearly controlling the current through a circuit at some point between fully off (an open circuit) and fully on (a short circuit).

From our water analogy, the width of a pipe is similar to the resistance in a circuit. If a valve can finely adjust the width of a pipe, then a transistor can finely adjust the resistance between collector and emitter. So, in a way, a transistor is loosely akin to a variable, adjustable resistor.

Amplifying Power

There’s another analogy we can wrench into this. Imagine if, with the slight turn of a valve, you could control the flow rate of the Hoover Dam’s flow gates. The measly amount of force you might put into twisting that knob has the potential to create a force thousands of times stronger. We’re stretching the analogy to its limits, but this idea carries over to transistors too. Transistors are special because they can amplify electrical signals, turning a low-power signal into a similar signal of much higher power.


Kind of. There’s a lot more to it, but that’s a good place to start! Check out the next section for a more detailed explanation of the operation of a transistor.

Operation Modes

Unlike resistors, which enforce a linear relationship between voltage and current, transistors are non-linear devices. They have four distinct modes of operation, which describe the current flowing through them. (When we talk about current flow through a transistor, we usually mean current flowing from collector to emitter of an NPN.)

The four transistor operation modes are:

  • Saturation — The transistor acts like a short circuit. Current freely flows from collector to emitter.
  • Cut-off — The transistor acts like an open circuit. No current flows from collector to emitter.
  • Active — The current from collector to emitter is proportional to the current flowing into the base.
  • Reverse-Active — Like active mode, the current is proportional to the base current, but it flows in reverse. Current flows from emitter to collector (not, exactly, the purpose transistors were designed for).

To determine which mode a transistor is in, we need to examine the two currents and voltages mentioned earlier.

Let’s look at the three important transistor modes individually; we’ll investigate how to put the device into that mode, and what effect it has on current flow.

Note: The majority of this page focuses on NPN transistors. To understand how a PNP transistor works, simply flip the polarity or > and < signs.

Notation

First a bit on the notation we'll use. We need to make reference to the voltage at the base (VB), collector (VC), and emitter (VE) relative to ground. We can then talk about the voltage across the base-emitter junction (VBE) and the collector-emitter junction (VCE).

Cutoff Mode

A transistor in cutoff mode is off—there is neither base current nor collector current, and therefore no emitter current. It almost looks like an open circuit.

Cutoff mode model

Getting an NPN transistor into cutoff mode is fairly straightforward. Consider the diode view of a transistor and remember that we need sufficient forward voltage across a diode for current to flow. When VBE is less than this threshold voltage, virtually no current will flow. There are many abbreviations for this voltage drop—VBE(sat), Vγ, and Vd are a few. We'll use VBE(th). The actual value varies among transistors (and even further by temperature). For a lot of transistors (at room temperature) we can estimate this drop to be about 0.6V–0.95V (depending on the base current applied).

Active Mode

For electrical engineers (and indeed, even the inventors of the transistor), the active mode of a transistor is its raison d'être, for it provides power amplification. Although we won't use their active mode for this class, you'll want to know that it exists (since it's how amplifiers like your stereo work), but moreover, it's the important step on the way to understanding Saturation Mode, which is the yin to the cutoff mode's yang for digital logic and computing.

First, unless we're trying to drive the transistor in an unconventional reverse mode, let's recall the the voltage at the collector (relative to ground) must be greater than the voltage at the emitter.

Next, remember that we need a non-zero forward voltage from base to emitter (VBE) to even turn on the transistor (much like an LED). Once we've raised the base voltage enough to overcome this forward voltage, current begins flowing into the base, and the magic of amplification begins.

But so long as VBE is not so high that the transistor is saturated (VCE hits a ceiling due to Kirchoff's Law), then we can drive some interesting behaviors...

Amplifying in Active Mode

Active mode is the most interesting and dynamic mode of the transistor because it turns the device into an amplifier. Current going into the base pin amplifies current going into the collector (and thus out the emitter).

Our shorthand notation for the gain (amplification factor) of a transistor is β (you may also see it as βF, or hFE). The parameter β linearly relates the collector current (IC) to the base current (IB):

I_{C} = \beta I_{B}

The actual value of β varies by transistor (not just the transistor family, but individual components from the same production line will vary). It’s usually around 100, but can range from 50 to 200…even 2000, depending on which transistor you’re using and how much current is running through it. If your transistor had a β of 100, for example, that’d mean an input current of 1mA into the base could produce 100mA current through the collector.

Active mode model

Active mode model: VBE = VBE(th), and IC = βIB.

What about the emitter current, IE? In NPN active mode, the collector and base currents go into the device, and the IE comes out. Because of conservation of charge (more on this later), the emitter current (output) must be the sum of the base and collector currents (inputs): IE = IC + IB.

To reiterate, the point here is that relatively small changes (in current) at the base (i.e., those caused by your voice moving a small wire near a magnet on your phone) are amplified to a much larger (linearly proportional) current at the collector. Cool!

Saturation Mode

Although active mode is indeed quite cool, it has its limits (which is rather a good thing, since it's what enables digital computers to exist).

Saturation is the on mode of a transistor. A transistor in saturation mode acts much like a short circuit between collector and emitter.

Saturation mode model

A naïve view of the amplification rule (IC = βIB) would suggest that increasing the base current IB would continuously increase the collector current IC. Indeed it does, but only to a point. Once the effective resistance from the collector to the emitter has been sufficiently reduced to act like a closed circuit, then the characteristics of other elements of the circuit must come into play, which will inevitably limit the collector current. Once this happens, we say the transistor has entered saturation.

More precisely, using Kirchhoff's law, let's think about the impact of a rising collector current on a circuit path including a resistor in series with the transistor. By Ohm's law, increasing current through the resistor would increase the voltage across it. Kirchhoff's voltage law tells us the resistor's voltage drop cannot exceed the supply voltage, suggesting there must be a limit to the transistor's collector current that determines the current through the resistor. We'll return to this idea with a concrete example of the transistor switch below.

Because of the extrinsically-limited collector current, the amplification rule is curtailed and we have what's called a forced β, because the actual ratio of the collector and base currents is going to be much lower than the transistor's intrinsic gain β. We'll revisit a concrete example of how this arises below.

But first, another reality bummer: there won’t be perfect conduction between collector and emitter. A small voltage drop will form between those terminalse. Transistor datasheets will define this voltage as CE saturation voltage VCE(sat)—the voltage across collector andemitter required for saturation. This value is usually around 0.05–0.2V. This value means that VC must be (at least) slightly greater than VE to get the transistor in saturation mode with current flowing from collector to emitter.

Another way to think about the action of a transistor in saturation, is that it's trying to bring the collector voltage as close as it can to the emitter voltage, just like a real short circuit would.

Return to again to our resistor-transistor circuit. Relatively small base currents IB lead to relatively small collector currents; that small current through the resistor leads to a small voltage across it (by Ohm's law). Kirchhoff's law reminds us that the remaining voltage must be dropped across the collector-emitter junction, or VCE. Increasing the current shifts more of the voltage drop to the resistor, reducing VCE until the transistor reaches it minimum VCE(sat).

We will have more to say and reiterate about voltage drops, VCE and even VBE later.


If you’re burnt out on conceptual stuff, take a trip to the next section. The best way to learn how a transistor works is to examine it in real-life circuits. Let’s look at some applications!

Switches

One of the most fundamental applications of a transistor is using it to control the flow of power to another part of the circuit—using it as an electric switch. Driving it in either cutoff or saturation mode, the transistor can create the binary on/off effect of a switch.

Transistor switches are critical circuit-building blocks; they’re used to make logic gates, which go on to create microcontrollers, microprocessors, and other integrated circuits. Below are a few example circuits.

Transistor Switch

Let’s look at the most fundamental transistor-switch circuit: an NPN switch. Here we use an NPN to control a high-power LED:

NPN switch to control an LED

Our control input flows into the base, the output is tied to the collector, and the emitter is kept at a fixed voltage.

While a normal switch would require an actuator to be physically flipped, this switch is controlled by the voltage at the base pin. A microcontroller I/O pin, like those on an Arduino, can be programmed to go high or low to turn the LED on or off.

When the voltage at the base is greater than 0.6V (or whatever your transistor’s VBE(th) might be), the transistor starts saturating and looks like a short circuit between collector and emitter. When the voltage at the base is less than 0.6V the transistor is in cutoff mode—no current flows because it looks like an open circuit between C and E.

R2 serves to safely limit the current through the LED, but it is also why the transistor ends up in saturation mode, rather than active mode.

Achieving Saturation

In the circuit diagram of a low side switch above, when the control signal is raised to 5V, the current to the base will be a little less than 5 mA. (In figuring the input current through the base resistor R1, we would need to account for the slight voltage drop VBE = VBE(th), but let's ignore that for now.) A typical β value for this NPN BJT might be 100, which would suggest a collector current of IC = βIB = 50×5mA = 500 mA. Ohm's law tells us the resistor R2 would have to drop 500mA × 100Ω = 50V in order to be drawing that kind of current. However, Kirchhoff's Voltage Law tells us that's not possible: we can only drop from the "high" side of the resistor down to the "low" side, or from at most from +5V down to ground.

Because of this upper limit on the resistor's voltage drop, there must be an upper limit on the current through the collector to the emitter. Once the base current IB has gotten high enough to reach that maximum IC, the transistor has entered saturation. Voila!

Base Resistors!

You’ll notice that the circuit above uses a series resistor between the control input and the base of the transistor. Don’t forget to add this resistor! A transistor without a resistor on the base is like an LED with no current-limiting resistor.

In a way, a transistor is sort of like a pair of interconnected diodes. We need to "activate" (or technically, forward-bias) the base-emitter diode to turn the load on. This imagined diode only needs 0.7V to turn on, and (critically) more voltage than that means more current. Way more current. Some transistors may only be rated for a maximum of 10-100mA of current to flow through them. If you supply a current over the maximum rating, the transistor might blow up. (Or at least start to smell bad. And stop working.)

The series resistor between our control source and the base limits current into the base. The base-emitter junction can get its happy voltage drop of 0.7V, and the resistor can drop the remaining voltage (thanks Kirchhoff!). The value of the resistor, and voltage across it, will thus set the current.

Switching an LED with a transistor

The resistor needs to be large enough to effectively limit the current, but small enough to feed the base enough current to reach saturation. 1mA to 10mA will usually be enough, but check your transistor’s datasheet to make sure.

We'll return to this diagram and analyze it a bit more carefully nearer the end of this reading.

Digital Logic

Transistors can be combined to create all our fundamental logic gates: AND, OR, and NOT.

These gates (which we'll talk more about in the next class) form the basis of operations on Boolean values, which you'll be familiar with from both C (where they're written as &&, ||, and !) as well as Scheme/Racket/Scamper (where the operators are the more intellegible and, or, and not).

In circuits for digital logic, a (continuous) voltage is used to represent the (discrete) Boolean values you are more accustomed to seeing in programs. One possible convention might be that something close to +0V (or Ground/GND) represents "off" or false, while something close to +5V represents "on" or true. In the following, we look at how to use transistors in circuits to code these values and combine them with the typical Boolean operators, AND, OR, and NOT.

(Note: These days MOSFETS are more likely to be used to create logic gates than BJTs. MOSFETs are more power-efficient, which can make them a better choice.)

Saturating Inverter

Here’s a transistor circuit that implements an inverter, or NOT gate:

BJT inverter circuit

An inverter built out of transistors.

Here a high voltage into the base will turn the transistor on, which will effectively connect the collector to the emitter. Since the emitter is connected directly to ground, the collector will be as well (though it will be slightly higher, somewhere around VCE(sat) ≈ 0.05–0.2V). If the input is low, on the other hand, the transistor looks like an open circuit, and the output is pulled up to VCC.

(This is actually a fundamental transistor configuration called common emitter. In this circuit the emitter is tied to a voltage common to both the base and emitter (usually ground). The base voltage becomes the signal input, and the collector voltage becomes the output.)

AND Gate

Here are a pair of transistors used to naïvely create a 2-input AND gate:

BJT AND circuit

2-input AND gate built out of transistors.

If either transistor is turned off, then the output at the bottom transistor’s emitter will be pulled low (both are disconnected from VCC; no current flows and the voltage across the pull resistor is zero). If both transistors are “on” (bases both high), then current is flowing, which will raise the voltage at the output probe (labeled "A*B").

This setup is fine if you simply want to drive current through some load (i.e., an LED), but the voltage at the output probe is not guaranteed to be sufficiently large to be considered "high", because the transistors might not be in saturation.

Whether or not the transistors end up saturated depends in small part on the values of the base resistors, but in much larger part on their particular gain, β. Because the gain is notoriously variable across individual transistors, this is not a particularly good design. We will look at an improved version in class.

OR Gate

And, finally, here’s a naïve 2-input OR gate:

BJT OR circuit

2-input OR gate built out of transistors.

In this circuit, if either (or both) A or B are high, that respective transistor will turn on, conducting current. If both transistors are off, then the output voltage is pulled low through the resistor.

As you might guess, like the AND gate above, this design suffers from unreliable saturation issues, which we will examine closely (and resolve) in class.

Briefly, the solution in both cases will be to (repeatedly) use the common emitter topology to reliably drive transitors to saturation for switching. The gates shown above use an emitter follower (also known as common collector), where the load appears on the low side of the transistor.

Kirchhoff's Law(s)

In order to use transistors to control other components, it's important to understand how Kirchhoff's Voltage Law applies to circuits involving transistors.

Let us take a closer look at the transistor circuit shown before in the state when the switch is closed in order to make sure we understand the currents and voltage drops.

transistor with LED

The analysis begins with the 2N3904 transistor (Q1 above) and its datasheet.

We would find that VBE(th) (likely labeled VBE(sat) on the datasheet) is 0.7V, so we indeed see that is the voltage drop shown across the base and emitter terminals upon closing the switch to +5V. By Kirchhoff's Voltage Law, because the base is tied "high" (when the switch is closed) to +5V, that leaves a voltage drop across the base resistor R1 as 5V – 0.7V = 4.3V. We can then use Ohm's Law either to figure out the necessary resistance (in order to respect the current limit) or calculate the current (when given a resistance value for R1). Taking the resistance of R1 as given at 1kΩ, we find that IB = 4.3V/1kΩ = 4.3mA.

Considering the other path through the transistor, the datasheet would tell us that VCE(sat) is 0.15V, which explains the voltage drop across the collector and emitter terminals. (Here we remember our previous rough analysis where we convinced ourselves the transistor would be in saturation mode.) With a red LED having a 1.85V forward voltage, that leaves 5V – 0.15V – 1.85V = 3.0V across the load resistor R2. If we need to limit the current through the resistor and/or transistor, we would use this voltage to determine the necessary resistance by Ohm's Law. Taking the resistance of R2 as given, we find the current from the +5V supply into the collector is IC = 3.0V / 100Ω = 30mA.

Kirchhoff's Current Law

You might then notice that the current from the emitter to ground rail is the sum of the two "input" currents on the transistor: IE = 4.3mA + 30mA = 34.3mA. It turns out this is related to Kirchhoff's other law:

the sum of currents into a junction equals the sum of the currents out of the junction

This is known as Kirchhoff's Current Law (KCL). You saw the application of this earlier when we wrote IE = IC + IB.

We won't use that law as much for this class, since it is the voltage levels corresponding to the binary (ON or OFF) states that are of greatest interest for digital logic and computer design.

Conclusion

With the end of this reading, you should understand:

  • the difference between NPN and PNP transistors;
  • the basics of how to use a BJT NPN transistor as a switch (i.e., saturation and cut-off modes);
  • how to measure current through basic circuits and account for the voltage drop of resistors, LEDs, and transistors using Ohm's Law and Kirchhoff's Laws; and
  • how to naïvely wire transistors into load-driving logic gates (i.e., AND, OR, and NOT)