===== Related Reading ===== Hayes and Horowitz: Pages 169 - 177 [[https://www.physics.dcu.ie/~bl/anacont.html|Lawless]]: Chapters 30 - 35
[[https://docs.google.com/document/d/1uGJXTFj_Kee1CHt0Jbwr7UuDV1KxJQ1oMYEW0T2JT4w/copy|Lab Template]]
====== Transistors ====== ---- There are many, many kinds of transistors that are used for a wide variety of things that could honestly take up the rest of these lab sessions.  At heart, most transistors do the same thing: change the electrical properties across two terminals depending on the voltage/current at a third terminal.  The specifics of implementation vary wildly, along with the uses for each different kind of transistor.  Some transistors are particularly good at acting as essentially electronic switches (letting you turn another thing on/off with a voltage or current) while others are better at amplifying signals (transforming a small change of current/voltage at one terminal to a large change elsewhere) In this lab, just to get you an idea of what can be done with transistors, we'll start by talking about one particular kind: ''npn Bipolar-Junction Transistors (BJTs)''
| | | A <5 min intro to the physics of BJT transistors; watch if useful. |
NPN BJTs are designed to operate such that a small current into the base (B) of the transistor will create a current $\beta \approx 100$ times larger through the collector (C) to the emitter (E) of the transistor.  In this state we say that the transistor is in the //**forward-active**// behavior regime.  However, there are two other common possibilities: - //**Cutoff**//: If the voltage between the base and emitter isn't at least a diode drop (i.e. 0.6 V), there will be no current through the transistor at all. - //**Saturation**//: If following the current gain rule would result in the collector to emitter voltage being zero or less, the transistor will instead saturate such that $V_{CE} \approx 0 V$, and additional current will bass through the transistor's base For npn Bipolar-Junction Transistors (BJTS), the three well-defined behavior regimes, as shown below.  Note that this is a first-order model; real devices will exhibit small deviations depending on their construction. {{pdfjs 600px >:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:transistor_behavior.pdf|BJT transistor behavior summary (click to download pdf)}} There are also pnp transistors, which operate in the same general way except that the base needs to be 0.6 V lower than the collector for it to operate instead.  ===== Starting out: Identifying your transistor terminals ===== ---- Unlike diodes, there are no universal markings on transistors that identify their three terminals.  Thus, we'll introduce you to the wonderful world of datasheets! To start: locate a transistor that is labeled **"2N3904L"** on the middle line of text on the flat side. They should be in the drawer of components at the front of the room. If there isn't the 'L' there it's fine, that just denotes a variant in specs that isn't critical for this lab.
It's hard to read the markings! It can be hard to read the engraving on these, a bright overhead light at a slight angle seems to work well.  You may also have luck zooming in with a phone camera, if you can get it to focus.  
| {{:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:transistorsize.png?200|}} | {{phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:2n3904l_enhanced.png?200}} | | Our trusty transistor!  Note that "UTC" refers to the manufacturer (Uniconic Technologies Co)\\ and "SLT" is a manufacturer data code. || | {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:2n3904_cross_section.png?400|}} \\ A cross-section of a BJT transistor, showing the base (silicon), collector (Al connection) and emitter (Au connection). [[https://twitter.com/TubeTimeUS/status/1112542303636226048|Source]] ||
Now that you have the correct part, let's take a look at the datasheet, which contains far, far more information than we need now. {{pdfjs 600px >:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:2n3904_datasheet.pdf|}} The things we need right now are on the first page: the circuit symbol has the Emitter, Base, and Collector labeled as pins 1, 2, and 3 respectively.  The sketch on the right shows how the numbered pins correspond to the device: if you hold the transistor by the legs with the curved part facing away from you, pin 1 is the leftmost one.  While it isn't stated explicitly, pin 2 is the center one and pin 3 is the rightmost. 
| {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:bjtpinout.png?200|}} | {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:bjtpackageorientation.png?200|}} | | A mapping of package pins to the circuit symbol | Mapping package pins to the physical device |
If you or the student is really unsure about which transistor they have, you can use a multimeter in diode check mode to figure it out. * Connect the common (black) lead to pin 1 or 3 and the red socket to the center pin (pin 2). * If it reads like a diode, it's an NPN transistor, which is what we want. Otherwise, it's a PNP transistor, which isn't useful right now. * This works because the silicon regions in transistors share properties with diodes, so a PN junction reads like a diode. ===== Theory Time: Analyzing Simple BJT Transistor Circuits ===== Transistor circuits can't be analyzed in the same way as circuits with just resistors, capacitors, and inductors. We indicated earlier that there are three possible behavior modes for the transistor, which obviously complicates things. But the other issue is that the transistor's behavior depends on external components! Thankfully, for the type of circuits you'll see in this class involving a single transistor there is a fairly straightforward way of figuring out how they'll behave. * Check if the base to emitter (BE) junction can be forwards biased. First check if the base to emitter junction //could// be forwards biased (i.e., have ~0.6V across it) and have a current from the base to the emitter. Whenever $V_{in}$ is less than 0.6V, we're in the ''cutoff'' regime with no current anywhere in the transistor. In that case, we're finished. Otherwise: * Assume the transistor is forward-active and check for contradictions. In practice, this usually means assessing what the voltage at the emitter would be, figuring out the emitter current, and checking if that would imply that the collector would be at a lower voltage than the base. If not, you're done! Otherwise, assume that the collector and base are at roughly the same voltage, and that any additional current needed is from the transistor's base. ==== An example ==== In the case below, we'll compare $V_{in}$ to 0V. Yes, there is a resistor in the path to ground, but the voltage across the resistor for small currents is also small and we're checking if the transistor could be 'on'. Any time time $V_{in}$ is less than 0.6 V, the diode-like junction between the base and emitter isn't forward biased, and there will be no current. No current through the 1k resistor implies no voltage change from ground, so $V_{out}$ will be 0V For the case where $V_{in}$ is greater than 0.6 V we expect that the transistor will be conducting current (i.e. the base to emitter junction is forward biased), and that the emitter terminal $V_{Emitter}$ will be at approximately $V_{in} - 0.6 V$. Conveniently, we're reading off our output voltage from here, so $V_{out} = V_{in} - 0.6 V$ and we'll expect a current of $V_{out} / 1 k\Omega $ which is 1 mA per V at the output. Unless we have a truly lousy power supply this wouldn't change the collector voltage, so there' no contradiction. What happens if $V_{in}$ is greater than the collector voltage of 5V? Don't do that. There are ways of figuring out that behavior, but they aren't relevant to the vast majority of use cases for the transistor and are likely to lead to damaging the device. ===== The Emitter Follower ===== ---- The first circuit we'll build is an emitter follower, a circuit whose output "follows" the input.  Not exciting at first, but we'll build up to its usage. To begin, construct the circuit depicted below, using your variable power supply as the input $V_{in}$. | {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:emitter_follower_3x.png|}} | {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:emitter_follower_full_loops_3x.png|}} | | A compact representation of an emitter follower circuit | An expanded diagram that explicitly shows all connections and loops in the circuit | Note that you'll have to change the configuration if you want to explore negative voltages: | {{:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:positivepsconnection_0.5x.png|}} | | {{:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:negativepsconnection_0.5x.png|}} | | If you connect the black terminal to ground and use the red and green terminals for $V_{in}$, the result will be a positive voltage If you connect the red terminal to ground and use the black and green terminals for $V_{in}$, the result will be a negative voltage This is because the voltage on the power supply screen only indicates the //difference// between the red and black terminals. | As an alternative, you can set your function generator to a DC voltage and use that as the input for your circuit. This will let you set negative voltages without reconfiguring wiring. Keep the input voltage between $-5V$ and $+5V$ .  If it is too negative, it can damage the transistor.  If it is too high, you can end up in a funky behavior regime for your transistor which is not particularly useful.
HELP! My output is oscillating when it shouldn't be! Don't panic! This is one area where textbook physics and experimental physics can diverge. When we build the actual circuit, our pins will effectively have //very// small capacitors across them due to the protoboard's construction (metal plates separated by distance = capacitor). In addition, loops of wire may introduce inductive connections we weren't expecting. The end result is that you can end up building an accidental oscillator, with a frequency from kHz to MHz. Thankfully, there are a few solutions that may help and have little impact on the rest of your circuit: ** Bypass capacitors ** By adding capacitors between power supply connections and ground, you introduce a path for high-frequency fluctuations that will bypass the rest of your circuit. Meanwhile, the DC behavior will be essentially unchanged.
| {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:emitter_follower_full_loops_bypassed_3x.png|}} | | Our emitter follower with an added bypass capacitor. Note that the exact capacitance isn't critical at all, but smaller capacitors (e.g. in the nF range) will have less impact on the DC behavior. |
Note that it's important to place bypass capacitors **physically close** to the area that might have problems. Placing things two feet away at the supply won't be much use for handling non-ideal behavior. ** Base Resistors ** The other option that may work is to add a small resistor (~10 - 100$\Omega$) between the input voltage and the transistor base. This helps modify the characteristics of some RLC network we've inadvertently created so that it suppress unwanted oscillations.
**If you don't keep your input below 5V**, you may discover the secret, fourth regime of behavior. Once the base is around 0.6V higher than the collector in this circuit, the ''NPN'' transistor will go back to its ''PN'' semiconductor roots and behave like a pair of diodes, conducting current from the base to both the collector and emitter. There are very few reasons why you would ever want this. > Test the limits of your circuit by determining the maximum and minimum values of $V_{out}$ along with the values of $V_{in}$ that produce these extremes. The maximum for $V_{out}$ should be a little less than 5V, likely around 4.8V (when the transistor is saturated and $V_{in}$ is >= $V_{out}$) The minimum for $V_{out}$ should be 0V (when the transistor is in cutoff. In an ideal case when Vin is less than 0.6V, in reality probably around 0.4 to 0.2V.) The rest of the time, $V_{out}$ should be $V_{in} - 0.6 V$ (when the transistor is forward-active) After you resolve how the circuit responds to DC voltages, let's use a sine wave as input instead.  Replace the input connection with the function generator, and set the peak-to-peak amplitude to 2V. > What do you observe under these conditions? $V_{in}$ should follow $V_{out}$ until it is 0.6V or lower, and then $V_{out}$ should be 0V. This basically clips off the bottom of the sine wave. Adjust the ''offset'' until $V_{out}$ has the same shape as $V_{in}$.  > For what range of offsets does the output "follow" the input? Offsets between 1.6V and 4.4V should keep the transistor forward-active at all times, and thus "following" the input. ===== Putting the transistor to work ===== So, the emitter follower circuit worked, but it isn't that exciting.  Let's tweak the circuit by adding in an LED on the emitter side.  Note that the longer leg of the LED is the anode, so it should be the one closer to $V_{out}$
| {{:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:led_pinout.png?50|}} | | A typical LED, along with its circuit symbol. Note that the anode (more positive side) has a leg that is longer than the cathode. In addition, the diode's knee voltage is typically between 2 and 3 V. The other telltale identifier is that the anode connects to the larger internal metallic contacts with a notch in the center|
Why the different knee voltage? Light emitting diodes are designed with different semiconductor bandgaps than normal diodes. For instance, red and yellow LEDs may have a blend of Gallium with Aresenic and Phosphor to create ~2 V bandgaps. Blue LEDs use nitrogen and magnesium compounds to ge a ~3V bandgap. Why? Well when there is a direct 2-3 eV transition in the semiconductor, electrons and holes recombining will produce produce visible light (whose photons have a couple eV of energy). See also [[https://en.wikipedia.org/wiki/Light-emitting_diode_physics]] White LEDs are just blue LEDs with a phosphor material that will down-convert some blue photons into other colors of light, which our eyes interpret as white.
| {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:crappy_led_driver_3x.png|}} | | LED driver I | > Predict how the above circuit will act (i.e., when the LED will be light and when it will be dark) as you vary $V_{in}$ between 0 and +5V. Use the DC power supply for this part. === How do I predict BJT transistor behavior? === * Check if the base to emitter (BE) junction be forwards biased. First check if the base to emitter junction //could// be forwards biased (i.e., have ~0.6V across it) and have a current from the base to the emitter. In this instance, we're comparing $V_{in}$ to 0V. Whenever $V_{in}$ is less than 0.6V, we're in the ''cutoff'' regime with no current anywhere in the transistor. In that case, we're finished. Otherwise: * Assume the transistor is forward-active and check for contradictions. In practice, this usually means assessing what the voltage at the emitter would be, figuring out the emitter current, and checking if that would imply that the collector would be at a lower voltage than the base. If not, you're done! Otherwise, assume that the collector and base are at roughly the same voltage, and that any additional current needed is from the transistor's base. Stress that students should be making predictions! It doesn't matter if they're correct, what matters is that they're trying to use what they know about circuits to predict their behavior. Build the circuit, test your predictions, and resolve any discrepancies. The input will need to surpass both the 0.6 V of the base-emitter junction, and the LED's turn-on voltage, thus it will need to be 2.6-3.6 V. The exact value depends on the color of the LED and how bright you'll accept as "turning on" If there's less than an hour of lab left, skip past this to the third circuit. You can come back if time permits. While that circuit can work, let's change it up by switching the LED to be on the collector side > Predict how this will change the LED's behavior (i.e. the ranges of inputs that will light the LED) | {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:better_led_driver_3x.png|}} | | LED driver II | Build the circuit, test your predictions, and resolve any discrepancies. In this instance, the input only needs to exceed 0.6V to turn the LED on. However, when the input gets within a volt or so of the collector voltage (i.e. when Vin ~ 4 V) the transistor will suddenly switch to saturation and the LED will turn off. This is because at this point the circuit would have to drive current backwards through the LED to keep the transistor forward-active, which isn't possible to any meaningful degree. In addition, the LED's current is controlled by the combination of the emitter resistor and the input voltage. A larger resistor will result in a dimmer LED (for the same input voltage). Finally, we'll make one last modification, moving the resistor to the collector and adding one to the base as shown below:
| {{:phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:best_led_driver_3x.png|}} | | Yet another LED driver circuit. Notice that there are now resistors on both the base and collector side, while the emitter is grounded. |
In this instance, there are a few more steps to the reasoning. We've thus provided a logic chain that should (approximately) predict the circuit's behavior. We're using quite a few approximations and simplified models, so some of the voltages may be off and transitions may not be sharp, but the qualitative behavior should still hold. The input still only needs to exceed 0.6V to turn the LED on. However, after we hit that threshold, the 47k resistor at the transistor's base will come into play. To enforce the condition that $V_{BE} = 0.6V$, the resistor will account for the rest of the input voltage, resulting in a current at the base that is around $V_{in} - 0.6 V / 47k \Omega $. The maximum forward-active current can be found by assuming that the collector is at 0.6 V. Combined with the power supply's 5V, and the LED's 2 to 3 volt knee, Kirchhoff's loop rule implies that there will be $5 V - 0.6 V - ($2 to 3$) V = 1.4$ to $2.4 V$ across the resistor. This corresponds to a 1.4 to 2.4 mA current for a 1k. We'll assume the smaller value for a moment. 1.4 mA of current at the collector implies $I_{C} / \beta = I_{B} \approx I_{C} / 100 = 0.014 mA$ at the base if the transistor is forward active (assuming a typical $\beta$ of 100). That threshold is reached when $V_{in} - 0.6 V = 47 k \Omega * 0.014 mA = 47 * 0.014 V = 0.66 V $, and thus when you add 0.6V to both sides the threshold is $V_{in} = 1.26V$. Higher input voltages will saturate the transistor, resulting in a higher current at the base & emitter but no change at the collector (the LED side) Putting things together, we expect: * no current when $V_{in}$ is less than 0.6 V * a ramp up in brightness until around 1.26V * nearly constant brightness above that as the transistor becomes saturated. $V_{in}$ going above 5V would also not be problematic in this case, as the 47k base resistor keeps any funny business from happening. Build the circuit, test its behavior, and briefly compare the three circuits. You can check an [[https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgoqoQFMBaMMAKABcQU89xiURs2Qr35UIMQti4oALBkIpSGMJFJRohBHwwJsymYRnZmyKgBM6AMwCGAVwA2bFmAUCh4GTLfCw8ziAsbBzYGezozcCgomEhWACdvEGJhQR9PKJU4FgBzRLQeVM4ZKhKWACVE5MSZHhKQYuo6mARnDH58kXAuTqpyJCQm6CQANQB7R2tsuhYErh4wPk58HtNIFgAHTm5OuYE0AWjV+DXc3akqM4RRKA36uA8vYouG7EPM47WAd0SwdKeHm65f6yKjAtrRFhAA | example simulation]] to get a better feel for the expected behavior. Change $V_{in}$ with the voltage slider on the right-hand side of the screen. Note that the simulation hits saturation much quicker; it is using more sophisticated models of transistors and LEDs. Keep this circuit built on your breadboard! ====== Your first sensor ====== ---- We're going to diverge slightly now and have you build a darkness detection sensor.  We can do this by utilizing a photoresistor along with a regular resistor in a voltage divider. Photoresistors are semiconductor devices whose resistance decreases as more light is incident on them.  | {{:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:photoresistor_symbol.gif|}} |{{:phylabs:lab_courses:phys-226-wiki-home:spring2020-lab-4-transistors-i:photoresistor.jpg|}}| {{phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:commercial_light_enhance.png}} | | The schematic symbol for a photoresistor.  The arrows are optional. | A physical photoresistor.  Note that ours is quite small, about 3mm wide on the top part. | A commercial nightlight that uses a photoresistor.  You can see it under a transparent dome that's just above the brand logo | > Using your digital multimeter, measure the resistance of your photoresistor in both ambient light and when covered. Ambient light will probably be in the kΩ range, but it can be lower. Covered can be up to MΩ (yes, mega!), but 10s to 100s of k are fine too. They are pretty variable little components. Now that you have this information, your goal is to design a voltage divider circuit (using your DC power supply) that will: * Have $V_{out}$ be relatively small ~0.5 V) in ambient light * Have $V_{out}$ increase as it gets darker, getting to at least $+3V$ when completely obscured * Be constructed only using your power supply, the photoresistor, and one or two other resistors There is not a unique solution to this problem, so don't worry if your implementation isn't exactly the same as someone else's.  Also don't be concerned about linearity or calibration, we don't have to tools to address that at this point in the course. > Create a diagram or sketch of your circuit, and describe how you expect it to behave > > Build and test your circuit.  If it does not behave as expected, include what you did to make it function. | {{phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:unknown_sensor.png}} | | A template for your sensor. You'll want to replace ''X'' and ''Y'' with the components you're using. | The most straightforward way to do this is using a voltage divider circuit. The other resistor should be between the ambient light and covered resistances, probably an order of magnitude away from either one if possible. The battery side should connect to the fixed resistor, and ground should connect to the photoresistor. The output should then behave as we'd like. ===== Making a nightlight ===== Now that you have a darkness detector, let's try and turn it into a nightlight by adding a new LED and resistor to its output:
| {{phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:led_circuit_only.png}} | {{phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:led_connected.png}} | | A depiction of the circuit to be attached to your sensor | Full schematic of the sensor and light |
> Describe what happens when you cover and uncover the sensor. The LED will either light dimly or not at all This combination doesn't work because (in electronics jargon) this circuit loads the other circuit. This means that it's pulling enough current (or has low enough impedance) to change how the other circuit functions. Now that that (presumably) went poorly, we'll go back to the transistor circuit we built earlier:
| {{phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:transistor_driver.png}} | {{phylabs:lab_courses:phys-226-wiki-home:lab_4_transistors_i:transistor_connected.png}} | | The transistor LED driver you previously built | Connected light sensor and LED driver |
> Describe the difference in how the circuit behaves compared to the straightforward implementation. This circuit works better now because we've addressed the impedance problem The input impedance of this circuit is (roughly) equal to the base resistor's value of 47k. This results in a much smaller impact on our sensor, letting the night-light work as intended. {{page>phylabs:lab_courses:phys-226-wiki-home#Assignments&nodate&nouser&noheader&inline&nofooter}} ====== Lab Recap ====== In this lab, we walked you though: * The basic functional behaviors of a BJT, NPN transistor * Cutoff, where there is no current through any part of the transistor * Forward-active, where a small current at the base is amplified to much larger currents at the emitter and collector * Saturation, where the base voltage is comparable to or higher than the collector voltage, and there may be significant base current * How to look up information in a datasheet * Datasheets are to electrical components what stackoverflow is to programming. * Using datasheets won't be a huge part of this class, but knowing that they exist is essential to even moderately complex circuit design. * How to use a transistor as an electrical on/off switch * This property is the basis of essentially all modern computing. Being able to //conditionally// change circuit properties is enough to implement mathematical logic operations, and the rest is built upon that foundation. * Different, more power-efficient kinds of transistors are used in most computers but the basic idea is the same * How to use a transistor to fix impedance problems * Without active circuit elements like transistors, chaining circuits together to do useful operations becomes extremely difficult. * We'll introduce operational amplifiers and other integrated circuits later that can do this job much better. ==== Optional Part: LED control techniques (This is ungraded) ==== === Set the function generator to produce a square wave and vary the frequency. === O.1 At what frequency do you stop seeing individual blinks (on/off cycles) of the lights? This should be somewhere on the order of 10s to 100s of Hz. === Set the frequency well above that which you found in part O.1, scroll down to the 'duty' option and select it.  Look at $V_{in}$  and $V_{E}$  (the emitter voltage) on the oscilloscope as you adjust the duty cycle percentage on your function generator.   === O.2 Briefly describe the effect the duty cycle has on $V_{in}$.   O.3 What effect does altering the duty cycle have on the brightness of the LEDs?  Explain why this happens.