Op-amp Basics (part 1)
by brmarcum in Circuits > Electronics
109430 Views, 236 Favorites, 0 Comments
Op-amp Basics (part 1)
Operational amplifiers (op-amps) are some of the most important, widely used, and versatile circuits in use today. The first op-amp used vacuum tubes and was released in 1941 by Bell Labs. The ubiquitous ua741 was released in 1968 and is considered by many to be the standard upon which others are based. It is still in production today from various manufacturers. Designed to amplify a small signal up to something useful, op-amps are applicable in an extremely wide range of projects, everything from audio circuits, to data acquisition, to signal processing. My goal is to simplify the op-amp into something easy and fun to use, highlighting the important stuff and keeping it simple.
Theory
If you could really care less about the theory behind op-amps or just don't want to read right now, skip this step. There won't be any heavy math involved, just some summarizing. I recommend you take the time at some point to read up on them though since they are so useful in so many applications. Some really good educational/instructional material is available here, under Chapter 5.
Op-amps are usually two-input, one-output devices, with additional pins for +/- voltage supplies. By looking at the difference between the two inputs, and using the +/- voltage supplies as max/min output values, the op-amp will output a voltage reference value that can be many times higher than the input. The value of amplification is called the gain and is often seen measured in decibels (dB). Regardless of what you are amplifying, be it voltage, current, or power, dividing the output by the input will give you your overall gain. Different op-amp designs have different maximum values that they can achieve for the gain, but for the vast majority of applications, you get to choose the level of gain you want to apply to the input differential. You can also choose to have the output be the inverse of the input or match the input. The inputs are labeled "inverting" and "non-inverting" and there are two equations to determine the gain value of your op-amp design, one for a non-inverting configuration and the other for an inverting configuration. Note that for the non-inverting equation, you have an additional gain of 1 that you can't avoid. If, for example, you connect the non-inverting pin to GND and the inverting pin to your signal, the output will be phase shifted by 180 deg and amplified by the gain. On a graph, it would be completely flipped upside down over the x-axis (see image 2). If you switch the inputs and connect the inverting pin to ground and the non-inverting pin to your signal, the output will look just like the input (see image 3).
Op-amps typically have an extremely high gain built in by default which you the user cannot change, and if you don't design feedback into the system, you'll saturate the op-amp very quickly and hit one of the voltage supply rails. That implies that an op-amp with no feedback will function as a comparator, meaning that if there is a difference in voltage between the two inputs (+ or -), even by the tiniest amount, the output will match the value of the corresponding supply voltage rail. In logic terms, you get a 1 or 0. This can be useful in certain applications, like generating a square wave from a sine or triangle wave, but not in all cases. Many times you want the output to be a scaled version of the input, identical except for magnitude. In order to control the gain, you must implement feedback, connecting one input or the other to the output through one or more passive components like resistors, capacitors, or inductors.
Some applications of op-amps include voltage buffers/followers, low-, high-, and band-pass filters, comparators, integrators, differentiators, peak detectors, voltage/current regulators, and analog-to-digital converters and digital-to-analog converters. I will be going over some of these uses in later steps.
Op-amps also come in many, many different design options, so choosing the right one can be difficult. Should you use an OP37 or LM741? You decide you want really high speed, so you choose the OP37. But which version? The OP37A, C, E, F, G, N, NT, GT, or GR? Will you need more than one in your design? If so, should you use singles, duals, or quads? Of course each one has it's own datasheet, so it can be difficult to do comparisons easily. Just to give you an idea, I've included an Excel spreadsheet with just a few parameters listed to show the wide range of ICs available. It is not an exhaustive listing of all specs, just some basic data.
By comparing some of the data, we can see that the 741 op-amp is not very high speed (low slew rate), nor does it have a high gain-bandwidth product (GBP). The OP37 however has a much (much, much) higher slew rate and GBP, so it can be used over a much wider range of frequencies than can the 741. The other ICs all fall somewhere in the spectrum of speed vs reliability vs... whatever else you want to compare. Each one has it's own application, and it's up to you to decide how you want to use it. For most applications though, pretty much any op-amp will work. If you are designing something that is on the extreme end (e.g. high speed, high voltage, high gain), look through the datasheets to find the one that best suits your needs. As mentioned, I will be showing some simple op-amp circuits that can be built with any of these chips, but there will be some points where I point out the strengths/weaknesses of certain chips. For more information about op-amps, see this website.
Downloads
Parts and Tools
Since this is more of a guide than a specific project, the parts and tools list can vary widely. That being said, I've listed the basic components that I'm using.
Parts:
- 8-pin DIP op-amp IC. All chips have their strengths and weaknesses. For a good, robust, all-around op-amp IC, get some 741 chips. They are available from many manufacturers under slightly different names. Just look for "741" in the chip ID. If you need high speed chips, get the OP27 or OP37. The circuits that follow can all be built with nearly any op-amp IC available.
- various resistors. Gain is directly related to the ratio of at least two resistors, so whole number multiples will be the easiest to work with. 100, 220, 330, 470, 680, 1k, 2.2k, 3.3k, 4.7k, 6.8k, 10k, 20k, 47k, and 100k are all good values to have on hand.
- jumper wires as needed
- various ceramic disc capacitors as needed. 1nF-100nF (101-104) are easy values to obtain and work with.
Tools:
- power supply
- waveform generator
- oscilloscope
These tools can be expensive and take up a lot of space, so I recommend the Digilent Analog Discovery or the Electronics Explorer Board, both of which contain all three in one simple, easy to use package. They both require the free Waveforms software. I will be using the Discovery, so all scope images will be screen shots from that. Also, the Discovery can supply +/- 5V at about 150mA, so all Vs connections will be those respective values. The EE board can supply +/- 9V at up to +/- 2A if you need more power output.
The last image is of a 741 op-amp pin-out diagram, which is the chip I will be using. Double check the pin-out diagram for the op-amp you want to use, especially multiple op-amp packages. Positive voltage from your power supply connects to pin 7 and the negative to pin 4. Pin 2 is the inverting input and pin 3 is the non-inverting input. Pin 6 is the output. Pins 1 and 5 are the offset null pins, which are rarely used and so will not be covered in depth here as most op-amps don't even have them, especially in larger dual and quad packages. Pin 8 is not connected.
Voltage Follower/Buffer
One of the most basic uses for op-amps is the voltage follower or buffer (image 1). Ideal op-amps have the characteristic that they have infinite input impedance, so if there is a point in your circuit where you can't draw too much current from the previous portion of the circuit but you still need to use the voltage level as it is, you can add a voltage follower/buffer in between. This will buffer the previous part of your design from too much current draw while allowing the output voltage to exactly follow the input.
Build: Connect the +/- power supply pins to pin 7 (+) and pin 4 (-). Put a jumper wire between pins 2 and 6. Connect pin 3 to your input signal. Pin 6 is the output. (image 2)
For an example of this little gem in action, see step 6 in this Instructable. Without the voltage follower, the output waveform is distorted due to the transistor characteristics.
Amplifiers
Amplifiers are another basic function of op-amps. First we look at the inverting configuration in image 1. This is easier to use since the equation simply inverts the input and scales it by the gain factor as determined by the resistor ratio (R2/R1). Technically the gain is considered to be negative for an inverting amplifier, but most applications will not be dependent on the phase of the input signal, so inverting it won't affect the outcome, and thus the negative sign can be ignored.
Build: Connect the power pins as before, + to pin 7 and - to pin 4. R2 goes across the IC between pins 2 and 6. One end of R1 goes to pin 2 while the other end is where the input signal connects. Pin 3 is connected to ground. (image 2) Use a small signal as your input for the circuit as the gain here is 10X. From the o-scope image you can see that the input (red) is about 200mV, while the output is 2V, which is what we want (image 3).
Next is the non-inverting configuration (image 4). The gain is still dependent on the ratio of the resistors, but with an extra 1 thrown in: (1 + (R2/R1)). The output phase matches the input phase, but the gain is slightly higher. The extra 1 becomes more and more negligible as the ratio (R2/R1) increases, but as a personal preference, I only use this circuit if I absolutely need the signal phases to match.
Build: Same power connections as before, but this time we simply switch where the input and ground connections go. Ground goes to the resistor tied to pin 2 and the input goes directly to pin 3 (image 5). Image 6 shows the o-scope data, and we can see that the phases now match, but the output (blue) is slightly higher than it was before because of that extra 1 we get from the gain equation.
For either configuration, if you make (R2/R1) too large or the amplitude of your input signal is too high, you will max out the available voltage at the power rails, saturating the op-amp output and clipping the signal into a square wave (image 7).
It is entirely possible to realize a gain of 100,000 or more with most op-amps. That would convert a 1 millivolt signal to 100 volts. That can be very useful in circuits where the input is extremely low, like microphones, flex sensors, medical devices, etc. The problem is that the input resistance is based solely on the value of R1. If your doctor connects a sensor to your brain (please don't, it's just an example), you probably don't want to be drawing too much current, right? So you make R1 large (1MΩ+) to limit the current draw, but to realize a gain of just 100, that means that R2 must be 100X larger, or 100MΩ. That's a lot and can be difficult to realize, especially with even higher gains. Image 8 shows a circuit design that will allow for a very high input impedance (1MΩ) and high gain (-102), but that can still be built with readily available parts. The equation is shown in the image.
Low-pass Filters
Electronic filters are everywhere, in almost everything we use. AM and FM radio signals must filter the carrier wave (see this Instructable for more on that). The signal coming through your phone filters out frequencies above 6kHz since the human voice can't get that high and there is no need to pass them through. Op-amps provide a very easy way to implement very effective filters.
There are several types of filters, with hybrid variations as well. Low-pass filters allow low frequency signals to pass through, from DC up to the cutoff frequency, while attenuating high frequencies. High-pass filters allow high frequencies to pass and attenuate lower frequencies. Pass-band filters allow a certain range of frequencies to pass and cutoff frequencies above and below the two corner frequencies. Stop-band filters cutoff a certain window of frequencies and allow those above and below the corner frequencies to pass. The cutoff frequency is where the input signal has been attenuated by 3dB, which equates to Vin/√2. For first order filters the cutoff frequency is not a sharp drop, looking more like a gradual slope on a logarithmic graph, so some passage of frequencies into the cutoff region will happen up to a certain point. By adding several filters in series, you increase the overall order of the filter and this cutoff slope can become very steep, in fact almost vertical if built properly. The math behind all of that is rather involved, relying heavily on a good understanding of differential equations and transfer functions, so I won't get into that.
Image 1 is of a low-pass filter. First determine the highest frequency you want to pass through the filter. This is your cutoff f. Next determine the values for R and C using the equation f = 1/(2π*R*C). For this example, let's arbitrarily choose f to be 2kHz. I've found that choosing the capacitor and building a resistor network to match is easier than the other way around. So let's choose a 100nF (104) ceramic disc capacitor. Doing the math gives a value for R of 795.775Ω. Remember that some frequencies above the cutoff f will leak through, so getting close should be good. We can either add a 470Ω and a 330Ω resistors together in series for 800Ω, or use a potentiometer. Also, filters can still have gain according to the equation gain = -(R2/R1), so to have unity gain (gain of 1) we match the input resistors at 800Ω.
Build: Connect the power pins as before. Between pins 2 and 6 place a 100nF (104) capacitor, and the 800Ω resistor series. Place another 800Ω resistor series between the input and pin 2. Ground pin 3. (Image 2)
Using your waveform generator, start at a low frequency (200Hz or less) and gradually work your way up the scale until you pass the cutoff frequency (20kHz+). Using your o-scope, observe the input and output on the same scale and observe how it attenuates at higher frequencies. (Images 3, 4, and 5)
High-pass Filters
High-pass filters are similar to low-pass, the only difference being where we put the capacitor (image 1). The equation for determining cutoff frequency f is the same, but this time frequencies below the cutoff will attenuate and higher frequencies will pass.
Build: The only thing you have to do is move the capacitor in between the input signal and the input resistors. (Image 2) Images 3, 4, and 5 show the effect this circuit has on the signal at 200Hz, 2kHz, and 20kHz respectively.
Band-pass Filters
Band-pass filters are a combination of a low-pass and high-pass filters (image 1). The trick is that while the input R1-C1 combination forms the high-pass portion and the feedback R2-C2 combo forms the low-pass portion, the ratio of the two resistors R2/R1 still determines the gain of the amplifier, so the math can get a bit fun. First determine your band-pass region, i.e. the highest and lowest frequencies you want to pass. These are the two corner frequencies we want to use in our calculations. Let's use 200Hz and 2kHz. Using the same equation as before, and choosing either R or C, we can determine the other. It may be easier to choose R2 and R1 according to the gain you want to achieve and then calculate C1 and C2 based on that. It is perfectly acceptable to choose whatever cutoff frequencies and gain you want, within the limitations of the op-amp. Let's increase R1 and R2 by a factor of 10 to 8kΩ. This makes C1 10nF (103) and C2 100nF (104).
Build: Connect power as before. Set up R1 and R2 as 8kΩ resistors, either with a potentiometer or with a 4.7kΩ and 3.3kΩ resistor in series. Place one resistor series across pins 2 and 6, as well as the 10nF (103) ceramic capacitor. Tie one end of the other resistor series into pin 2 with the 100nF (104) capacitor on the between the input and the resistors. (Image 2)
There are five points on the o-scope to highlight here. Below the lower cutoff frequency (image 3), at the lower cutoff (image 4), in between the two cutoff frequencies (image 5), at the higher cutoff (image 6), and beyond the higher cutoff (image 7).
Image 8 shows a generic schematic that will achieve the same results, but uses two filters cascaded together. The first part is the high-pass filter, followed by the low-pass filter. By placing the HP filter first, the LP filter will attenuate any high frequency anomalies that may come through if we switch them. Also, each part can have it's own gain, which may make it easier to construct from parts on hand.
Stop-band Filters
Stop-band filters, or band-reject filters, are those that filter a specific frequency or band of frequencies but let higher and lower frequencies pass. These are definitely more difficult to design but are very useful if you are experiencing noise at a specific frequency range in your circuit that you want to filter out. One variation is the notch filter, which is used to filter specific frequencies, like the noise from 50-60Hz AC mains lines.
With a band-pass filter, we could build two separate filters, one high-pass and one low-pass, and then cascade them one after the other. That was possible because their pass-band regions overlap, but this is not the case with stop-band filters. We still use a LP and HP filter, but they must be placed in parallel and then a third op-amp is configured as a weighted summer (more on that later) and the two signals are added together to produce the output. Image 1 shows the schematic.
To design, we first need to know what range of frequencies will be blocked. Set the lower cutoff frequency as the cutoff for the LP filter and the higher cutoff as the cutoff for HP filter. This is the reverse of how we designed the band-pass filter. From the equation we've used before, we know that the cutoff frequency f is determined by f = 1/(2*pi*R*C). Using a 100nF (104) capacitor and 4.7kΩ resistor, we achieve a LP cutoff of 340Hz. Using a 1nF (102) cap and 4.7kΩ resistor, the HP cutoff is 34kHz. From there, put the two outputs through the summer and your're done.
Build: Power connections like before, '+' to pin 7 and '-' to pin 4, this time to all 3 op-amps. Connect the LP filter as before. Then connect the HP filter as before. The outputs will then go to the summer input as shown in the schematic. See image 2.
Images 3, 4, 5, 6, and 7 show the output at 34Hz, 340Hz, 3.4kHz, 34kHz, and 50kHz respectively. At 3.4kHz the output is very low, showing an attenuation of -34dB (20*log(Vout/Vin)). That is very significant. Also note that image 7 is showing more of a triangle wave than a sine wave. This is due to the low slew rate of the ua741 op-amp. In short, it can't change the output as fast as the input is changing, so it's playing 'catch-up' the whole time. Image 8 shows the same output, but this time using one OP27 and two OP37 op-amps, which have a much higher slew-rate.
More to Come...
More op-amp circuits are soon to follow! As you can see, the op-amp is very versatile and useful, and I'm not even close to done. Please check back soon!
EDIT: As promised here's Part 2.
Please don't hesitate to ask questions in the comments below. You never know when someone else has the same question and that way we can all learn and help each other get bettter. Have fun building!