Laboratory Exercise 5 –Operational Amplifiers 1 – Basic Op Amp Circuits We had a tiny “taste” of what transistors can do in the previous lab. It was probably clear to you that to get highly functional transistor circuits you have to use more than one transistor. The complexity of the circuits (and number of transistors used) can increase almost without bound in search of the most desirable combination of effects – computers being an extreme example. In this exercise we will start using inexpensive operational amplifiers (op amps) and learn that they can do most of the jobs that transistor circuits can do, with a lot less work on our part. Naturally, this savings in effort for us comes at the cost of someone else’s work (sort of the engineering version of the first law of thermodynamics). There are thousands of op amps available and new designs show up all the time, with different combinations of advantages and limitations. We will use a technically “obsolete” design that is nevertheless a good old reliable workhorse. The differential amplifier circuit that you put together near the end of the last exercise is about ¼ of the total circuitry inside of one of the little 8 pin DIP package op amps that we’ll use in this lab. The schematic symbol for an op amp is shown above. This one is a particular type, the old “tried and true” Fairchild 741, but the symbol is generic – it is used to represent any op amp. This may be the only time you will see the symbol drawn this way, with the up and down (plus and minus) lines coming out of the middle of it. These lines represent connections (or terminals) to power supply voltages external to the chip. They are often omitted from the schematic for simplicity, but they always have to be connected for the real circuits to work. Most of the op amps that we will use require both negative and positive voltage power supplies, but there are single supply models available. For the single supply op amps, ground is the “other” voltage. Recall (from the transistor exercise) the caution about amplifiers not doing well near the rails; this also applies to op amps, although there are some that will work with outputs or inputs that are very near the power supply voltages – referred to as “rail to rail” performance. The point of using both the plus and minus supplies is to move the rails away from ground, making it easier to work with low voltage or DC signals, where “zero” might be the right answer. There are three other terminals (besides the power terminals) on the symbol that are the key to using the op amp. Op amps are differential amplifiers, so they have two inputs and one output (the one at the end of the triangle). There is an important difference between the two inputs: the one marked with a plus sign is referred to as the non-inverting input, while the one marked with a minus sign is the inverting input. The significance of those names will be apparent shortly. Some op amps also have terminals for balancing the inputs and output (exactly zero output for no differential input). These aren’t used often in instruments, so we won’t consider them in this class. The key to the usefulness of op amps lies in the concept of negative feedback. For stable operation there has to be something connected to both of the inputs of the op amp, and the output needs to be connected (the feedback loop) to the inverting input in some way. Feedback (which gives stability) comes at the cost of gain (which we usually also want) so there is an inherent compromise. In the case of op amps this isn’t a problem though, because the gain of op amps is intentionally made very large. A typical spec for the maximum voltage gain (Vout/Vin) for an op amp is 200 V/mV. Concept Question 1 – What is the theoretical voltage gain (unitless number) for an open loop op amp (maximum gain possible) with the above spec (200 V/mV)? What is the theoretical power (P = I V) gain of the above op amp if the input resistance is 10 M and the output resistance is 1 KΩ? Obviously, the power gain can’t result in more actual output power than the power supplies can provide. Usually it’s significantly less, even at maximum amplification. Likewise, the output voltage can not exceed either of the power supply voltages. The signal processing and control capabilities of op amps are well suited for use in chemical instrumentation because of their high accuracy and versatility. They can be used for amplification, addition, subtraction, integration, differentiation, and active filtering (all of which we will demonstrate). Feedback control of experimental parameters, such as temperature and pH is also possible. We’ll start off with some basic circuits in this lab to show you how things work (and when they don’t) and then next lab we will focus on some useful op amp circuits and their application to measurement of physical and chemical properties. We’ll use two popular types of integrated circuit op amps in the lab: the 741 and the 3140. You’ll see that in a lot of circuits these two op amps can be used interchangeably, and in fact many other types could be used as well. Standardization of the pin layout of the packages is helpful in this regard. The major difference between the 741 and the 3140 is the input stage: the 741 uses a BJT (bipolar junction transistor) differential pair, while the 3140 uses a differential pair of p-channel MOSFETs. The input resistance of the 3140 is large enough (> 1GΩ) to allow us to measure pH with a glass electrode. The glass electrode is a good example of a badly conditioned voltage source - its output resistance is several megaohms. The Golden Rules Analysis of op amp circuits is easy using the two golden rules. It’s even easy to see where the analysis fails by realizing that the two golden rules aren’t perfect. This version of the golden rules is from Hayes and Horowitz, but it’s pretty standard stuff. 1. The output tries to do whatever is necessary to keep the two inputs at the same voltage. 2. The inputs don’t draw (source or sink) any current. One amplifier circuit that we will build, the inverting amplifier, is shown below. Let’s think through the analysis as an example. The non-inverting input is grounded, so the op amp wants the inverting input to be at ground too (Rule 1). The current flowing into the inverting input from the input source (Vin/R1) can’t go into the op amp (Rule 2). Therefore, the output has to “push” current through the feedback loop (R2) to cancel out the input current. Since those currents need to be equal in magnitude, but opposite in sign, -Vout/R2 = Vin/R1 or Vout = -R2/R1 Vin. The input resistance of this circuit is R1 because that’s what the input would “see” looking toward the op amp. (Think about what the op amp wants the voltage at the inverting input to be.) We often call this point in the circuit (the inverting input) “virtual ground”. To get a large input impedance, you choose a large resistor for R1 which lowers the gain for a given R2, or you use a different circuit that we will build in the first circuit exercise. The output impedance in this case is that of the op amp, which varies a little from device to device, but is small - so small we’d have a hard time measuring it. The Follower Remember this circuit from the transistor lab? It makes a copy of the signal from a “bad” high output impedance source so that it looks like it came from a nice low output impedance one. The amplifier needs to present high input impedance to the real source to avoid loading it and provide the low impedance output for the rest of the circuit. Circuit Exercise 1 – This is an easy one - the op amp follower. Set up the op amp follower shown below using a 741 and verify that it gives an output that mimics the input by driving the input with a slow (100 Hz) sine wave. The 10 KΩ resistor is just to protect the input of the op amp, it’s not really part of the function of the circuit. There’s a big difference between this circuit and the inverting amp above. What is the input impedance in this case? (Don’t try to measure it, just say where it comes from.) What determines the output impedance? Simulate a “bad” (high output impedance) source by putting in a 10 M resistor between the function generator and the 10 KΩ resistor (in series). Do you see any differences at all? If you put your other scope probe between the 1 M and 10 KΩ resistors, you will see the loading that the scope would normally produce under these conditions. This is a useful circuit in instrumentation, even if it looks like it doesn’t do anything. We’ll get a little more use out of it before we move on by demonstrating one of the important limitations of op amps. Remove the 10 M resistor, switch to the square wave on the function generator, and verify that the output still looks pretty much the same as the input. Now take a closer look at one of the “on” edges of the waveform. That is, expand the time scale to short times. You should see a little lag in the output, relative to the input. If not, increase the voltage amplitude on the input a little (it should be a few volts). This effect is referred to as the slew rate, the speed at which the output voltage changes in response to rapid changes in the input. There is a good reason to design a less than infinite slew rate into an op amp that we will talk about in lecture. Measure the slope of the output’s on time. Do this near the center of the voltage range. Have a look at the specs for the op amp and see if this agrees with the “typical” value for the slew rate. Measure the slope of the output’s off time. Is it symmetric? They aren’t always symmetric there is part and model variation. Circuit Exercise 2 – Set up the inverting amplifier with a controllable input as shown below and measure the output (B) and input (A) with the DMM or the PMD (you can do both simultaneously with the PMD). This circuit illustrates that it’s easier to work with DC signals in op amp circuits than with transistor amplifiers, but its just as easy to work with most AC signals using op amps. With many op amp circuits, it is a good idea to decouple the power supplies at the circuit board with 0.1 μF ceramic disk capacitors - ask how this is done if you aren’t sure. It often is not needed, but it never hurts to do it. What value do you expect for the gain of the amplifier, including the sign? What voltage range do you expect the variable input (15 V power supply plus 15 KΩ resistor and 1 KΩ pot) to give you? Set the 1 KΩ pot to at least five values between 0.1 and 0.9 V, measuring the voltages at points A and B each time. Record the values below. Now change the 15 KΩ resistor connection to the negative 15 V power supply and repeat the set of measurements. A/volts B/volts Calculated B/volts Error % Graph the results and paste the graph in below. Fit the data using a linear regression. Is there a non-zero intercept on either of these sets of data? Is the slope equal to the gain that you predicted above? The source of a non-zero intercept (if there is one) could be an important failing of op amp golden rule #1. The two inputs for the op amp are sometimes not at exactly the same voltage and the op amp tends to magnify the offset. It is possible to trim the 741 op amps to remove this effect, as noted above. It’s kind of a pointless exercise though, since the trim tends to drift with time (presumably due to small temperature changes in the trimming resistor) and will vary from op amp to op amp. Fortunately non-zero intercepts are easy to account (calibrate) for, as long as the response is linear, and it usually is. Next we’ll see how the inverting amp does with an AC signal. Disconnect the 15 KΩ resistor from the 15 V power supply and connect it to the function generator, set for a sine wave output. Using a scope probe at point A, adjust the function generator amplitude and the 1 KΩ pot until the signal at point A is about 0.5 Vpp. Connect the second scope probe to point B and record the peak to peak voltage and relative phase below. Frequency A/volts 100 Hz B/volts Phase of B relative to A 1 kHz 10 kHz 100 kHz Try triangular and square waves and note qualitatively the relative amplitude and any distortion of the waveforms (what shape are they?) for 10 kHz and 100 kHz. Math with Signals - the Summing Amplifier The output feedback loop cancels whatever current is coming into the inverting input when the non-inverting input is held at ground, so it is possible to sum currents at this point (using Kirchoff’s current law). Thus the op amp can be used to do analog math. If we just want the voltage inputs to be summed, we use the same value input resistor to connect to multiple sources that all terminate at the virtual ground produced at the inverting input as for the feedback resistor. The output is an inverted version of the sum of the inputs, but we can re-invert with another inverting amplifier, if we wish. If we want to multiply some inputs by a factor and then add them, we use different input resistors relative to the one feedback resistor. Changing the feedback resistor can amplify or attenuate the final sum. There are many possible combinations. Concept Question 2 – If we put two 5 volt DC signals through 10 KΩ resistors to the virtual ground of an inverting amplifier and use a 15 KΩ feedback resistor, what is Vout? (You might need to sketch this one.) If we put a 5 volt DC signal through 10 KΩ resistor and a 100 mVpp pure AC sine wave signal through a 1 KΩ resistor (both terminating at the summing point) and use a 10 KΩ feedback resistor, what is the output waveform? If we want to add a 5 volt signal to half of a 10 volt signal and then end up with 1/3 of the total, what three resistors (two Rin and one Rfeedback) would work? The summing amplifier is also handy way to add a controllable DC offset to a signal, as we show below. Circuit Exercise 3 – Modify the inverting amplifier circuit as follows so that there are two inputs. Set the FG for a 1 kHz sine wave. Observe the change in the output at C for a 0.5 Vpp sine wave at B as the voltage at A is changed from about 0.5 to -0.5 V. Describe the function that this circuit is providing (what knob on the trainer is it mimicking?) How could the circuit be changed so that the sine wave is attenuated by a factor of two, but the range of the dc offset remains the same? Try this and verify that it worked. Non-inverting Amplifier When high input impedance is required or amplification of the input signal without inversion is desired, the positive or non-inverting input (pin 3) of the op amp is used. The follower is one example, and the non-inverting amplifier is another. A typical example is shown below using a 3140 (high input impedance) op amp. Circuit Exercise 4 – Set up the non-inverting amplifier as shown below. Note: the feedback loop is still connected to the inverting input. All pin assignments are the same as the 741; the same power supply and other connections can be used as above. You don’t need to write anything down, but try to think your way through the analysis of this circuit, and all of the other op amp circuits we do in this lab. They are usually very simple to analyze using the golden rules. In those instances where they are not, it will be pointed out. Record the output voltage at the DMM as shown for at least two values of positive input voltages at point A and for two negative values. You can use the PMD instead to measure both voltages simultaneously, if you wish. A/volts DMM/volts Calc'd B/volts Error % Calculate the expected (Calc’d) voltages at the DMM location shown on the diagram from the equation Vout = Vin (l + 100 KΩ/10 KΩ) and record them in the table above. Calculate and record the percent error between the measured and expected output, and explain the errors, if they are non-zero. What voltage would you get (theoretically) at point B if you put 1 V in at point A? See if this is what you get. Again, how is this circuit different from the inverting amp? Differentiator and Integrator As promised back in the capacitors lab, we are now in a position to build some much better calculus circuits with the op amps. That is, we can now get a nice integrator and an “ok” differentiator. Circuit Exercise 5 – Breadboard the following circuit, which provides an approximate timedifferential of the input signal. Drive it with the function generator and watch the output on the scope. Hint: you have to watch the input between the FG and the first cap. The capacitor in parallel with the 100 KΩ feedback resistor is necessary to avoid instability and excessive noise; try values in the indicated range that give the cleanest signal. For the following input signals from the function generator, record the amplitude of the output signal and describe its waveform. Input 1 Vpp triang. 100 Hz 1 Vpp triang. 1 kHz 1 Vpp square 100 Hz 1 vpp square 1 kHz 1 vpp sine 100 Hz 1 vpp sine 1 kHz Output/Vpp Waveform Comment on the output waveforms as time derivatives of the input signals. As we saw with the pure RC circuits, this differentiator is also used as a filter. Is it a high pass or a low pass filter? Was your answer based on your observations, or were you able to predict a priori which way it was going to come out? Interchanging the input capacitor and the feedback resistor in the above circuit produces the opposite effect, integration. Go ahead and do this as shown below. It doesn’t take too much imagination to come up with a use for integration. Whenever we do chromatography or spectroscopy, we end up with “peaks” and usually it is the integral of the peaks (the area underneath) which is related to concentration in some way. Remember the integral trace from NMR spectrometers? In the circuit below, a 3140 op amp is used to make the integrator because of its low input current. This helps to circumvent another limitation of op amps – golden rule 2 isn’t perfect either, and some current does flow into the inputs. Since the integrator integrates current this would add to the desired signal. We can get around this to some extent by using MOSFET input transistors on the front end of the op amp. Even so, the output will gradually limit as the op amp integrates its own error current and voltage. We’ll try a sneaky solution suggested by Hayes and Horowitz: a big resistor is inserted into the feedback loop to help keep the capacitor from charging up and the integrator from running away with itself. You can probably anticipate that this mixing of the “wrong” component types with the “right” ones leads the circuit to switch roles at some extreme and thus behave non-ideally. Comment on the output waveforms as time integrals of the input waveforms, and how their amplitude changes with frequency. Input 1 Vpp triang. 100 Hz 1 Vpp triang. 1 kHz 1 Vpp square 100 Hz 1 vpp square 1 kHz 1 vpp sine 100 Hz 1 vpp sine 1 kHz Output/Vpp Waveform What type of filter is this one? How well does it work? (If you want to do a Bode plot to find out, that’s fine. Otherwise, you can just check it out qualitatively.) Real World Example (Easy) – Pick one of the circuits you made today and say how it could be used in one of the instruments from the Instrumental Analysis lab. Ok, now build that instrument. (Just kidding but something to keep in mind for the project at the end of the term.)