The Ultimate Op-Amp Comparison

Intro

This is an op-amp that I’ve made completely from scratch in order to find out what exactly goes into making a good op-amp. Despite being perhaps one of the most important analog components, op-amps are oftentimes the most confusing, with all of their datasheet parameters and whatnot. That’s why I’ve put together this video, so you can find out what exactly you should look for when you’re deciding on an op-amp for your next project.

Some of you likely remember one of my older videos about that DIY op-amp that I made. Unfortunately, I didn’t really test its performance in that video, so it’s difficult to tell just how well it compares to a commercial product. Speaking of the commercial op-amps, I gatherd the 6 op-amp ics to compare to the DIY op-amp. But first, let’s begin with a brief recap of the DIY op-amp.

What’s in the DIY version

Here is a recreation of the original design from that video. I recommend you watch it if you don’t know how it works. But as a basic run down, the first stage is a differential pair, otherwise known as a long tailed pair. This is the segment that will compare the voltages on our inputs. Afterwards, it is followed by a simple PNP common emitter amplifier. This amplifier helps convert the differential output back into a more useful single-ended output instead. There is also a small compensation capacitor here for stability, but more on that later. Finally, it is followed up with another transistor amplifier. This time it’s an NPN emitter follower. The two transistor amplifiers are there to provide a buffer to the differential amplifier front end, because it’s not strong enough to drive an output load on its own.

Op-amp introductions

Now let’s get into the comparisons. I’ll introduce each op-amp. First up is the LM358, which seems to be a popular part here on Sine Lab. It’s a general purpose op-amp, so it’s not particularly good at anything, but it can be used for most projects. It’s also really cheap. Cheap enough that I bought 50 for this video. Next, the TL072. It claims to be a low noise op-amp with JFET inputs, although I had to wrestle with it in my microphone project. Up next is the MCP6022, which I’d say is another general purpose op-amp. It’s definetly better than the LM358, but also considerably more expensive. I only bought 5 of these. The next op-amp is the NE5532, which is a popular choice for audio circuits on the internet. Next is the UA741, which is one of those classic ics that is somehow still around today, just don’t expect good performance from it, at least in modern standards. And finally, we have the OPA134. This one is specifically designed for high-performance audio, and it delivers with a hefty price tag

Rail swing

Now that you are familiar with the op-amps, we will begin with the voltage ranges of these op-amps, since that is likely the most basic and first requirement that you will need to take a look at. Obviously, make sure that the op-amp’s minimum and maximum supply voltage requirements are being met by your project. What is more interesting is how closely your output can reach your supply rails. The MCP6022 is perhaps the most ideal out of the bunch in this case, in that it can output all the way up to the positive supply, and all the way down to the negative rail. So, for example, if we supply the MCP6022 with a 5v supply, and then configure it as a non-inverting buffer, we can perfectly output that 5v peak to peak sine wave. The other op-amps would have a problem with this. If we replace the MCP6022 with the OPA134, but keep all other parameters the same, our sine wave will now clip at the top and bottom. The OPA134 can swing to within 1V of the positive rail and very close to the negative rail, but it can never reach either rail. The same goes for the others, except the LM358. It isn’t rail-to-rail like the MCP6022, but it is what you may call a single supply op-amp. This means that it can reach the negative rail, but not the positive rail. Here’s what the sine wave looks like on the LM358. Only the top portion is clipped this time. This is why the LM358 is perfect for when you have a singular positive DC supply, since you won’t need to make a virtual ground. Anyways, you may need to search for a rail-to-rail op-amp if you don’t have much voltage headroom. The DIY op-amp also has this clipping problem, although with some weird distortion at the bottom, which we will fix later.

Offsets

Offsets, in relation to op-amps, are basically undesired parasitic DC voltages that are added to the output. Let’s take our LM358 and read the datasheet so we know what to expect. Under ‘Offset Voltage’ we will find a spec called input offset voltage, which has a typical value of 300uV and a maximum of 3mV. Basically, what this means is that you will add 300uV to your input signal BEFORE amplification. So, let’s imagine that we have a current sensing differential amplifier measuring current through this 1 ohm resistor. We will have an amplification factor of 1001x by using 10 ohm and 10kohm resistors. Let’s now pass 1mA of current through it and measure the output. Ideally, for 1mA, the resistor will drop 1mV. In turn, the amplifier will amplify that drop up to 1V. Verifying with my multimeter, we can see that indeed we are getting 1mA through the resistor along with that 1mV drop. Let’s read the the output now. And we somehow see 2.2 volts on the output. Why is this?

