Friday, October 1, 2010

Electricity for Synth-DIY'ers: Transistors

This is where we start to get into the more complex of the basic electronics components. Transistors are really the basis of modern electronics. It was the transistor, and its subsequent micro-miniaturization into integrated circuits, that really kicked off the electronics revolution in the latter half of the 20th century.

There are a number of different basic types of transistors. In this installment I'm only going to cover the bipolar transistor, which is still the most commonly used type. You are also likely at some point to run across another type, called the field effect transistor (e.g., JFET, MOSFET). Those work on a different physical principle and they have different characteristics. I'll cover them in a future installment.

What Does a Transistor Do?

Basically, a transistor is a device that controls a flow of current. This is the first thing to understand: the bipolar transistor is not a voltage regulating device; it's a current regulating device. A transistor has three terminals: current flows from one terminal to the other, under the influence of the third terminal. A small current flowing into or out of the controlling terminal controls a much larger flowing between the other two terminals. This is what allows the transistor to act as an amplifier: a small current can control a much larger one.

The three pins of a bipolar transistor are referred to as the emitter, the base, and the collector. The base is the control terminal; a small current at the base controls a larger current flowing between the emitter and the collector. Which direction these current flows go in depends on which of the two flavors of bipolar transistor you are dealing with; the two are known as PNP and NPN, based on their construction. If you remember the discussion from the diode installment of this series, a diode is a junction between two types of semiconductor, known as P-type and N-type. Same thing here: the PNP and NPN designations indicate what types of semiconductor material the transistors are made from, and by implication, which direction current can flow through them.

At this point we will introduce the symbology for transistors. The two types are denoted as:


The pin coming out to the left side of the symbol, perpendicular to the little bar, indicates the base terminal. The little arrow indicates the emitter, and of course the remaining pin is the collector. Note that in the symbol for a bipolar transistor, the collector and emitter are always portrayed as meeting the little bar at a 45-degree angle. If they aren't, then the symbol is for some type of FET transistor, not a bipolar.

As you may have figured, the direction of the arrow indicates whether the transistor is a PNP or NPN type. But what does the direction actually mean? This is where we introduce the first principle of the bipolar transistor: the junction between the emitter and the base acts as a diode. And, in accordance with the base pin being the middle pin in the transistor symbol, the middle letter in "PNP" and "NPN" indicates the type of the base; either of the other two letters can be regarded as representing the emitter. So, in a PNP transistor, the emitter is a P-type and the base is an N-type. If you remember from the diode discussion, this indicates that current can only flow from the emitter to the base, not the other way around. Accordingly, the arrow on the PNP symbol is pointing inward, to indicate that current goes in through the emitter. The opposite is true for an NPN transistor; since the base is P-type, current can only flow from the base to the emitter. So the emitter has to be a current exit, and so its arrow points out.

Do not, at this point, start confusing the current-in or current-out state of the emitter with where you actually obtain the amplified output signal! In both the PNP and NPN types, you can tap off of either the emitter or the collector to get the output, depending on the circuit design. We'll cover this further down. The arrow only indicates which direction current is flowing through the transistor.

So what about the base-collector junction? Does it also act as a diode? Well, no. Why not? To be honest, I don't know enough about the physics to give you a complete answer, but here's a simplified explanation: The base region of the transistor is very, very thin compared to the collector and emitter regions. So when the electron is attracted to the base region due to an opposite charge leaving the base, when it hits this region, instead of taking a 90-degree turn and heading laterally towards the base pin, it's easier to just pass through it to the other side. The collector region is "doped" differently so that it has much less of a tendency to pull charges away from the junction area when it is reverse-biased. So, although some electrons or "holes" go get gathered up by the base, most of them just go on through. That's what makes the transistor an amplifier. This is far from being a satisfactory explanation, but for a better answer, I'll have to refer you to someone who knows more about semiconductor physics than I do.

Transistor Circuit Basics

So, let's see what we've got so far. We have three layers of semiconductor material, with two junctions between layers of opposite types, one of which acts like a diode and one of which doesn't. For purpose of discussion, let's assume for a while that we are talking about an NPN diode. Now let's apply some voltages to some of the terminals. We'll start by applying 12 volts to the collector, and grounding the base and the emitter.

