As a Switch and More
There’s a lot you can do with electronics these days without any EE-level of knowledge. But certain concepts can be tricky—like selecting a transistor for a high-current or high-voltage design. In this article, Jeff steps through the history of the transistor as a device. He then guides you on how to select and use a transistor as a switch or for other functions.
Many of today’s young hackers have not been exposed to many of the fundamentals open to those who explore higher education in the field of electronics. They can explore the use of microcontrollers (MCUs) without this knowledge, because of the low cost of entry. With free tools and PCBs under $20, the basic “hello world” or “blinky” program does not require any knowledge beyond plugging in a few cables to their PC. I think that is great. Hopefully, it provides a spark of imagination that will conjure up ideas on how they might use this new-found power.
Indeed, this is true. These vibrant minds can easily plug in peripherals such as motors, speakers, push buttons, lights and other goodies, without having to think about voltage, current, resistance, wattage and those other parameters that make up the circuitry of our imaginations. As long as they can follow the recipes of the presenters, newbies can reproduce thousands of experiments of others. And because of a sharing community, this list continues to grow. For those who are thoroughly hooked, this may eventually lead to a dead end, where their imagination has finally hit the proverbial stone wall. They will want to control something that isn’t “plug and play”—or may just want to do it themselves.
For instance, while most MCUs can drive an LED with 10mA, higher currents require a few external components. Driving devices with higher currents or voltages requires the use of a transistor of one kind or another. But which one? With the thousands of choices where do you start? A little background may help you understand the choices you must make.
In the early 1900s, English physicist John Ambrose Fleming found that a heated filament would give off electrons. When combined with a separate contact or plate in a evacuated glass bulb, these emitted electrons were attracted across the gap, when the plate or anode was positively charged with respect to the filament or cathode. The current flowed in one direction only, and the first diode tube was created (Figure 1). It wasn’t the most efficient device, since it required one source of power for the filament and an additional one for the bias.
A few years later, American inventor Lee de Forest added a third electrode to the mix, creating the first triode tube. The third electrode or “control mesh” or “grid” enabled the vacuum tube to be used not just as a rectifier, but also as a switch or an amplifier of the electrical current. This was possible by adjusting a separate bias on the grid, located between the cathode and anode. The electrons would be prevented or allowed to flow through the grid to the anode.
Ultimately, this led to the development of two of the most technologically incredible machines in our history—the radio and the computer. While many early radio devices were portable, they were rather large and heavy, because multiple batteries were required (Figure 2). Early computational machines were massive, taking up rooms and giving off thousands of watts of heat (Figure 3).
The beginning of the semiconductor era didn’t arrive until the 1960s. The semiconductor’s distinguishing difference from previous vacuum-tube or gaseous-state devices was a new technology based on the semiconductor and known as solid-state devices. The semiconductor device works by controlling an electric current within a solid crystalline piece of semiconductor material such as silicon.
All elements (oxygen, carbon and aluminum, for example) are composed of atoms. The atom is the smallest bit of matter that retains the properties required to define an element. It has two basic parts. The center or “nucleus” is made up of two particles, the proton and the neutron—and the “shell” contains orbiting particles called electrons. There are other subatomic particles, but we only need to consider these three for this discussion.
Each element is identified by its “atomic number,” which is the number of protons in its nucleus—for example, 8 for oxygen (O), 6 for carbon (C) and 13 for aluminum (Al). An element is most stable or “happy” when its numbers of protons (with a positive charge) and electrons (with a negative charge) are equal, because the charges cancel one another. An element with a charge is called an ion. Anions lack electrons and have a positive charge. Cations have extra electrons and have a negative charge. Any element can have a charge if the number of electrons does not equal the number of protons in the atom.
The electrons whizzing around a nucleus typically orbit in multiple shells and sub-shells, each of which can hold a maximum number of electrons. If an element has more than 2 electrons (anything heavier than hydrogen or helium), the additional electrons won’t fit into the shell closest to the nucleus. This innermost shell, designated “K,” has a single sub-shell, “s,” that can hold a maximum of 2 electrons.
The second shell, designated “L,” has two sub-shells, sub-shell “s” with 2 electrons, and sub-shell “p” with 6 electrons. The third shell, “M” has three sub-shells, sub-shell s” with 2 electrons, sub-shell “p” with 6, and sub-shell “d” with 10. Regardless of which element we are talking about, each shell (K, L, M and so on) holds the same maximum number of electrons, and each sub-shell (s, p, d and so on) holds the same maximum number of electrons. The distribution of shells, sub-shells and electrons depend, however, on the atomic number (number of protons) of the element.
The electrons in each sub-shell have some energy level, based on the sub-shell’s distance from the nucleus—lower energy for the inner sub-shells and higher energy for the outer sub-shells. The innermost sub-shells fill up before any additional electrons are forced to move to an outer sub-shell or the next shell. Therefore, the outermost shell is the only one that can have fewer than the maximum number of electrons in a sub-shell. These are called “valence electrons,” and that’s where the magic happens. Let’s look at some examples. In the discussions ahead, the numbers of electrons in the respective shells, from closest to furthest from the nucleus, are given in parentheses.
Copper (Cu) is widely used as a conductor. Its atomic weight is 29, and it has 29 electrons in 4 shells (2-8-18-1). The single electron in its outermost shell makes it unstable. It is therefore a good conductor, since its single valence electron can move freely among other copper atoms all looking to fill their outer shells. When more electrons fill the outer shell, there are fewer free valence electrons, and the element becomes more stable and a good insulator. We are interested in those elements with both of these aspects.
Carbon (C, 2-4), silicon (Si, 2-8-4), germanium (Ge, 2-8-18-4) and tin (Sn, 2-8-18-18-4) are four such elements. Atoms of each have 4 valence electrons in their outer shells. Their covalent bonding (sharing of electrons) produces a lattice structure that is full—not necessarily a good conductor.
DOPING AND MORE
Let’s start with a good insulator, silicon, atomic number 14 (Si, 2-8-4). The Si atom would be most happy to have 8 electrons in its outer shell, so it will share its 4 valence electrons with 4 other Si atoms, forming a crystal structure of covalent bonding (Figure 4).
To transform Si into a material that can conduct electricity requires free electrons that are available to move within the crystal. A process known as “doping” can increase the conductivity of the semiconductor silicon. There are two different types of doping—N-doping and P-doping. In both types of doping, an impurity (a substance that is not silicon) is added to the Si crystal.
P-doping occurs when an element such as Boron (B) with 3 valence electrons is added to Si (Figure 5). Note that the crystal structure is not complete; the B atom bonds with only 3 Si atoms, leaving a” hole” (missing electron) looking for an extra electron. Should an Si electron fill this hole, another hole is created, and so the hole wanders around looking for a new home.
N-doping occurs when phosphorus (P) with 5 valence electrons is added to Si, as shown in Figure 6. Note the crystal structure is complete, but each phosphorus atom has added an extra electron with nothing to bond with. This electron wanders around, looking for a new home.
Now the magic. When a P-doped and an N-doped material are joined, we get a “PN junction” or “diode” (Figure 7). The contact of the two doped materials creates a region where the free electrons in the N-doped material diffuse across the junction to fill the holes in the P-doped material, and the holes in the P-doped material diffuse across junction to recombine with the free electrons, as shown in Figure 8.
This migration creates an electric field within the small area around the junction, called the “depletion region,” and blocks any further diffusion of electrons across to the P-doped region. An external bias applied can either reinforce or counteract, depending on the polarity. Applying an external positive potential to the anode (reverse bias) strengthens the depletion region, creating a better insulator and preventing current flow. However, applying an external positive potential to the anode (forward bias) weakens the depletion region, creating a better conductor where current can flow. For a PN junction in silicon, the depletion region is eliminated once the potential exceeds 0.7V. The diode is a simple and extremely useful semiconductor device on its own, but it is also the foundation of other devices.
NPN AND PNP TRANSISTORS
We can take the diode a step further by adding a second junction to the device, creating the transistor. If we add an N-type material to the P-side of a diode we get an NPN transistor. If we add a P-type material to the N-side of a diode we get an PNP transistor. These devices add control to the current flow through them. The ends of each device (emitter and collector) are the same type, but have differing amounts of doping. The emitters are more heavily doped, and an N-type (NPN) or “donor” has more free electrons, whereas a P-type or “acceptor” has more holes.
The center and opposite type (the “base”) has the least amount of doping, and is what allows control over the flow of current. With no (or reverse) bias on the base with respect to the emitter, the junction potential can only be reinforced, and no current flows. When we place a small forward bias on the base, with respect to the emitter, we allow the base-emitter bias to overcome the junction potential and enhance current flow across the junction. If the collector is also forward biased in relation to the emitter, the collector current will flow through the collector-base junction and through to the emitter. The size of the base determines the ratio of base (IB) to collector current (IC). These two currents equal the current in the emitter (IE). Figure 9 shows the junction, schematic and physical view of each of these two devices.
In the Figure 9 schematic, the direction of the arrow of each emitter determines the type of device. On an NPN device, the current flows out of the emitter, and on a PNP device, the current flows into the emitter. For the sake of simplicity let’s use a power supply of 5V. Most circuits have ground (or VSS) connected to the negative side of a power supply and the positive side connected to VCC.
A transistor’s three terminals can be thought of as an input, an output and a common terminal. As such, they can be connected in one of three ways—common-emitter, common-collector and common base. The common-emitter configuration is the most common and will be used in this discussion. Please feel free to explore the other formats on your own, should you be curious. This configuration will allow us to control some current flow through a load with just a fraction of that current on the base. The load may be an LED, relay or any other 5V device. We’ll discuss higher voltage devices in a bit.
The simplest load might be the LED, so let’s start with that. In this configuration, the base is the input, the collector is the output, and the emitter is common to both. The emitter will almost always be connected directly to the supply. For an NPN device, the emitter is connected to ground, and current flows out of the emitter (note the schematic arrow in Figure 9 pointing out). For an PNP device, the emitter is connected to VCC and current flows into the emitter (note the schematic arrow pointing in).
USING THE TRANSISTOR
In Figure 10 we see how the two types of transistors can be used to control an LED. In the circuit on the left, a 2N3906 (PNP) transistor has its emitter connected to VCC. With no drive on the base (or R1 connected to VCC), the transistor is OFF (high impedance), and no current can flow to the LED through R2. When R1 is pulled to ground, current can flow out the base, turning on the transistor and allowing 10 times the current to flow out the collector and through R2 and the LED.
In the circuit on the right, a 2N3904 (NPN) transistor has its emitter connected to GND. With no drive on the base (or R3 connected to GND) the transistor is OFF (high impedance), and no current can flow to the LED through R4. When R3 is pulled up, current can flow into the base, turning on the transistor and allowing 10 times the current into the collector through the LED and R2. Both types of transistors are available from a variety of electronics distributors, including Digi-Key and Mouser Electronics.
These two transistors are symmetrical and have similar parameters. Table 1 shows parameters you need to check before use in your circuit. Note when used with a logic supply of 5V, we won’t exceed max voltage parameters. Maximum current is 200mA. I like to keep the maximum to 100mA to avoid “hot” devices. The gain is important for determining minimum bias currents for required load currents. There are some frequency parameters that you only need to heed when working in RF frequencies. You can disregard those when operating under 1MHz.
You can see that these would also be fine for supplies of 12V and 24V, which will most likely cover most of the devices you will want to control. Many MCUs today can source or sink 20mA, which is plenty for a simple LED. But when you need more current—say whacking an LED with a current of 100mA for a short duty cycle—you will need to use a transistor.
A HIGHER POWER
What happens when you need more current than 100mA? A higher-power transistor can be chosen. Sidney Darlington invented the compound transistor we know as the Darlington (pair). Two similar-type transistors are connected in an emitter-follower configuration. The first transistor provides high current to the base of the second transistor. The gains multiply and can be quite high, along with the current through the second transistor. The small, plastic, TO-2 package can no longer support the higher currents, because the power dissipated across the device can be quite high. T0-220 and T0-3 size packages are common, and can require appropriate heat sinking. The use of twin transistors raises the VBE to approximately 1.4V, and with current now in the ampere range, the dissipation is significant.
Like our BJT (Bipolar Junction Transistor), the Darlington transistor (DT) is available in both PNP and NPN. While it has advantages in current handling, it also has disadvantages, such as slower turn-off times, which limit high-speed use. But for many applications, this can be disregarded.
Today, other semiconductor devices can be considered for higher currents, but these also have trade-offs. The FET transistor, for instance, has a much lower junction impedance (ON resistance), and though this creates much lower dissipation, it’s also more difficult to use. We’ll save this for another time. This column is devoted to the use of these two simple devices—the BJT and DT. They can get you through most projects without having to get too wrapped up with the math. You just have two decisions to make.
Do I need to turn my device ON with an active-high signal (logic high), then choose an NPN device? Or do I need to turn my device ON with an active-low signal (logic low) then choose a PNP device? If you can choose the polarity, then choose the NPN route. Not only are these slightly less expensive, but they also are easier to use with higher-voltage devices. Does my device require less than 100mA (BJT) or more (DT)? Here the biggest issue will be: is heat sinking needed for a DT device?
Although this discussion is about using the transistor as a digital switch, the transistor is really an analog device. There is a region between no current flow (OFF) and saturation or max current flow (ON), whereby a fraction of the base current will produce a fraction of the maximum current. This is fairly linear once conducting begins, up to the saturation point. Thus, the transistor can be used as an amplifier for analog purposes. Because the biasing is critical, it requires a bit more math and support circuitry. Once you master using the transistor as a switch, you can investigate its use as a signal amplifier.
Until then, let me leave you with a few examples of how you might explore the use of transistors for device control. Figure 11 shows a number of different loads you might want to control. From left to right there is a simple resistive load, an LED, a relay, a piezo transducer, a piezo beeper and a DC motor. +V can be any voltage up to the VCE max of the transistor. Current is limited to about 100mA for a 2N3904/6 NPN/PNP, or many amps, depending on the DT like a TIP3x.
Piezo devices come in two varieties: 1) the transducer, which you can drive with a frequency; and 2) a beeper, which has an internal driver and will sound at a predetermined frequency by just applying a voltage. The piezo transducer is a capacitive load and requires a parallel resistor, whereas relays and motors are inductive and require a free-wheeling diode to protect the transistor from inductive spikes when turned off.
Stepper motors can be run by providing a sequence of pulses enabling stepper motor coils. The sequence allows you to control the direction of the motor’s shaft. The speed of the sequence controls the rotations per minute. Figure 12 shows a unipolar stepper, which requires the same polarity on each coil, but center-tapped coils. The bipolar stepper has single coils, but requires the circuitry to change the polarity on each coil. This requires NPN and PNP devices connected to each end of each coil. It is similar to Figure 13, which shows a full bridge for direction control of a DC motor. Where the DC motor has a single connection, the bipolar stepper requires twice as many transistors—two pairs for each coil.
ELECTRON VS. CURRENT FLOW
By convention, the direction of current flow on diagrams has always been shown as the direction that a positive charge would move. Today’s knowledge tells us that electron flow is actually the opposite of conventional current flow. While this might seem wrong, some things are better left uncorrected, and so we can more accurately define current flow as “hole” flow.
Now, you don’t have to think using a transistor is crazy complicated.
- If your load is on the ground side, use PNP. And if your load is on the high side, use NPN.
- If your load is 10mA at 5V (or 3.3V), your MCU may be able to handle it directly. If the device you wish to control requires a higher voltage or current, use a transistor. Most BJTs are good to 100mA.
- For heftier currents, use a Darlington transistor. Just remember that you will probably need a heat sink, if you need to get rid of some heat due to high junction dissipation!
For many projects you’ll only need to stock 2N3904 and 2N3906 transistors. For more current, stock Darlington-like TIP33 and TIP34 transistors. Don’t be afraid to substitute, depending on your requirements or availability! Then expand your world, and consider learning about FETs (field-effect transistors). Too much to learn, too little time.
 Figure 1 en.wikipedia.org/wiki/Vacuum_tube
 Figure 2 www.radiolaguy.com/images/tubePortables/Silvertone30sBatterySet.jpg
 Figure 3 en.wikipedia.org/wiki/Colossus_computer
 Figures 5, 6 and 8 www.schoolsobservatory.org/learn/tech/instruments/inst_ccd/semiconductors
 Figure 7 www.allaboutcircuits.com/uploads/articles/diode-representations.jpg
Digi-Key | www.digikey.com
Mouser Electronics | www.mouser.com
PUBLISHED IN CIRCUIT CELLAR MAGAZINE • MAY 2021 #370 – Get a PDF of the issueSponsor this Article
Jeff Bachiochi (pronounced BAH-key-AH-key) has been writing for Circuit Cellar since 1988. His background includes product design and manufacturing. You can reach him at: firstname.lastname@example.org or at: www.imaginethatnow.com.