Well, the 1mV is being amplified corretly, but that input offset voltage that I mentioned was added to our measurement and then amplified too. So, as you can see, this input offset voltage can be a big problem for large gains and precise DC op-amp measurements. Let’s try to measure the raw offset ourselves. Here is the circuit that I will be using to measure the offset. This setup would yield a clean 0 volts on the output if the op-amp were ideal. However, it isn’t, and our input offset voltage will add itself to the inputs. We can solve for the input offset voltage by dividing Vout by 1001.

So, I built this up on the testing board and started testing with the LM358. Make sure to use closely matched resistors in order to minimize error. Anyways, sure enough, we got 1.4V on the output of the LM358, or 1.4mV offset, which is within the 3mV maximum value in the datasheet. Let’s try the same thing out on the DIY board. After building the circuit, we get an output of 1.3V, which equates to 1.3mV of offset, so pretty high, like the LM358. But what causes this offset? Well, a large part is due to the mismatch of components in the op-amp. For example, the input transistors are not perfectly matched, and will never share the same temperature. This causes them to have different current gains, and thus, different effects on the differential amplifier. Furthermore, the bottom resistor is meant to act as a simple current source. However, it isn’t perfect and variations of voltage will change its current draw slightly. The top resistors may not be perfectly matched. This goes on for the rest of the components, since any mismatch between them will cause a slight voltage difference. Eventually, it reaches the output as that offset that we saw earlier.

As expected, the more expensive op-amps have lower offsets. The TL072 has an unnoticeable offset from my measurement, and the NE5532, has an offset of just 70uV. Either way, the offset issue may or may not be important for your project. Sometimes you are only focused on an AC signal, and audio, for example, is made entirely of AC. So, simply sticking a coupling capacitor will remove any DC, including the offset, while keeping the AC audio signal intact. So really, the input offset voltage only matters for precise DC measurements.

Frequency response & bandwidth

Let’s now talk about the frequency response of these op-amps. The frequency response is basically how the op-amp will react when different frequencies are applied to it. Here is an example of a frequency response graph from the LM358. The basic idea is that when you apply higher and higher frequencies, the lower the gain that the op-amp can provide. The limiting factor is usually the compensation capacitor. Some of you may be wondering why we even need such a capacitor in the first place. Well, let me show you what happens without it. Here is my DIY op-amp with the compensation capacitor removed. As you can see, I have the circuit setup in an open loop configuration, and the function generator is turned off. Already you can see the instability. Without the capacitor, we have an oscillation of 330 kHz, but as soon as I place the capacitor back, the oscillation stops. So yes, the capacitor is necessary unless you can find another way to stabilize the oscillation. Either way, we still need to talk about how this specific capacitor will affect the gain of our circuit.

This is how we will test the frequency response of our op-amp. First, I will set the probes to be AC coupled in order to remove any issues with DC offset. Second, I will be using the op-amps in an open loop configuration, as in there will be no feedback. The inverting input will be connected to ground and my function generator will be connected to the non-inverting input. As a quick test, you can already see the difference between 1kHz and 10kHz on the DIY op-amp. Anyways, as a proper test, I will be manually sweeping the frequency from 10Hz to 1MHz. Then, I will record both the input and output voltage peaks on a spreadsheet. Let’s get to the results. Here is the bode plot for the DIY op-amp. I know some of you are scratching your heads right now, so I’ll explain how this plot works.

On the left side, we have gain with the units being dB. A decibel is simply a logarithmic ratio between two powers. Here is a handy equation that you can punch into your calculator: the power gain in decibels is equal to 10 times log base 10 of the ratio between those two powers. So, if for example we have 1W going into our amplifier and get 2W out, we will get a gain of 3dB. But we recorded our data as voltages, not powers so there is a bit of a difference. The gain in decibels of a voltage is very similiar, just multiply by 20 instead of 10. Let’s do another example, if we have 1V going into our amplifier and get 2V out, we have a ratio of 2x. If we plug it into our dB equation, we get a gain of 6dB. So when dealing with decibels, just make sure to be aware of the difference between power and voltage calculations.

So if we look back at the results, we can see that we will get a flat 60dB of gain until we reach about a 5kHz input signal. 60dB equates to a voltage gain of about 1000, so it’s really not great. After 5kHz, you can see that the gain drops off until it reaches somewhere around 2MHz, where the gain is 0dB, meaning that there is no gain, it’s a ratio of 1. If you look a bit further you will see negative gain, which simply means that the output signal is smaller than the input. Keep in mind that all of this is the maxmimum gain you can get. With negative feedback, you can limit the gain to a certain threshold. Interesting data, but let’s take a look at the other op-amps to see what an actually good frequency response looks like.