What happens? Nothing. Why not? Remember, the P-N junction between the base and the emitter has all of the properties of a diode -- including diode drop. Because of the diode drop, and the fact that we're talking about silicon, no current can flow from the base to the emitter until the base is at least 0.6V higher than the emitter. So now let's apply, say, 3V from a battery to the base.

Now what happens? Probably, the transistor burns up! Why? Because we're not thinking in the transistor's terms. The transistor isn't a voltage controlling device; it's a current controlling device. When we connected the battery to the base, we gave it an almost infinite source of current. The input impedence of the base of a bipolar transistor is very low. So right away a large current went into the base; this in effect threw the transistor "wide open" and a whole bunch of current flowed from the collector to the emitter. Even running wide open, the transistor has a small amount of resistance, and like any resistive device, there is a limit to how much heat it can dissipate.

So, after clearing the smoke and installing another transistor, let's re-think this and try again. The voltage into the base, as long as it's at least 0.6V above the emitter, doesn't really matter. What matters is the current going into the base. So let's put a potentiometer in between the base battery and the transistor base terminal. We'll also put in an ammeter in between the pot and the transistor base, and we'll put another one on the transistor's collector. I've prepared three short videos to illustrate some of thes principles; they use the circuit below:




We turn on the power and start turning the pot slowly clockwise, as in this first video:



What do we see now? At some pretty small value of current going into the base, we'll also see current starting to flow into the collector. As we increase the base current, the collector current will increase in proportion (up to a point, which I'll describe in a moment). The transistor is amplifying the current: as we put a current N into the base, we get a larger current X*N going into the collector. What is the value of X? That is, by definition, the transistor's current gain. When discussing bipolar transistors, the current gain is called the beta. (You may also see the terminology "Hfe".) The beta is a property of the design and construction of the transistor, pertubated somewhat by manufacturing variation. For the typical commodity small-signal transistors that we commonly deal with, the beta will generally be in the 50-250 range depending on the specific type. Fancier transistors, particularly power types, have gains ranging from the hundreds up to about 1000. The transistor used in the demo video has a beta of 200. So, for instance, when we adjust our pot for 50 uA into the base, we see 10 mA going into the collector. What if we used a PNP transistor? Well, we'd have to swap the voltages at the collector and the emitter, and apply a negative voltage so as to draw current out of the base rather than putting current in. But the operating principles are exactly the same. Only the arithmetic signs change.

