Chapter 6
Working with Transistors
In This Chapter
Understanding transistors
Using a transistor as an amplifier
Switching on and off with a transistor
Creating a flashing circuit
Most people became aware of the transistor when transistor radios took off in the 1960s and 1970s. Before that, radios were more or less confined to the home – often as pieces of furniture in the living room that people gathered around. The transistor allowed the radio to go out into the street, the workplace and – to the older generation’s annoyance – the beach and cafe.
That was just the first obvious sign of an extraordinary technology revolution that was to change everyone’s lives. Today, transistors are in just about every piece of electronics you can think of, from your washing machine to satellites. They have led to new industries, such as computing, and revolutionised older ones, such as publishing. Without them your mobile phone wouldn’t be mobile and your computer wouldn’t fit in your office, let alone under your desk. The world wouldn’t have laptops, MP3 players or even cassette or CD players, and people would still be playing music on vinyl records. Well, okay, we admit some of us still do, but that’s from personal choice and not necessity.
In the half a century or more since the first transistor radio, little thimble-sized transistors have given way to transistors that are literally millions of times smaller. Nowadays, experts can put 100 million transistors on a single piece of silicon crystal about the size of your fingernail.
In this chapter, you take a look at what transistors are and how you can put them to use in your own circuits, as amplifiers, switches and LED flashers. Along the way, you build a few simple transistor circuits to discover how they work.
What’s the Big Deal About Transistors?
When the transistor was invented in 1947, it didn’t really do anything that hadn’t already been done before. It did, however, do it in a radically different way (for the history, check out the later sidebar ‘Why transistors were invented’).
Think of a transistor as an electronic lever. A lever is a device that allows you to lift a large load by exerting a small amount of effort. In essence, a lever amplifies your effort. Well, that’s what a transistor does: it lets you use a small current to control a much larger current.
Figure 6-1 shows some of the many different kinds of transistors that are available today. As you can see, transistors come in a variety of different sizes and shapes. But all these transistors have one thing in common: they each have three leads.
Figure 6-1: Transistors come in many shapes and sizes.
Peering inside a transistor
The most basic kind of transistor is called a bipolar transistor. Bipolar transistors are the easiest to understand, and they’re the ones you’re most likely to work with as a hobbyist. As a result, most of this chapter focuses on bipolar transistors (though we do describe another type of transistor in the later sidebar ‘Considering field-effect transistors’). Throughout this entire book, you can assume that whenever we use the term transistor by itself, we’re referring to a bipolar transistor.
We now peer inside a transistor to see how it works.
In this minibook’s Chapter 5, we explain that a diode is the simplest kind of semiconductor, made from a single p-n junction. The latter is simply a junction of two different types of semiconductors, one that’s missing a few electrons to give it a positive charge (p-type semiconductor) and the other with a few extra electrons, which gives it a negative charge (n-type semiconductor).
By itself, a p-n junction works as a one-way gate for current. In other words, a p-n junction allows current to flow in one direction but not the other. A diode is simply a p-n junction with a lead attached to both ends.
A transistor is like a diode with a third layer of either p-type or n-type semiconductors on one end. Thus, a transistor has three regions rather than two. The interface between each of the regions forms a p-n junction.
Figure 6-2 shows the structure of two common types of transistors along with their schematic diagram symbols. We explain the details of this figure in the following paragraphs.
You can make a bipolar transistor in two ways:
NPN transistor: A p-type semiconductor sandwiched between two n-type semiconductors. This type of transistor has three regions: n-type, p-type and n-type (see the top part of Figure 6-2).
PNP transistor: An n-type semiconductor sandwiched between two p-type semiconductors (in other words, the opposite way round). This type of transistor has three regions: p-type, n-type and p-type (check out the bottom part of Figure 6-2).
Each of the three regions of semiconductor material in a transistor has a lead attached to it, and each of these leads is given a name:
Collector: This lead is attached to the largest of the semiconductor regions. Current flows through the collector to the emitter as controlled by the base.
Emitter: This lead is attached to the second largest of the semiconductor regions. When the base voltage allows, current flows through the collector to the emitter.
Base: This lead is attached to the middle semiconductor region. This region serves as the gatekeeper that determines how much current is allowed to flow through the collector-emitter circuit. When voltage is applied to the base, current is allowed to flow.
Figure 6-2: NPN and PNP transistors.
Collector-emitter: The main current that flows through the transistor. Voltage placed across the collector and emitter is often referred to as Vce and current flowing through the collector-emitter path is called Ice.
Base-emitter: The current path that controls the flow of current through the collector-emitter path. Voltage across the base-emitter path is referred to as VBE and is also sometimes called bias voltage. Current through the base-emitter path is called IBE.
Before we move onto the gory details in the next section, just note these transistor points:
In an NPN transistor, the emitter is the negative side of the transistor. The collector and base are the positive sides.
In a PNP transistor, the emitter is the positive side of the transistor. The collector and base are the negative sides.
Most circuits that you can build with an NPN transistor can also be built with a PNP transistor. But if you do, you have to remember to flip the power connections.
In a schematic diagram, transistors are usually represented by the letter Q.
Although good reasons exist why the terms collector, emitter and base were chosen for the three leads of a transistor, they have to do with the internal operation of the transistor at a deeper level than you need to go for this book. So please take our word for it: the inventors of the transistor didn’t choose the terms collector, emitter and base just to confuse you!
Examining transistor specifications
Transistors are more complicated devices than resistors, capacitors, inductors and diodes (see Chapters 2 to 5 of this minibook, respectively). Whereas those components have just a few specifications to wrangle with, such as ohms of resistance and maximum watts of power dissipation, transistors have a whole range.
If you happen to be a rocket scientist and you’re thinking about using the transistor in a missile, by all means pay attention to every detail in the data sheet. But if you’re just trying to do a little on-the-side circuit design, you need to pay attention only to the most important specifications, such as the following:
Collector current (IC ): The maximum current that can flow through the collector-emitter path.
Most circuits employ a resister to limit this current flow; use Ohm’s law (from Chapter 2 of this minibook) to calculate the value of the resistor necessary to keep the collector current below the limit. If you exceed this limit for long, the transistor may be damaged.
Collector-base voltage (VCBO ): The maximum voltage across the collector and the base. This is usually 50 V or more.
Collector-emitter voltage (VCEO ): The maximum voltage across the collector and the emitter. This is usually 30 V or more, which is well above the voltage levels you work with in most hobby circuits.
Current gain (HFE ): A measure of the amplifying ability of the transistor, which refers to the ratio of the base current to the collector current. Typical values range from 50 to 200. The higher this number, the more the transistor is able to amplify an incoming signal.
Emitter-base voltage (VEBO ): The maximum voltage across the emitter and the base, which is usually a relatively small number such as 6 V. Most circuits are designed to apply only small voltages to the base, and so this limit isn’t usually a concern.
Total power dissipation (PD ): The total power that can be dissipated by the device. For most small transistors, the power rating is on the order of a few hundred milliwatts (mW).
Amplifying Current with a Transistor
The most common way to use a transistor as a current amplifier is shown in Figure 6-3. This type of circuit is sometimes called a common-emitter circuit because, as you can see in the figure, the emitter is connected to ground, which means that the input signal and the output signal share the emitter connection.
The circuit in Figure 6-3 uses a pair of resistors as a voltage divider to control exactly how much voltage is placed across the base and emitter of the transistor. The AC signal from the input is then superimposed on this bias voltage to vary the bias current. Then, the amplified output is taken from the collector and emitter. Variations in the bias current are amplified in the output current.
As we describe in Chapter 2 of this minibook, a voltage divider is simply a pair of resistors. The voltage across both resistors equals the sum of the voltages across each resistor individually. You can divide the voltage any way you want by picking the correct values for the resistors. If the resistors are identical, the voltage divider cuts the voltage in half. Otherwise, you can use a simple formula to determine the ratio at which the voltage is divided. (To check out this formula, turn to Chapter 2 of this minibook.)
Figure 6-3: A basic transistor amplifier circuit.
If you look at the schematic diagram in Figure 6-3 and narrow your eyes just a bit, you can see that the circuit features two voltage dividers:
The combination of resistors R1 and R2, which provide the bias voltage to the transistor’s base.
The combination of resistors R3 and R4, which provide the voltage for the output.
In reality, a third resistor exists in the output voltage divider: the collector-emitter path in the transistor itself. In fact, one common way to explain how a transistor works is to think of the collector-emitter path as a potentiometer (a variable resistor), whose knob is turned by the bias voltage. For a more detailed explanation, see the later sidebar ‘The magic pot’.
The output voltage divider is a variable voltage divider: the ratio of the resistances changes based on the bias voltage, which means the voltage at the collector varies as well. The amplification occurs because very small variations in an input signal are reflected in much larger variations in the output signal.
This idea is a little tricky and so now we look more closely at this circuit:
The input arrives at the left side of the circuit in the form of a signal, which usually has a DC and an AC component. In other words, the voltage fluctuates but never goes negative.
One side of the input is connected to ground, to which the battery’s negative terminal is also connected. The transistor’s emitter is also connected to ground (through a resistor), as is one side of the output.
The purpose of C1 (see Figure 6-3) is to block the DC component of the input signal. Only pure AC gets past the capacitor. Without this capacitor, any DC voltage in the input signal would be added to the bias voltage applied to the transistor, which may spoil the transistor’s ability to amplify faithfully the AC part of the input signal.
R1 and R2 form a voltage divider that determines how much DC voltage is applied to the transistor base. The AC portion of the signal that gets past C1 is combined with this DC voltage, which causes the transistor’s base current to vary with the voltage.
R3, R4 and the variable resistance of the collector-emitter circuit form a voltage divider on the output side of the amplifier. Amplification occurs because the full power supply voltage is applied across the output circuit. The varying resistance of the collector-emitter path reflects the small AC input signal on the much larger output signal.
C2 blocks the DC component of the output signal so that only pure AC is passed on to the next stage of the amplifier circuit.
Switching with a Transistor
One of the most common uses for transistors is as simple switches. In short, a transistor conducts current across the collector-emitter path only when a voltage is applied to the base. When no base voltage is present, the switch is off. When base voltage is present, the switch is on.
In an ideal switch, the transistor should be in only one of two states: off or on. The transistor is off when no bias voltage is present or when the bias voltage is less than 0.7 V. The switch is on when the base is saturated so that collector current can flow without restriction.
Exploring an NPN transistor switch
Figure 6-4 shows a schematic diagram for a circuit that uses an NPN transistor as a switch that turns an LED on or off.
Figure 6-4: Switching an LED with an NPN transistor.
The following list looks at the circuit in Figure 6-4 component by component:
LED: A standard 5 mm red LED. This type of LED has a voltage drop of 1.8 V and is rated at a maximum current of 20 mA.
R1: This 330 Ω resistor limits the current through the LED to prevent the LED from burning out. You can use Ohm’s law (for details, see this minibook’s Chapter 2) to calculate the amount of current that the resistor allows to flow. Because the supply voltage is +6 V, and the LED drops 1.8 V, the voltage across R1 is 4.2 V (6 – 1.8). Dividing the voltage by the resistance gives you the current in amperes, approximately 0.127 A. Multiply by 1,000 to get the current in mA: the result is 12.7 mA, well below the 20 mA limit.
Q1: A common NPN transistor. We use a 2N2222A transistor, but just about any NPN transistor works. R1 and the LED are connected to the collector and the emitter is connected to ground. When you turn on the transistor, current flows through the collector and emitter so lighting the LED. When you turn off the transistor, the transistor acts as an insulator and the LED doesn’t light.
R2: This 1 kΩ resistor limits the current flowing into the base of the transistor. You can use Ohm’s law to calculate the current at the base. Because the base-emitter junction drops about 0.7 V (the same as a diode), the voltage across R2 is 5.3 V. Dividing 5.3 by 1,000 gives the current at 0.0053 A, or 5.3 mA. In this way the 12.7 mA collector current (ICE) is controlled by a 5.3 mA base current (IBE).
SW1: This switch controls whether current is allowed to flow to the base. Closing this switch turns on the transistor, which causes current to flow through the LED. Thus, closing this switch turns on the LED even though the switch isn’t placed directly within the LED circuit.
You may be wondering why you need to bother with a transistor in this circuit. After all, you can just put the switch in the LED circuit and do away with the transistor and the second resistor. But that would defeat the principle that this circuit illustrates: that a transistor allows you to use a small current to control a much larger one.
If the entire purpose of the circuit is to turn an LED on or off, by all means omit the transistor and the extra resistor. But when you’re working with more advanced circuits in the future, you’ll find plenty of cases when the output from one stage of a circuit is very small and you need that tiny amount of current to switch on a much larger current. In that case, the transistor circuit shown here is just what you need.
Building an LED driver circuit
In Project 6-1, you build a circuit similar to the one shown in the preceding section. The circuit uses a transistor to switch on an LED using a current that’s much smaller than the LED current.
The only difference between this circuit and the one in Figure 6-4 is that the circuit in Project 6-1 adds an LED to the base circuit. When you close the switch, both LEDs light up. However, LED1 is brighter than LED2 because the collector current is larger than the base current.
Figure 6-5 shows the completed project.
Figure 6-5: The circuit for the LED driver circuit.
Walking Through a NOT Gate
A gate is a basic component of digital electronics, which you can read all about in Book VI. Gate circuits are built from transistor switches that are either on or off. A total of 16 different kinds of gates exist and you discover them all in Book VI, Chapter 2.
In this section, we introduce you to one of the simplest of all gate circuits, called a NOT gate, which simply takes an input that can be either on or off and converts it to an output that’s the opposite of the input. In other words, if the input is on, the output is off. If the input is off, the output is ON.
Looking at a simple NOT gate circuit
Figure 6-6 shows the schematic diagram for a circuit that uses a single transistor to implement a NOT gate. Here’s how the circuit works:
The input is controlled by a single-pole switch. When the switch is closed, the input is ON. When the switch is open, the input is OFF.
The input is sent through the R1 and LED1 to bias the transistor. Thus, when the input is ON, LED1 lights up and the transistor is turned on, which enables the collector-emitter path to conduct. When the input is OFF, LED2 is dark, the transistor turns off and no current flows through the collector.
LED2 is connected directly between the +6 V power supply and ground, through a current-limiting resistor, of course, to keep the LED from burning itself out.
The anode of LED2 is connected to the transistor’s collector.
When the transistor is off, current flows through R2 and LED2 and the LED lights up, indicating an ON output. But when the transistor turns on, a short circuit is created through the transistor’s collector and emitter. This short circuit causes the current to bypass LED2, and so the LED goes dark to indicate an OFF output condition.
Figure 6-6: The schematic diagram for the NOT gate circuit.
Building a NOT Gate
Project 6-2 shows you how to build the one-transistor NOT gate circuit on a solderless breadboard. The completed project is shown in Figure 6-7.
Figure 6-7: The transistor NOT gate.
When you complete this project, you can allow yourself a celebration that you’ve built your first digital logic circuit.
Oscillating with a Transistor
An oscillator is an electronic circuit that generates repeated waveforms. The exact waveform produced depends on the type of circuit used to create the oscillator. Some circuits generate sine waves, some generate square waves and others generate other types of waves. Oscillators are essential ingredients in many different types of electronic devices, including radios and computers. Flip to Book I, Chapter 9, for more about the different types of waves.
Inspecting an astable multivibrator
Figure 6-8 is a generalised schematic diagram for an astable multivibrator made from a pair of NPN transistors.
When you first power up this circuit, only one of the transistors turns on. You may think that they’d both turn on, because the bases of both transistors are connected to +V, but it doesn’t happen that way: one of them goes first. For the sake of discussion, assume that Q1 is the lucky one.
When Q1 comes on, current flows through R1 into the collector and on through the transistor to ground. Meanwhile, C1 starts to charge through R2, developing a positive voltage on its right plate. Because this right plate is connected to the base of Q2, positive voltage also develops on the base of Q2.
When C1 is charged sufficiently, the voltage at the base of Q2 causes Q2 to start conducting. Now the current flows through the collector of Q2 via R4, and C2 starts charging through R3. Because the right-hand plate of C2 is bombarded with positive charge, the voltage on the left plate of C2 goes negative, which drops the voltage on the base of Q1 and causes it to turn off.
C1 discharges while C2 charges. Eventually, the voltage on the left plate of C2 reaches the point where Q1 turns back on, and the whole cycle repeats.
Figure 6-8: An astable multivibrator.
Here are a few other interesting things about astable multivibrators:
The time that each half of the multivibrator is on is determined by the RC time constant formed by the capacitor charging circuits. Therefore, you can vary the speed at which the circuit oscillates by adjusting the capacitor and resistor values. For more information about calculating resistor and capacitor time constants, refer to Chapter 3 of this minibook.
You can create an astable multivibrator from PNP transistors simply by switching the ground with the +V voltage source.
Output from the multivibrator circuit can be taken directly from the collector of either transistor. For example, you can place an LED or a speaker in series with R1 or R4 to see or hear the oscillator in action. For an example, check out the next section.
You can use a third transistor to couple the multivibrator with an output load, as shown in Figure 6-9. Just connect the emitter of one of the multivibrator transistors to the base of the third transistor and connect the load to the collector, as shown in the figure.
This arrangement has two advantages:
• The load itself interferes with the multivibrator circuit if you take it directly from the collector of Q1 or Q2. By using a third transistor, you isolate the load from the multivibrator circuit.
• The output is much closer to a true square wave when the coupling transistor is used. Without it, the output isn’t a clean square wave because of the effects of the capacitor charging.
Figure 6-9: Using a transistor to couple an output load to an astable multivibrator.
Building an LED flashing circuit
In Project 6-3, you build a circuit that uses an astable multivibrator to flash two LEDs alternately. LED flasher circuits are a favourite of electronic hobbyists because flashing LEDs have all sorts of fun uses, from surprising Christmas cards to warning lights on your model railroad layout.
The LED flasher circuit is an astable multivibrator similar to the one shown in Figure 6-8. The only differences are that we add LEDs to the collector circuit of each transistor and fill in the resistor and capacitor values. With the values we select for this project, the lights alternate quickly, a bit faster than once per second.
If you feel like experimenting a bit after you complete this project, here are a few suggestions:
Replace R2 and R3 with larger resistors, such as 220 kΩ and 470 kΩ, and see what effect this has on the flasher.
Add a potentiometer in series with R2 or R3. Doing so allows you to vary the flash rate by turning the potentiometer knob.
Change the capacitors.