For the other op-amps, I’ll be using the provided charts on the datasheets. Here’s how the DIY op-amp compares to the LM358. The LM358’s chart has a similiar trend where it is flat at first, and then drops off at high frequencies. The difference is that it has much higher gain, all the way up in the 80db region. What’s interesting is that they drop off at about the same frequency, a little above 1MHz. What about the others? Well, the TL072 has an interesting curve, where it has more of a linear drop-off. A similiar thing happens with the MCP6022, it has a brief flat portion, then it drops off. However, on both the TL072 and the MCP6022, the frequency reaches much further, upwards of 10MHz.

All of this talk about frequency response also corresponds with another datasheet value, which is the Gain-bandwidth prodcut, or GBW for short. This value is the same as when our bode plot reaches 0dB. It’s basically there to specify the maximum frequency that you can run a unity-gain amplifier. Beyond this, you will actually start losing gain, like I did with my diy op-amp. So, depending on your desired frequency, you will need to verify that your op-amp has the bandwidth to accomodate it.

Slew Rate

Next up, we have slew rate. The slew-rate of an op-amp is basically the maximum rate of change on the output that the op-amp can handle and it is limited by the internal compensation capacitor. Let me illustrate what I mean. I will be starting with a buffer which means we will have unity gain. On the input, we will have a 1kHz square wave with an amplitude of 9V. For our op-amp, I’ll use the LM358. You should expect the same square wave on the output, and that’s exactly what we get. But, we need to zoom in to see the effect of slew rate. Zooming in on the rising edge, we will find that the path up isn’t a straight line, but rather a ramp up. The slope of this ramp is our slew rate, which I measured as 0.3V/us. In other words, the fastest that the op-amp can change its output is 0.3V per every microsecond. This measurement slower than the LM358 datasheet which reads out 0.5V/us at unity gain. The ua741 claims about the same with 0.5V/us. But the slew rate on these two opamps is actually rather slow. The MCP6022 has a slew rate of 6V/us. On the upper end, the TL072 and the OPA134 should both have a slew rate of 20V/us. Here is the output from the TL072, and it may look odd at first, because of this bump at the bottom and the top. These bumps are caused by stray capacitance in my board, since it doesn’t have the greatest layout.

Ignore the bump for now and focus on the rate of change in the linear region. I measured a voltage change of 3.9 volts over 200ns. This equates to 19.5 V/us, so the TL072 datasheet is spot on with it’s specification. Anyways, just make sure that the op-amp is fast enough for what you are doing. As for the DIY op-amp, I measured a slew rate of 5V/us, so it’s decently fast.

As another demonstration, here is how slew rate would affect a sine wave. The purple line is the original signal and the yellow is the op-amp’s output. As you can see, the sine wave is moving much faster than the op-amp can handle. This causes it to devolve into a sort of triangle wave. For this to happen, I ran the sine wave at 100kHz on the LM358. By the way, the slew rate is intrinsically connected with the frequency response and bandwith data that I explained earlier, because they both depend on the compensation capacitor. It just depends on whether you want to use the time or frequency domain.

Noise

Noise is one of those op-amp properties that can be a huge problem when you are dealing with small signals. Take, for example, my most recent video about that DIY microphone. The capsule provides such a small output that op-amp noise can seriously affect the sound quality of the output. So how do we know how much noise will be contributed? Well, let’s take a look at the TL072’s datasheet for an example. Scroll down to the noise section and you will see two entries: input voltage noise and input voltage noise density. Starting with the input voltage noise, you will see that the entry is specified with a frequency between 0.1 Hz to 10 Hz. This means that the op-amp will receive random noise input voltages of 1.4 uVrms, or 9.2 uVpp. This noise will occur randomly at all of the frequencies inbetween 0.1 and 10 Hz, like shown in this corresponding graph.

But what about the other entry, the one that specifies the noise density? Well, it comes with one of the more confusing units ever created: nV per root Hz. Well, on a general level, it describes how much noise there is over a certain frequency range. But, it would be far more useful if we could get it into an RMS value like before. To do that, you just need to do some simple unit algebra. Basically, just multiply the value by the root of your frequency range. So, if we are going to operate over a frequency between 10kHz and 15kHz, then we have a range of 5kHz. To get the resulting noise, multiply the density, which is 21, by the square root of 5k to get 1,400 nV RMS or 1.4 uVrms in total over our frequency range from 10kHz to 15kHz. Keep in mind that this result is an RMS value and only includes those frequencies.

