Introduction: 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.

Step 1: 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.

Step 2: 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.

Step 3: 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.

Step 4: 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.

Step 5: 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)

Step 6: 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.

Step 7: 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.

Step 8: 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.

Step 9: 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!

Comments

author
layla juma (author)2016-09-04

great

author
SHOE0007 (author)2016-08-29

What I would like to do is to make an Radio jammer AM with a 555 timer and use an AMP op chip to amplify the signal. Here is a video of the 555 timer jammer in progress. I now have a two stage DC 0-30 and 0-5 amp powersupply that I can use to power the 555 timer and the Amp Op seperately.

003.mp4
author
Jakester98 (author)2015-01-12

Hey all!

I am currently building and designing an LED music sensitive box. It rums on 3 AAA batteries (so 4.5V). This is an early prototype, and I hope to eventually get it patented.

I have an issue though. The tip31 transistor I am using is killing the signal, and the LEDs only light up if the audio source is all the way up. And even then the LEDs aren't nearly as bright.

I connected a total of 13.5V(9 AAA) and it still wasn't to full power it seemed.

I need something that is cheap, simple and effective please! After reading your whole article, I feel better about op amps, but I'm still not sure what to do with my problem.

Thank you!!!

-Jake

author
StephaneAG (author)2014-08-02

Hi !

I am a beginner at OpAmps, & intend to build some Bio-sensing device(s) / EEG using those (..).

As info, one of the tutorial I read ( from "Bionics for the Evil Genius" ) was using the CA3140 OpAmp -> have you ever come across it ?

Also, I managed to get some ICs for some experiments, but I'm wondering wich one(s) would better fit the need ( EEG recordings ), while it's almost clear now that I need high slew, high gain & low noise [ & low power consumption for the device(s) to be portable ], does it implicitly involve instru opAmps ?

so far, I managed to get:

- TS922IN

- CA3130EZ

- AD620ANZ

- TL084CN

- LM386

any advice is welcome, though I already took some notes on each datasheet for pinouts & stuff (..), but wanted to finish the 1st part of your tut' to have a little background (.. nb: I did NOT skip the intro ;) )

last but not least, & expressed in one word else I won't be able to post:

-> GREAT tutorial, sincere thanks ;)

( I just finished the part 1, & now starting part 2 .. )

author
brmarcum (author)StephaneAG2014-08-04

Hi StephaneAG,
First, I am unfamiliar with using electronics in bio applications. That being said, the body can be modeled like a large electronic device with a fair amount of accuracy. So sensing and probing should be pretty straight forward, as long as you maintain voltage/current protections as needed.
By default, instrumentation amps are much more precise than standard op-amps. And even though they are, at a bare minimum, just 3 op-amps put together, it's better to use a purpose built inst amp on one piece of silicone than to use three separate op-amps. They also typically have higher tolerances, more gain, and less power consumption.
For your application, I think that inst amps would be much more effective at achieving what you want to do.
The LM386 is designed to be used as a power audio amp, so I don't think it would be of good use here, unless of course you are using it to drive an audio circuit.
Hope that helps.

author
Psycho4Ever (author)2014-07-16

Nice instructable I have sent the link to the 14 year old brother of a friend who wants to learn how to use omperation ampflifiers... i think he will have some nice basic knowledge when I am through my bachelor exams so I can build something nice with him without explaining every little detail from the beginning :)

author
brmarcum (author)Psycho4Ever2014-07-16

That is awesome! I would also highly recommend that you do what you can to get him interested in programming, if he isn't already. Knowing how to code is something that kids need to be taught nowadays.

author
Psycho4Ever (author)brmarcum2014-07-17

yeah, he is very interested in electrical engineering and computer science. :) I like him and his curiosity.. :)

author
bergerab (author)2014-07-15

Awesome article. I'm a computer/coding guy by nature, but your tutorials help me learn so much about EE. I love the o-scope pictures you've added to this instructable and all the diagrams in general. This is a lot of great information. I know i'll be coming back to this article as a reference for my future projects! Thank you so much for sharing.

author
brmarcum (author)bergerab2014-07-15

Thanks bergerab! In Part 2 I discuss digital to analog conversion, so that may pique your interest too. Stay tuned!

author
DrHoule86 (author)2014-07-15

So can you use the non inverting amplifier circuit to technically as a step up regulator for like using a 1.5 volt battery or 3v battery to provide a 5 volt source for charging usb devices? i have read the entire instructable and it really looks like it can i just am not sure if the frequency would be correct? Or that the op amp can transfer the amperage oof the battery as well? Thanks in advance.

author
brmarcum (author)DrHoule862014-07-15

Yes, you can amplify 1.5V or 3V up to 5V with an op-amp. But you can't charge much of anything with a AA (LR6) battery. They simply don't have the current available. The trick with op-amps is that they don't transfer the current from the source (high input impedance) but instead utilize the +/- power supply connections to provide the extra current needed. That means that the 1.5/3V battery won't actually be doing the charging, as it can't provide the current needed to force the electrons back into the battery. The only thing the battery could be used for is nothing more than a reference voltage, something that the op-amp can compare it's output with. The output voltage and current characteristics would then come from the power supply connected to the op-amp, not the battery. I found this video which does a good job of explaining a simple voltage regulator. Replace the zener/R1 combo with your battery as Vref and it should work. You'll have to adjust R2 and R3 to get the gain required to convert 1.5/3V to 5V. But you'll still need a second power supply, at least 7V or higher (you won't need a '-' supply. Just ground pin 4). Also note that most op-amps can't source enough current to provide more than a trickle charge at best (and that would be pushing it). That's why the transistor is added in the circuit in the video. It allows more current to be available.
In short, you can do it, but you'd be better of getting yourself a 7805 +5V voltage regulator, or using a 1N4733A 5.1V zener diode and setting that up as a zener regulator. You'll need to be able to provide at least 600mA (1A+ is better) to have a charger that doesn't take all day to charge your phone.

author
Hassanul_ (author)2014-07-12

This is really really good! I am currently trying to build an amplifier for my 3W speakers and this definitely help me out. Thanks for the great instructable!

author
brmarcum (author)Hassanul_2014-07-14

I hope it works for you. Don't hesitate to ask questions. I don't know everything, but I'm happy to help if I can.

author
tripstar76 (author)2014-07-11

could these be used to amplify the signal put out by a video transmitter, like ones used in FPV?

author
brmarcum (author)tripstar762014-07-11

I am unfamiliar with video processing and the signals involved, but I've no doubt that you can. An instrumentation amplifier would probably be better as it has inherently more precision. My gut says that you will want to look at the op-amps with higher slew rates because they can handle higher frequencies. The 741 doesn't do too well higher than about 40kHz, but the OP37 and others do very well up over 100kHz+ while still being able to produce some usable because the Gain Bandwidth Product is so high.

author
Aleator777 (author)2014-07-11

Superb! This is a great resource for many a budding EE and anyone really working with electronics. Thank you for taking the time to make this.

author
brmarcum (author)Aleator7772014-07-11

Thank you, I'm glad you like it.

About This Instructable

46,220views

213favorites

License:

Bio: I've always loved to figure out how things work, so hacking and making just fits for me. I'm a husband, a father, an ... More »
More by brmarcum:Programming Digilent FPGAs Using NI MultisimMonitoring Digital Circuits With the Digital DiscoveryUsing the Voltmeter With the Analog Discovery 2
Add instructable to: