*Cross-posted from my blog.*

The purpose of this post is to lay out some of the stuff I wish someone had explained to me when I was first learning about electronics. This is a pretty entry-level introduction, intended by me to ‘fill in the gaps’ with regard to basic operating principles. Opamps are not all that complicated, but for many people they appear as a black box. With so many schematics available online, it can be very tempting to simply ‘cut-and-paste’ subcircuits into your own designs without understanding them. This is okay to a point, and useful for learning, but it may come back to bite you later if your design doesn’t work the way you expect it to.

While this is entry level in terms of concept, there is some significant algebra going on here. I’ve tried to explain each step as I go along, but it does assume you have a basic knowledge of algebra. Unfortunately, there’s really no way around it.

First, let’s look at the schematic symbol for an op-amp and identify the pins and their functions.

**V+** is the positive supply and **V-** is the negative supply. Often these will be omitted in diagrams, especially if the opamp is part of a dual or quad package. For most schematics, it is implied that the opamp is connected to such supply rails.

**Vin+** is the non-inverting input. Because of the plus sign, you may be tempted to call this the positive input, but that would be something of a misnomer because the signal voltage applied to it can positive or negative with respect to ground.

**Vin-** is the inverting input. Again, the signal voltage applied here can be positive or negative with respect to ground.

**Vout** is the voltage output.

There are two concepts which are typically used to describe how opamps function. The first is: the voltage output of the opamp is the voltage difference between the two inputs multiplied by the gain of the device. The gain of the device is often denoted as *A*, and refers to the *open-loop gain* of the amp. Further, the voltage difference refers to the difference between the voltage at the non-inverting input (Vin+) and the voltage at the inverting input (Vin-). In other words:

(1)

This voltage difference can be considered the input to the opamp. The order of terms in the above subtraction is where the inputs get their names. To explain, let’s assume that the voltage at Vin+ is X, and the voltage at Vin- is 0 (ground). Thus, Vin would be X – 0, which is just X. However, if Vin+ = 0 and Vin- = X, the input voltage would be -X (negative X), thus its sign would be *inverted*, hence the term *inverting input*. This sign inversion would hold true regardless of whether X itself was a positive or negative value (with respect to ground).

So now that we’ve dealt with the Vin terms, let’s talk about *A*. *A*, as mentioned above, is the open-loop gain of the opamp* — *it is typically very large, on the order or 10,000 or more*.* This huge gain factor makes an open-loop opamp pretty useless for most applications*.* There are very few occasions where you would need to multiply a signal 10,000+ times, and even then it would be unwise to do so using an open-loop opamp. The reason is that even though *A* can be regarded as quite large, it’s very difficult to control exactly *how* large it will be. This is due to a number of factors, but mostly it’s due to manufacturing variances. The gain of the opamp is directly related to the gains of the individual transistors which make it up. Transistor gain can be difficult to control, particularly in large numbers. While it is possible to create very precise transistors, and thus pretty precise opamps, it’s not at all cheap. Further, it’s completely unnecessary, as we will soon see.

It’s much better to approach opamp design from a different angle. Rather than create a device which has a large but precise gain factor, it’s better to create one with a theoretically infinite gain and provide some other constraint which can be used to control it. This brings us to the second big concept for opamp functionality:

*“An opamp tries to keep the voltage across its two inputs at zero.”*

*“An opamp tries to keep the voltage across its two inputs at zero.”*

In fact this is the fundamental operating principle of all opamps, but when I was first learning about active devices, I always found this statement to be very confusing. The problem is that very few sources go on to explain *why* this is so. It seems a little counter-intuitive. Amplifiers aren’t supposed to make things smaller (or zero), they’re supposed to make them bigger, so why is the opamp trying to mitigate it’s own inputs, and how the heck does it do that?

I’ll answer the second question first. The *how* is with a feedback network. The original statement would be more complete if it read:

*“An opamp tries to keep the voltage across its two inputs zero ***by using a feedback network to control one of the inputs with the output.**“

**by using a feedback network to control one of the inputs with the output.**“

The construction of the feedback network will determine the extent to which the opamp has to swing the output one direction or another, so that one of the inputs is equal to the other input. The easiest way to explain this is by looking at a simple circuit — the non-inverting amplifier:

In the non-inverting amplifier, the input voltage is applied to the non-inverting (+) input of the amp. The output of the amp is connected, via a feedback resistor, to the inverting (-) input. There are two resistors here which make up the feedback network. The first is the aforementioned feedback resistor (R_feedback or R_f), and the second is a resistor from the inverting input to ground, called R_ground or simply R_g. Let’s ignore the non-inverting input for now and just look at the feedback network — it forms what is known as a voltage divider. Below is an example of a simple voltage divider circuit.

A voltage divider is so named because it provides a fraction of the input voltage as its output. The simplest voltage divider is made with two resistors, R1 and R2. In the figure above, the output voltage (Vout) is equal to the input voltage (Vin) times the ratio of the lower resistance, R2, to the total resistance, R1+R2. The lower point of R2 is tied to ground.

(2)

The nice thing about the voltage divider is that it has lots of applications, one of which is in our non-inverting amplifier feedback network. In that case, the input to the voltage divider would be the output of the opamp, and the inverting input of the opamp is the output of the voltage divider. Seems very confusing, I know. Perhaps a diagram will help.

The formula for the voltage divider still applies, and we can substitute the terms from the non-inverting amplifier from above:

(3)

To make things a little clearer, let’s replace the resistor fraction with something less cluttered — the greek letter Beta:

(4)

–thus–

(5)

Ok, now we need to relate this equation to the whole circuit, so that we can come up with the *transfer function* for the non-inverting amplifier. A transfer function is an equation that describes the output in terms of the input. It’s usually written as follows:

(6)

In other words, it’s **a function that describes the ratio of the output to the input**. This is an easy form to understand and use, because to find the value of the output, all we need to do is multiply the transfer function by the input value. Remember that the input to the whole circuit is at the non-inverting input, so we are going to need to include that in our function as well.

**NOTE:** From this point on, it’s mostly just a lot of algebra — moving terms around between both sides of the equation until we get a nice Vout/Vin transfer function. If you’re thinking of studying electrical engineering, you should know that this stuff is critical. Being able to do algebra like this quickly is something you should make an effort to get really good at, because you *will* use it **all the time**. There aren’t really any shortcuts here — you just have to do it.

One of the problems when you’re studying this stuff is that textbook authors tend to ‘skip steps’ when reducing or reconfiguring equations, because they assume some intermediate steps are self-evident. Sometimes they are, particularly if you have a lot of experience working equations, but for n00bs (or sleepy college students), they are not. As such, I’m going to try to show each and every step, and explain what I’m doing, so you can understand it.

Getting back to the problem at hand, we need to create a transfer function for our opamp+feedback network. In order to do that, we will take equation (5) and substitute it into equation (1), replacing Vin- with the voltage divider equation. Doing that, we get:

(7)

–or–

(8)

The next step is to get **both Vo terms over on the same side of the equation**, so let’s do it:

(9)

Now we **extract the Vo term as a common coefficient of both terms** on the left.

(10)

Our original mission, of course, was to find the transfer function of Vo/Vin. Vin, in this case, is Vin+, so we want to find Vo/Vin+, so we **divide both sides by Vo**.

(11)

Now we’ll divide both sides by *A*:

(12)

which becomes:

(13)

Here we can use a little trick to simplify things. Recall that *A* is very large — theoretically infinite. As such, 1/*A *is very small, theoretically zero. We can use this to our advantage, because it means we can get rid of the 1/*A* term by equating it to zero. Further, looking at the second term on the left, the *A* in the numerator and the denominator cancel out, so we can get rid of them too.

(14)

Oh snap! Look how much simpler that is! Now we can substitute back the resistor fraction for Beta:

(15)

and we invert both sides to get the Vout/Vin form we’re aiming for:

(16)

Rg/Rg = 1, so:

(17)

To figure out Vo in terms of Vin, we simply multiply:

(18)

And that’s the equation of a non-inverting amplifier. Now that we know where that formula comes from and how it’s derived, it’s a little easier to understand the concept of a feedback network. In order to create a voltage at Vin- which is equal to the voltage at Vin+, the opamp has to produce an output voltage which, when attenuated by the Rf/Rg divider, is equal to Vin+. So, if the voltage divider is set up to output 50% of its input, the opamp has to produce a voltage twice as large as the voltage at Vin+ in order to mitigate it. As such, it is indeed acting as an amplifier with a gain of 2. Likewise, other voltage divider values would produce different gains, as expressed in equation 18.

So now that you know how it works, you should build a couple circuits to try it out. Happy amplifying!

**About the equations:** the equations here are rendered as alpha-channel PNGs with the WP QuickLaTeX plugin. This is a great plugin which renders LaTeX beautifully and even provides equation numbers. If you want something that will allow you to write nice-looking equations on a blog, you should check it out.

Check out all the Circuit Playground Episodes! Our new kid’s show and subscribe!

Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Learn resistor values with Mho’s Resistance or get the best electronics calculator for engineers “Circuit Playground” – Adafruit’s Apps!

Maker Business — โIf Work Is Digital, Why Do We Still Go to the Office?โ

Wearables — Stiff upper lip

Electronics — Signature required?

Biohacking — BBC Biohacking: Technology and Health

## 6 Comments

Sorry, the comment form is closed at this time.

One of the most understandable articles that includes some form of formula I’ve read in a very long time.

How about something that brings understanding of integrals to the masses.

Thanks, Michael!

I may do something like that eventually! ๐

THANK YOU for this! The concept of the op-amp is one of those things that confused me every time I read about it although I believe I had the knowledge to grasp it… just needed it explained step by step like this. Very cool. Basically a component that lets you play choose-your-own-amplifier?

@Eric: pretty much. Another way of saying it (which is common in technical literature) is that the opamp has ‘programmable gain’. That is, you can program the gain by choosing certain resistor values. There are certain limitations in the real world, obviously, but an ideal opamp works exactly as a “choose you own characteristics” device. ๐

After all these years I finally get it! Thanks John.