Here is a more visual way of understanding it. From 10 Hz to roughly 800Hz, the input noise drops off. This ‘drop-off’ region is commonly known as the 1/f noise region. So, as you can tell, the lower frequencies are the noisiest. But what about afterwards? Well, we get a mostly flat line. That’s why there really is only one datapoint at 10kHz, because the density is the same over the rest of the line.

Let’s try to measure this. First, we need to measure the noise that will be contributed by our measuring device, which is this oscilloscope. To do this, simply terminate the ends together using a 50 ohm resistor. You can either use a probe, or a coax. Then, we will need to pull up our FFT function to read the presence of noise at each frequency. Here’s what the oscilloscope is reading. We have this rather large spike at the beginning, followed by a somewhat flat line afterwards. The flat line averages out to be -88dbV. To understand just how small this is, remember back to when I talked about decibels in the frequency response section. These decibels work the same, except they are referenced to a particular value. 0dBV is equal to 1 volt. So, we can calculate that our -88dBV is about 70 microvolts. This flat area of noise is known as white noise. Now, if I zoom in on the large drop at the beginning, we can see that the noise here is much higher. I read -78dBV, so ten times more noise at these very low frequencies. This area where there is a steep drop off is the 1/f noise region. Either way, I hope that you can see that the oscilloscope is much too noisy to measure these op-amps, at least in unity gain. Remember that the noise is called input noise, so it will be multiplied with the gain.

So, to test the TL072, I configured it in an inverting configuration like shown. The gain is 1001 so hopefully the noise will show up over the oscilloscope’s noise. It’s also worth mentioning that the resistors will introduce their own noise in the form of Johnson noise. That is why I used low resistor values. Also make sure to AC couple your oscilloscope. Anyways, here is what the FFT shows us. The result looks similar to the first, but the white noise level is much higher: -67dBV. There is also this odd bump at about 35kHz. This isn’t specific to the TL072, since it appears even larger on the NE5532. Either way, this method of measurement is much too imprecise for a good measurement, but it does prove that the op-amp does inject noise in the same pattern that it claims to in the datasheet.

CMRR/PSRR

CMRR is a term that many electronics newcomers aren’t familiar with. Well, it stands for common-mode rejection ratio. Likewise, PSRR stands for power supply rejection ratio. But let’s start with CMRR. What exactly does common-mode mean? Well, remember back to the beginning of the video where I showed you the anatomy of the DIY op-amp. The first input stage is a differential pair. The purpose of this pair is to amplify the difference between the two inputs. When the inputs have the same voltage, we call this a common-mode signal, and since there is no difference to amplify, ideally, nothing should be on the output of our op-amp. Let me show you an example. Here I’ve setup an differential amplifier with a gain of 10x. On each input, I have placed an nearly identical sine wave. The only difference is that one is the exact opposite of the other. Now, since they are exactly opposite, the amplifier will amplify their difference and end up with the amplified sinewave on the output. But, if I made them exactly the same, such that both inputs receive the same signal, then nothing shows up on the output. So, if we go back to the differential signal, imagine what would happen if some common-mode noise came and interfered with the circuit, what would happen?

Well to find out, let’s make some changes to our test circuit. First, I will put our signal through this transformer. This transformer is wound to a 1:1 ratio, so AC placed on the input will be mirrored on the output. The special thing that is useful about it though, is that the secondary side has a center tap. This means that if we measure from the center, we will get two opposite sine waves on each end. Now, let’s inject our noise. I put my function generator running a 2kHz sine wave on the center tap. If you look closely on the oscilloscope, you will see that the shape of the main sine waves are opposite one another, but the noise on each is exactly aligned. Now, if we run these two signals through the differential amplifier, we should only see the original main sine wave on the output. The noise disappears because it is ‘common-mode’, in that it is exactly the same on both inputs, hence common-mode rejection ratio.

However, the op-amp has more trouble rejecting common-mode signals at higher frequencies. Here is the LM358 for example. At the start, it has about 90dB of CMRR. Which means that the common-mode signal is 90dB smaller than the desired signal. However, later in the graph, we see that the CMRR starts to fall off at these higher frequencies. If we go back to the testing circuit and increase the gain to 1000x, then we can see the common-mode signal start to come through. This is what it looks like at 1MHz, 1000x amplification, and a 7V amplitude input. So it takes a lot just to get the common-mode signal through.