Question at this point: what is the current coming out of the emitter? Well, all current that goes into the transistor has to come out somewhere. We have current coming in at both the collector and the base, and the only place where current is coming out is at the emitter. So it stands to reason that the emitter current is the collector current plus the base current: 10 mA + 50 uA = 10.05 mA. And if we had a third (accurate) ammeter on the emitter, we would see that this is true. Much of the time, when you are figuring currents through a transistor, you can disregard the base current and figure that the collector current equals the emitter current, since the base current is always a small fraction (according to the transistor's beta). Next question: what is the voltage at the base? Answer: it depends on the voltage at the emitter. As long as the transistor is flowing current, and isn't saturated ( in a moment), it will always maintain the diode-drop relationship between the base and the emitter, so if we are interested in the base voltage, we can always look at the emitter voltage, and the base voltage will be about 0.6V more than that. But the transistor is not really sensitive to the voltage at the base -- it's the current at the base that matters. You will often have to figure out the value of a resistor to put in series with the base.

Which brings up a point: you must always ensure that both the collector-emitter and the base-emitter currents are limited somehow. As we discussed earlier, the transistor will willingly pass enough current to blow up both itself and components connected to it. One way to limit the collector current, as shown by our example circuit, is to put the load (in this case, just a resistor) in series with the collector. However, you can also put the load in series with the emitter -- but the circuit will behave somewhat differently. Check this second video, in which we add resistance to the emitter load; as the resistance goes up, the base voltage goes up. This occurs because the pot plus the current-limiting resistance at the collector effectively puts the transistor in the middle of a voltage divider. As the voltage at the emitter goes up, the base voltage has to go up in order to maintain the diode-drop relationship.





Transistor Performance and Characteristics

Transistor performance is often shown in the form of a characteristic curve which plots collector current vs. collector-emitter voltage, for various values of base current. I don't find these to be terribly useful; the main thing they illustrate is that as long as the collector-emitter voltage is sufficiently large (typically 1-3V), the collector current depends only on the base current -- it doesn't depend on the collector-emitter voltage. But we knew that already. What we really want to see, for educational purposes, is a chart that details base current vs. emitter current. Here's a rough one that I assembled from taking measurements on the transistor I used in the video above. The green area indicates where the transistor is behaving linearly (constant beta), and the red areas indicate where it is non-linear. Bear in mind that the upper red area, in particular, depends considerably on the circuit that the transistor is installed in.




This illustrates a couple of things. The red "corner" at the bottom left is where the transistor is approaching cutoff; as in the case of the diode, this is where the base-emitter junction voltage is less than the diode drop and it is very non-linear. When the base voltage drops to or below the emitter voltage, the transistor will completely stop carrying current, except for a small leakage current which, for smaller transistors, is usually on the order of a few nanoamps. The other interesting red bit is the flattening out of curve as the collector current approaches 20 mA. This occurs as the transistor is approaching saturation -- a condition where it cannot carry any more current because there are no more charge carriers available at the junctions. Why are there no more charge carriers available? Because, in the case of the video above, the circuit that the transistor is in can't source any more current. Note that this is not a limitation of the transistor itself; it's a limitation of the circuit that the transistor is in, and specifically the resistance that I put in series with the collector. The 500 ohms resistance between the battery positive and the collector limits the maximum possible current to about 20 mA.

In between the cutoff and saturation regions is the active region, shown by the green portion of the graph. In the active region, the beta remains nearly constant, and so the transistor's response to base current is nicely linear, as shown in the center portion of the above graph. When you are using the transistor as an amplifier, this is what you want. On the other hand, the cutoff and saturation regions have their uses too.

Transistor Applications: Switching vs. Amplification

The two most common uses for a transistor are switching and amplification. Let's cover the switching case first since it is easier to understand. In a switching application, we want the transistor to, at any given time, be in one of two states. The "off" state obviously corresponds to the transistor's cutoff region: we kill the base current, and the collector current goes to near zero. The "on" state can be a little trickier. It's common to operate a switching transistor in saturation; in this state, it has a very low resistance (provided that the collector current isn't excessive). A common rule of thumb for switching circuit design is to figure out what base current is needed to achieve the necessary collector current, and then double it. However, in doing so, you have to make sure that the transistor's limits for base current and power dissipation aren't exceeded. Here's an example of a common use for a transistor circuit: the transistor is being used to drive a relay. (The relay could, for example, be switching a high-voltage circuit on or off. A typical example in the audio world would be that the relay might be controlling the high-voltage plate supply in a tube amplifier.) Assume the following:
  • The relay coil has an impedence of 250 ohms
  • It takes 20 mA of current through the coil to make the relay close
  • The transistor has a beta of 100
  • The supply voltage is 12V