For the DIY op-amp, I ran through and made this chart of our CMRR. To calculate the CMRR, calculate the gain of the differential signal and the gain of the common signal. Divide the gains to get a ratio. Afterwards, take the log and multiply by 20 to get our ratio in dB. At the starting frequencies, I got a CMRR of 28dB. So, it’s already really low. Low enough, in fact, that there isn’t much of a drop-off until 100kHz.

As for PSRR, it’s a very similar concept to CMRR. The only difference is the amount of power supply noise that will reach the output. This could be an issue depending on your circuit, but oftentimes a simple decoupling capacitor solves a lot of PSRR problems by filtering out the higher frequencies.

Upgrading the DIY op-amp

Now, so far you’ve seen the DIY op-amp falling short in basically all of these comparisions, so why don’t we give it a bit of an upgrade. First, let’s fix our current source. Currently, we have R3 acting as our current source, but it doesn’t do a great job. So instead, let’s use a current mirror. Basically, when we pass current through the first transistor, the second will match that and draw that same amount of current through the second path. We can set the current by using a resistor on the first transistor, and it will stay steady since the voltage will be stable. The second will match the first because they both share the same base-emitter voltage, so ideally, they should both share the same input current and thus the same collector emitter current. This new current source will improve performance because it will stay constant unlike the resistor current. This should improve CMRR and gain.

We can use a similar trick on R1 and R2. By replacing them both with a PNP current mirror then we can ensure that both paths have equal current flowing and this will balance the op-amp. Let’s shift our focus to the output. Currently, I am using an emitter follower for the output, but switching to a push-pull amplifier, also known as a class AB amplifier, should improve performance. It will improve efficiency since only one transistor will be active at a time. To do that we will replace R7 with a 2n3906. Between the base of each output transistor we will place two diodes in order to prevent crossover distortion. And finally, we will replace R6 with a proper current source in the same way that we did earlier, by using a current mirror.

With these improvements, I remeasured a few of the parameters. Our op-amp has such an improved open-loop gain that I can’t honestly measure it with my function generator at lower frequencies, I would need an even lower input voltage. But, I was able to measure it starting at 10kHz, starting with 70dB. Either way, it’s easy to tell that the open-loop gain has massively improved since it barely broke 60dB before, and that was at the lower frequencies. The slew rate also got a big upgrade to 10.4V/us. This is a slew rate big enough to be very competitive with the commercial op-amps. The CMRR also greatly improved up to 45dB, thanks to that new current source at the bottom. At this point, the best way to improve performance even further would be to properly match each transistor so that they have a close current gain. It would also be best to thermally couple the transistors together to match thermal performance. And, obviously, produce the thing on a PCB. Either way these improvements are still incredible. With some more work I imagine that this discrete amplifier could have similar performance to those inside of ICs.

Selecting an op-amp

So, now that you know what all of these datasheet parameters mean, it’s time to narrow down which op-amp would be useful for you. Let’s first begin by reviewing what all of these parameters would be on an ideal op-amp. An ideal op-amp would be rail-to-rail, have no offset, have an infinite gain at all frequencies, an infinite slew rate, 0 noise, and have an infinite CMRR and PSRR, and also it would be free. Now, since none of these op-amps are ideal, you have to pick which one would be best for your project. As my regular viewers know, I’ve used the LM358 in several projects, simply because it is dirt cheap. For most things, it’s good enough, not to mention just how helpful the single-supply operation along with the huge voltage range is.

However, the LM358 isn’t always the best choice. Something like the OPA134 would be great if you were designing a very high performance audio-amplifier. It has extremely low input noise and a very high slew rate. The only drawback would be the high price point. The NE5532 is similar to the OPA134 in that it is meant for audio application, but it’s a bit cheaper and has worse performance. For most other things, the MCP6022 would be a good choice. It’s a general purpose op-amp like the LM358, and, for the most part, has better performance than the LM358. However, it falls behind both in price and also in operating voltage range. It can only go up to 5.5V. And, surprisingly, the upgraded op-amp can be a viable option if you’d like the challenge.

So really, determine what you need your op-amp to do and pick one based on that. Either way, it definetly doesn’t hurt to have a surplus of LM358’s on hand, but hey that’s just my opinion. Anyways, thanks for watching this far into the video. If you have enjoyed, please consider subscribing so that you can see my future videos. Also, visit my buymeacoffee page. With your support, I can keep making these videos. Thanks for watching, have a good one!

 Share!