When the switch is closed, the base resistor feeds current into the base of the transistor. This is where the fun starts: how do you analyze this to know how much base current you need? Start by doing an Ohm's Law calculation: in order to to push 20 mA through the 250-ohm coil, you need to apply at least 5V to it. So we know it's doable, provided that our 12V power supply can source at least 20 mA of current without drooping. Now, in order to pass 20 mA of current through the transistor, how much base current do we need? Dividing that current by the beta gives us 0.2 mA, or 200 µA, of base current. If the switch is also connected to the 12V supply, then in order to put 0.2 mA into the base, we need a 60K ohms resistor in series with the base. (Note in this case that because of the base-emitter diode drop, the voltage at the base will need to be at least 5.6V if the relay coil is in series with the emitter. If we only had 5V being supplied to the switch, that won't work; the transistor will remain cut off. If this is the case, you have two options: (1) supply a higher voltage to the switch, or (2) put the relay coil in series with the collector and ground the emitter.)

Now, the thing about transistors is, the beta of specific units varies a lot from unit to unit across a given part number. So if our transistor is spec'ed for a nominal beta of 100, the beta of the particular unit we have might only be 70 or so. There are two approaches to this. One is that we can test the individual transistor that we put into the circuit and make sure its beta is at least 100. However, if we are manufacturing in quantity, it will take extra time to do the testing, and cost more because we'll have to discard some percentage of the transistors that we buy. The other approach is to provide for the minimum expected beta of a particular unit. In a switching application, this is pretty easy; if we reduce the base resistor to 30K, then the transistor beta can be as low as 50 and it will still work, but the base current is still low enough to not cause damage.

Well, assuming that your transistor is operating in the active region, it's pretty easy: choose the resistor that results in 2 mA of base current, and you'll get 200 mA out. But how do you know what resistor value gets you 2 mA of base current? And how do you know for sure that you are going to be operating in the active region? After all, that depends on the collector-emitter current.

Historically, though, amplification has been the most common use for transistors. This is not quite so true in audio applications today; opamps have taken over most of the functions of amplification within audio devices because they are easier to design with. In audio-frequency applications, discrete transistors remain mostly in power amplifiers. Nonetheless, we'll look at two methods of using transistors as amplifiers.

The first type of circuit uses a single transistor. As you might guess, the first problem that one faces when using a transistor to amplify alternating signals is that the transistor can only flow current in one direction, which means that if you just feed an AC signal into the base, at best only half of the signal will get amplified -- the other half will be absent from the output, because the opposite-polarity voltage applied to the base drives the transistor into cutoff. The way to solve this problem is to bias the input signal -- that is, add an offset current to it so that the transistor stays within the active region throughout the input signal range. This drawing illustrates a common way of doing this:



This is an example of a single-transistor amplifier driving a loudspeaker. The resistors obviously constitute a voltage divider, but it can also be thought of as a current divider. It sets the "operating point" of the transistor: the amount of current that enters the base when the input signal is quiescent, which is proportional to the voltage drop in the middle of the divider. Assuming that the input signal will on average be symmetric, the operating point needs to be at the midpoint of the transistor's active region. The input also needs to be scaled, per the transistor's approximate beta, so that a maximum input signal will not drive the transistor into saturation, and a maximum negative signal won't drive it into cutoff. Since the output will have a DC offset, the usual practice is to couple it into the following circuit via a DC-blocking capacitor (not shown here).

This single-transistor circuit is pretty common in circuits which handle small currents, but for large-current circuits, there are better methods. The two-transistor "totem pole" is a commonly used circuit; it is nearly universal in audio power amplifiers. In this configuration, a PNP and an NPN transistor are used together, with either their collectors or their emitters tied together, and the output taken from that node point between the two. One transistor amplifies the positive half of the signal; the other transistor amplifies the negative half. In Class A operation, the transistors have their operating points set so that neither of them ever goes into cutoff. A given level of input signal causes one transistor to conduct more current while the the other one conducts less; the difference is what appears as the output signal. When the input signal is quiescent, an equal current flows through both transistors. Well designed Class A amps are noted for their low-distortion operation, but they are very inefficient at low signal levels because a lot of "wasted" current is passing through the two transistors.

In Class B operation, the transistors have their operating points set so that they both enter the cutoff region precisely at the point where the input signal is zero. Note that some bias is still required in order to overcome the base-emitter diode drop; otherwise, there would be a "hole" in the response at very low input levels. It's harder to design a Class B amplifier for low distortion due to the fact that the transistors are approaching the non-linear cutoff region, but a Class B amp is far more efficient than a Class A -- at a zero input level, the Class B amp draws little current. There exist designs that are hybrid of these two concepts, known as "Class AB"; they set the operating points so that one transistor cuts off when the other is well into its active region. These are a compromise between distortion and efficiency.

Emitter vs. Collector Output

There are two basic ways of obtaining the output signal from the transistor, which we've already touched on, but they need to be described more explicitly. One is the common emitter configuration; in this configuration the emitter is connected to ground or to a power supply, and the output signal is obtained at the collector. If the output signal is something that requires a lot of current and has some resistance, such as a relay coil, the easiest way to do this is to put the load in series with the collector.

However, this configuration can also be used to derive a voltage signal from the input, provided that the load doesn't draw much current. The way to do this is to put a resistor in series with the collector (which you often will do anyway, to limit the maximum current) and then tap a point between the resistor and the collector. This effectively makes the transistor behave as a variable resistor in a voltage divider, and the output comes from the middle of the divider, as such:



Note a couple of things about this. The first is that the signal output is inverted from the input; the output voltage will be at its maximum when the base current is zero, and vice versa. The second thing to note is that the swing of the output voltage is determined by the maximum collector-emitter voltage, and so it can be of higher voltage than the input to the base. So in this mode, the transistor is capable of voltage gain in addition to current gain. This is illustrated by the video below:



The other configuration is usually called the emitter follower. In this configuration, the signal is taken from the emitter:


You can, if you are careful, design an emitter follower circuit with no current-limiting resistors. This configuration provides the maximum possible power within the limits of the transistor, which is why it is frequently used in power amplifiers.

Darlington Pair

You can use a pair (or more) of transistors to obtain higher gain, by driving the base of a second transmitter from the emitter of the first one, like so:


This is known as a Darlington pair. Where the name comes from, I don't know; I've often wondered if it has anything to do with the notorious speedway in South Carolina. The total beta for the Darlington pair is B1 x B2, where B1 and B1 are the betas of the individual transistors. As you can see, you can obtain quite high gain levels this way. Darlington pairs can be purchased as pre-made parts, or you can of course make your own from individual transitors.

Other Useful Transistor Circuits

You may recall that back in the diodes chapter, we presented a simple regulated power supply circuit controlled by a zener diode. The problem with that circuit is that the zener itself has to dissipate all of the power not drawn by the load at any moment. Here's an improved version:


In this circuit, the zener only has to dissipate the very small base current. The regulated voltage will always be 0.6V less then the zener's voltage rating, thanks to the B-E diode drop. The transistor has to pass all of the power supply current, but you can get power transistors that can handle substantial current.

The next circuit is called a current mirror, and it has a number of uses:


The way it works is that the resistor on the left allows a specific amount of collector current to flow through the transistor on the left, and its connection to both of the bases will cause the same amount of current to flow through the transistor on the right. This means that a fixed amount of current will flow through the load (within the limts of the power supply). The two transistors must be of the same part number and be matched -- that is, tested to make sure they have the same beta value. The circuit is useful for any situation where a constant-current supply is needed. Replacing the resistor on the left with a varying load will cause the two loads to always see the same amount of current.

A similar-looking circuit is the differential amplifier:


This circuit amplifies the difference between the inverting and the non-inverting input. If both inputs change by the same amount, the output does not change. This is frequently used in pro audio applications where "balanced" lines are used, e.g., to send microphone signals long distances to a mixing console. Noise that tries to enter the line will enter both inputs in equal amounts (called "common mode" noise) and the amp will reject it. It is also frequently used in sophisticated amplifier circuits where negative feedback is used to stabilize the circuit.

Transistor Numbering, and Packaging

Three main packaging styles are used for transistors these days. "Small signal" transistors are generally found in what is know as a "TO-92" package:



It's a small cylindrical plastic package, nearly always black. One side is flat for orientation, and circuit board designers often use a flat-sided circle on the board silkscreen to indicate which way the transistor is to be inserted. Generally, as you look at the flat side, the order of the pins is emitter/base/collector, but not always. So be sure to check the data sheet for the specific type that you have. Usually, the part number will be printed on the flat side. Not pictured is the TO-18 metal can, which is the same size as the TO-92 but does not have the flat side. A small piece of metal sticks out from the edge of the can to identify the emitter pin. The TO-18 version is not much used anymore, but very common in electronic devices made prior to 1985 or so.

Somewhat higher-power transistors will usually be found in a "TO-220" package:


Photo courtesy of the University of Michigan Smartsurfaces Project

As in the case of the TO-92 package, the order of the pins may vary. The metal tab is intended to be mechanically fastened to a heat sink, to increase the current carrying capacity of the transistor. The tab is often electrically connected to one of the pins, usually the collector, so electrical insulation may be required between the tab and whatever it is fastened to. As usual, check the data sheet.

Serious power transistors come in a "TO-3" case:


Photo from Wikipedia Commons

These are most commonly found as output transistors in audio and RF power amplifiers, and switching transistors in solid-state power controls. Not visible in the photo are two pins that stick out from the bottom side, which are the base and emitter pins; the case itself is the collector. These are made to be inserted into a special socket, and they are usually in contact with a live heat sink (insulated from ground) which is also part of the collector circuit. Transitors this large have a number of non-ideal properties, such as high leakage current and parasitic capacitance.

There are three main systems for part numbering of transistors. As in the case of diodes, there is a JEDEC system for transistor numbering. While diode JEDEC numbers all start with "1N", transistors start with "2N". This will be followed a a three- or four-digit number, and possibly additional letters to identify variants. In general, higher numbers are more recent designs.

Many transistors made in the Far East use the Japanese Industrial Standard (JIS) system. In this system, numbers for PNP types start with "2SA" or "2SB", and NPN types start with "2SC" or "2SD". A European system called Pro-Electron also exists. In this system, the first character is "B" to indicate a silicon-based device. A second letter of "C" or "D" indicates an audio-frequency transistor; "F" or "L" indicates a radio-frequency transistor, and "U" indicates a power switching transistor. Here is a good Web page that summarizes these systems.

Transistor Conventions and Standard Parts

You may have noticed that all of the circuits I've presented in this post have all used NPN type transistors. There is some history for that: in the 1960s when transistors first came into use, for reasons not clear to me, NPN types were a lot easier to make -- and therefore a lot cheaper -- than PNP types with equivalent characteristics. For that reason, designers figured out how to build many common circuits using only NPN types. This persists somewhat in electrical engineering; in situations when the choice between designing a circuit to use NPN or PNP transistors is an arbitrary choice, designers will usually go the NPN route. A side effect of this is that when engineers discuss the characteristics of various transistors, they will generally talk about the NPN type as being the standard, and then just note whether or not an equivalent PNP type exists. PNP types aren't often discussed for their own sake.

In synthesis circuits, we don't typically deal with large currents, so we usually stick to small-signal transistors. (This will change if you get into building amplifiers.) Doing a quick survey of small-signal transistors used in the most common published synth-DIY circuits, I note these three commonly used part numbers:

* BC547. A very useful and inexpensive NPN small-signal transistor, with a maximum collector-emitter voltage of 45V and maximum collector current of 100 mA. A Fairchild data sheet specifies beta as being in the range 110-220 for the "A" version; there are "B" and "C" versions with higher beta ranges at somewhat higher prices. As of this writing, Mouser has the "A" version listed for a whopping five cents USD apiece, quantity 10. They come in the TO-92 plastic package. The BC557 is a complementary PNP type.
* 2N3904. A similar part to the BC547, with max collector-emitter voltage of 40V and a maximum collector current of 100-200 mA depending on which version you get. Beta is in the 100-300 range; here's a Fairchild data sheet. It comes in a TO-92 package and a variety of surface-mount packages. It's a little faster than the BC547, which generally won't matter in synth applications. The main thing you have to watch is the max emitter-base reverse breakdown voltage of 6V. Mouser is quoting them at five cents USD apiece, quantity 25. The 2N3906 is a complementary PNP type.
* 2N2222. The easy-to-remember "all twos" NPN transistor has some virtues over the above, mainly that it can handle more collector current: 500-600 mA for most versions. It is still available in the TO-18 metal can as well as the TO-92 package; the former is good for applications where you need to thermally couple it to something (e.g., the expo converter circuit in a VCO/VCF), and some people claim that the extra parasitic capacitance of the TO-18 can makes it sound a bit better in audio applications. Here's an ST Microelectronics data sheet; collector-emitter voltage is 40V and beta is in the 100-300 range. As in the case of the 2N3904, you have to watch the 6V base-emitter reverse breakdown voltage. Main disadvantages are the somewhat higher cost (cheapest one I see at Mouser is $0.54 USD, quantity 25), and the fact that there is no exactly complementary PNP type.

On To the Next

As you can see from the date of my last post, it's taken me a long time to get this one together, for various reasons. This is the end of the series on discrete parts; next, we'll swing into integrated circuits with a discussion of operational amplifiers -- op amps.



No comments: