Leslie Kaelbling: 6.01 Lecture 06

Search transcript...

PROFESSOR KAELBLING: OK. It's time for a little lecture about circuits. So let's see. So last time, we talked about three kinds of simple circuit elements-- resistors, voltage sources, and current sources. And we saw that there is really a very simple set of equations that you can use to describe a circuit.

You use equations to describe the effect of each component on the voltage across it and the current through it. And that we could use KCL equations to describe what's happening at the nodes in particular, that the current summed to zero. And in fact, what we're going to do in software lab today is write software that will solve those circuits, just exactly those kinds of circuits that we saw.

But we also ran into some issues and interesting sort of behavior, which we saw in design lab last week, of loading. So everybody built some resistor dividers. And then what we did was explored what happened when you made something that looked like a divider, and then attached another resistor over there, or in some other places, too. And what we saw was that attaching extra things to our circuit actually changes the way the circuit behaves.

And that's-- sometimes it's something that you can exploit. But it's also something that can make things hard to design. Because you might have worked really hard to create a particular voltage over here that you really like. You want to do something with it. And then when you try to connect it to something else, it doesn't necessarily work out.

So what we're going to do today is look at something called an Op-Amp, which is going to let us actually build circuits in a more modular way. So here's a circuit we can think about. We've got a voltage source, a couple of resistors, and an open switch right now with a light bulb. So if we close the switch, the current will go through the light bulb.

So here's a question. You should think about it. You should be able to understand this, given what you did in lab last week. So I know it's first thing in the morning, but no time like the present. So think about this. Talk to your neighbor. Figure out an answer.

The question is, if I close the switch, how does that affect this current? So the current that's sort of drawn from the voltage source. And how does it affect the voltage between these two nodes? And there's a bunch of choices.

OK. So what are your votes? Put up the number of fingers for the answer you vote for. Quite a few twos, some fours. Two and four. So voltage-- so everybody thinks the current increases, and maybe the voltage increases or decreases. All right. So let's think about how this works.

First of all, when the circuit is open, when the switch over here is open, then let's see. Let's just understand what the voltage is here. So when this switch is open, it's just a plain old resistor divider. We've got 12 volts going through the divider. So we have 12 here, and zero here.

And so we're going to lose 1/3 of the voltage between here and here, and 2/3 between here and here. So this is 8 volts. So the voltage at this node right here is going to be 8 volts. Is that cool with everybody? Right. And we can figure out that the current is four amps. Because we know that this is a three ohm resistor, and v equals ir. OK.

So that's a real easy circuit to analyze when the switch is open. When we close the switch, what happens? Well, it's all kind of done out here in algebra. But we can just kind of do it a little bit qualitatively instead of quantitatively, also. So let's just think about this. So now when we close the switch, remember that you can think of the light bulb as a resistor.

So if you think of this whole part of the network, does it have more or less resistance than two ohms? Less. Right? Resistors in parallel, no matter what they are-- this arc could be anything you want to, no matter what it is-- this thing, seen as one component, has less resistance than two ohms. OK. So if this has less resistance than two ohms, does this whole thing have more or less resistance than three ohms? Less.

OK. So we've got less resistance here. Same voltage, less resistance. How much current do we have, more or less? More. V equals ir. r went down, i better go up. OK. So the current is bigger than it was before. Everybody cool with that? OK, good.

The current is higher. But so now, the question is, what's the voltage difference across here? And what we're going to see, you can see that it's going to be less than it was before. Because the resistance is lower. So this is a pain. It means that having carefully created 8 volts, maybe because we wanted our light to be a certain amount bright, we created 8 volts.

But then when we attach our light bulb here, that voltage changes. So we would actually have to take the resistance of the light bulb into account when we're trying to decide what voltage we needed to create here. It's complicated. OK. So we're going to add a new contraption to our inventory of things that we can put in a circuit. It looks like this. And it's called an Op-Amp.

And when we stick it in the circuit in this particular way, we sometimes call it a buffer. Buffer's a good name, because what it does is, it effectively, it does two really important things. One is, it makes it so that no currents can flow through from here to here. So there's no current flowing.

However, ultimately, what it's going to do is arrange for whatever the voltage is here on the input terminal to be the voltage on the output terminal. So it can copy the voltage over to the other side, but without any current flowing. And if no current flows, then it's not going to mess up what's going on over here on the other side of the circuit. So that's the cool thing about Op-Amps.

So what we're going to do today is understand, in some detail, how to think about Op-Amps, and how to design more interesting and complicated circuits with Op-Amps in them. OK. So Op-Amps inside are some crazy mess, very complicated. This is the diagram of the insides of one particular kind of Op-Amp.

These things are transistors. Transistors are already sort of complicated. You could go and then try to study what a transistor is made out of. And so designing an Op-Amp is a very complicated and hard thing. You can take a class that would teach you how to do that. But we're not going to do that. So we're going to treat it as a certain kind of a black box.

And we're going to study two different abstract models of what this thing does. So to understand the first abstract model, we have to understand the idea of dependent sources. So a dependent source-- you know what, there's an example here, and I'm not sure it's helpful. I'm going to actually skip it, and I'm going to cut straight to here. We can go back to that if we have time and inclination.

OK. So this is a particular kind of a dependent source. It's called a voltage-controlled voltage source. OK, so everybody is familiar with a voltage source already, right? A voltage source, we've seen them before. We usually draw the picture like this. And there's some voltage, Vo, coming out of this voltage source.

And before, when we've talked about voltage sources, we've thought about, oh, I'm going to go to Radio Shack and buy a particular voltage source with a particular voltage. Right? Or, we've played with voltage sources now in the lab. And you can actually, there, you can turn the dial.

So those voltage sources that we have in the lab, you could consider those as not voltage-controlled voltage sources, but human-controlled voltage sources, or maybe knob-controlled voltage sources, right? You turn the knob, and you get a different voltage out on your power supply. So everybody's kind of used to that idea.

So the innovation here is that we're going to put this thing sort of like in a bigger box, and have two input terminals here. And we are going to let the voltage between these two input terminals govern the output voltage on our voltage-controlled voltage source. So it's like instead of you turning the knob, we're going to let some pair of voltages turn the knob on our voltage source.

But current is not going to flow through this thing. So it's like there's kind of a wall between this stuff and this stuff. So the voltage difference here on the input terminals is going to control the output voltage. And in particular, the way it controls it is that Vo is going to be equal to K times V+ minus V-. So K is a constant. And it's big.

It may be bigger than 10 to the fifth. So it's a big constant. So this is an abstract model of that diagram I showed you with all those transistors in it. Does this idea makes sense in the abstract? For right now, you might be wondering why it's a good idea to have such a thing. Because it seems a little strange that we can take the input voltage and multiply it by 10,000 or something, and get an output voltage, or say 100,000.

But you get the idea? Output voltage controlled by the difference in the input voltages. So that's a voltage-controlled voltage source. And we can think of an Op-Amp, if we get tired of drawing that picture, it's a little complicated, we can think of an Op-Amp which has this cute little triangular picture as being a voltage-controlled voltage source.

So these two inputs here are the two inputs that govern the output voltage. And the output voltage-- I'm drawing a ground here as the bottom pin there. There's some sort of low reference value here. And this Vo is this difference. So Vo is K times V+ minus V-.

OK. Important things. On any wire, you can think of there being a current. But these currents are equal to zero. No current flows into the box, no current flows between these guys, no current goes between here and over there. Current, as in any voltage source, current can flow through the voltage source.

We have current variables for voltage sources. That's fine. The voltage source, in fact, his job is to, you can think of it as manufacture or whatever current is necessary to keep the voltage difference as it needs to be. So there can be current here. But there's no current that flows through.

And so what that means is what you connect to the input terminals isn't going to-- or what you connect to the output terminal wouldn't change the voltage at the input terminals. Because there's no current flowing through. OK. So all by itself, this thing is not-- I mean, just looking at it, it's hard to see what it would be good for. And when it gets really interesting is when you connect it up like this.

So this is an Op-Amp in what we would describe as a negative feedback configuration. So what we've done is we've just soldered a little wire, taken a wire from the output, and run it back around into the negative terminal. So we just took an Op-Amp, added an extra wire. The reason Op-Amps don't come wired like this is because we don't do this all the time.

But this is one standard, useful thing to do with an Op-Amp, is to connect the output back into the negative input. So let's try to think about now, what happens when we do connect the output into the input. So let's see what we can say about what's going on.

So we know that Vo is K, whatever the magic-- the constant, if you go buy an Op-Amp at Radio Shack, it'll come with a data sheet. And the data sheet would tell you the K for that Op-Amp. So all Op-Amps have a K. It's big. 200,000, something like that. So K, V+ minus V-. All right? So then we can substitute in V+, that's our Vi.

Because we're going to be interested now in understanding the relationship between the output voltage. We'll call this the output voltage and the input voltage. So Vi minus Vo. Because now the voltage on the negative terminal is Vo. All right. So we have an equation here, Vo is K times Vi minus Vo.

You can think of that as, that's a stable point for this system. If Vo had whatever that value is, Vo, that satisfies that equation, then the thing is in equilibrium. It's in balance. It's not going to want to change. And it's all happy. So the question is, well, what value of Vo makes this guy happy?

So we do a little bit of algebra. And we find that if Vo is K over K plus 1 times Vi, than the thing is stable. So if that were the value on Vo-- I just woke up in the morning, and that was the Vo voltage-- it would be great. It would be all happy. It would be stable. Does that make sense?

And we'll see, we'll talk about K. But it's pretty clear, as K gets big, Vi is a lot like-- I mean, Vo is a lot like Vi. They're almost equal. So that's an Op-Amp wired up in this negative feedback configuration. So what we see is that, basically, Vo is a lot like Vi when it's in its stable point.

Now, I said we should wire the thing up like this, with the feedback going to the negative terminal. I should warn you that different people draw Op-Amps with the plus and the minus on the top and the bottom, which actually makes me slightly crazy. But that seems to be standard practice. And so you have to watch out for the plus and the minus signs. When you look at a circuit with Op-Amps in it, don't trust, top versus bottom doesn't mean anything.

So here we go. So this guy, this picture, looks the same as that picture, but it's not. Because the plus and the minus terminals are swapped. So here now we have feedback to the positive terminal. So what happens when you do feedback to the positive terminal?

Well, let's see. We just did the feedback to the negative terminal case. That was the example that we just solved. And we found that the relationship between Vo and Vi was about 1. Now, if we do it with the feedback to the positive terminal, we also find out that there is a stable position. It's written here minus K over 1 minus K. I prefer to think of it as K over K minus 1. K over K minus 1.

But what that seems to say is that when we have this positive feedback arrangement, we also have a stable point, which is, the output is K over K minus 1 times the input. So if someday, if somehow, you have that Op-Amp in the positive feedback arrangement, and it just happened to have that voltage, K over K minus 1 sitting on it, we'd be all good. And it would stay there. And the output would be like the input.

So you might think it doesn't matter. That you could wire it up either way, and you would get something that works out. In fact, that's not going to be true. So let me see if I can-- there's a little picture here, but I'm going to just do a little bit of algebra on the board to help convince you that the negative feedback arrangement is a good one, and the positive feedback arrangement is a bad one.

So if we have the negative feedback, so the negative feedback case, we said that the stable arrangement was that Vo was K over 1 plus K of Vi. But what if the circuit wakes up in the morning, what if it's perturbed just a little bit? The output voltage is not quite the thing we wanted it to be. So imagine that Vo was equal to K over K plus 1 Vi plus some epsilon. Right?

So it's epsilon higher than that nice, stable point. So what if Vo is that? And now, let's think about what happens if we feed that back through the equation that governs the Op-Amp. So we know that Vo is K times V+ minus V-. And so we can feed this in, put in the value.

So this would be Vi minus K over K plus 1 Vi minus epsilon. You see what I did? I just put in Vi because that's the V+. And I said, well, what if Vo was this value that was a little bit too high? So it's almost as if we put that in for V-, what would the output be? So we're trying to think about, what's the dynamics of this process?

So if we put that value in, we get this expression. And you do a little bit of algebraic messing about, and you get K over K plus 1 Vi minus K epsilon. OK. So this seems good in the sense that our value is a little bit too high. Our value is epsilon, too high. And now on the next step, and of course this isn't really discrete time. It's really continuous time, and you want to be using differential equations to think about this.

But just kind of intuitively, somehow next, the value is going to go down. So that's what this picture is supposed to be about. In the negative feedback case, if the value is higher than it's supposed to be, it's going to go down. And it's going to go down, and in fact, it's going to converge to the value that you want.

And similarly, you could do the algebra to figure out in the negative feedback case that if it was minus epsilon, if the original input was a little bit too low, the next time it would be a little higher. So arranged in the negative feedback set up, if it's too high, it's going to go down. And if it's too low, it's going to go up. So that's all good. We like that.

Now, if we do it with the positive feedback, and again, we'll assume that it's a little bit too low-- excuse me, a little bit too high. And now, in positive feedback, we actually want a little bit of a different value. So what if Vo is K over K minus 1 Vi plus epsilon. So it's a little bit too high.

Then if we do that same analysis, we'll get on the next round that Vo is going to be, now it's V+ minus V-. And this is the V+ minus Vi. And this is going to equal K over K minus 1 Vi plus K epsilon. OK. So that is not good. Just qualitatively, we started with an output that was a little higher than we wanted for the input that we had.

And what we're going to get is something even higher. And then we get something even higher and even higher, and it's going to explode. And explode is not totally a joke. In lab, especially before we put these current limiting things inside the robots, we used to explode Op-Amps. But they would get hot, and then emit smoke.

So if you wire an Op-Amp up with the feedback to the positive terminal, it will blow up. Not dramatically, but yeah. OK. So the difference between these configurations is that one make smoke, and the other one doesn't. So we like this arrangement. The negative feedback, if it's too high, it goes down. If it's too low, it goes up. No smoke. No smoke.

All right. So that model of Op-Amps, the voltage-controlled voltage source thing, is nice. And we've got the K over K plus 1, and we can think about how big the K is. But the fact is that for most purposes, the K is big enough so that you can just treat this thing, when it's wired in a feedback arrangement like this, as basically having the property that V+ is equal to V-.

If you're going to remember, there are two things about Op-Amps from this lecture. In the ideal model, when arranged in feedback, V+ is equal to V-. Remember that. And current doesn't flow between this node here, whatever's attached here, and this node over here, whatever's attached over here. Those are the two important features. V+ equals V-, current doesn't flow.

OK. So now, you can see that if we go back to this circuit, we carefully arrange to get 8 volts here by making a divider. Because we really wanted 8 volts across our light bulb so it would be the right brilliance. And now, if we stick an Op-Amp, wired this way, here, no current will flow from this wire to this wire. But this 8 volts, which is on the V+, will get replicated at the V-. And our light bulb will have 8 volts across it. Yay.

Does that roughly make sense to everybody? This is an important thing about Op-Amps. Yep?

STUDENT: But how does the light bulb work if there's no current?

PROFESSOR KAELBLING: Yay! How does the light bulb work if there's no current? Let me cheat ahead to here, and I'll come back. That's a wonderful question. How, indeed, does the light bulb work if there's no current? The fact is that when we buy one of these chips, in fact, it has a couple of extra connections called V-- oh, you're not going to be able to see that. I'll just rely on the slides.

Vcc, and Vee. Why they're called that, you don't have to care. Collector and emitter, it's transistor talk. But anyway, basically, there's a big voltage and a small voltage. And you have to connect them up. It's like plugging your power supply into the wall.

So this voltage-controlled voltage source indeed has to get voltage for-- to be a voltage source, it has to have a voltage supply itself. And it's that voltage supply which will produce the current that it needs. So that's exactly a good question.

So good. So this guy is, in fact, connected up to whatever our external voltage source is that we have available. It could be connected up to this 12 volt source. That's fine. You could say, all right, I'm going to run this 12 volts over here, and this ground over here. And then this guy can suck out of that voltage source if he needs to. Other questions? Yep.

STUDENT: So in this case, would the current to the light bulb only depend on 8 volts and the resistance of the light bulb?

PROFESSOR KAELBLING: That's right. In this case, you can think of this as being a voltage source that goes between here and here. And it's 8 volts. So that's the cool thing. Just think of the Op-Amp as a brand new voltage source. It's just that its voltage happens to be controlled by the input voltage. Yep.

STUDENT: Could this be used to increase the voltage from the voltage that's powering the Op-Amp?

PROFESSOR KAELBLING: Excellent. I planted him in the audience. Yes. In fact, the reason it's called an Op-Amp is because it can be used as an amplifier. And we'll look at that in just a little bit. Definitely. So we can use Op-Amps to now change voltages, and even add and subtract them. Other questions?

STUDENT: What happens to the current?

PROFESSOR KAELBLING: What happens to this current? Well, it's like this is a dead connection from the current perspective. So current flows through here. So there's a KCL here. You can think of this-- there's a KCL equation right here.

And if you want to, you can think of there as being three currents-- the one through this resistor, the one through this resistor, and the one that goes into the Op-Amp. It just happens that this one is defined to be zero. So the current from here all goes down here. So current flows through this wire, flows through this node. But just none of it leaks into here.

STUDENT: [? Is that ?] going to equal to the current through the light bulb?

PROFESSOR KAELBLING: The current through the light bulb is a whole separate story. It's really, this is one circuit over here. It's got its own current. And then, this is its own circuit, too. If I drew, probably, maybe to make this picture clearer in the future, I could draw the ground. The Op-Amp has a ground. And you can think of it as connected down to here.

So this is a voltage source. And we've got a circuit that goes like that. And they're at arm's length from one another. Yep?

STUDENT: In completing a current that goes to the two ohms of the resistor, won't we need to know the resistance on the other side to know how the current is going to divide [INAUDIBLE]?

PROFESSOR KAELBLING: No, no current dividing. The current doesn't divide. Let me show you the picture of the nodes in this diagram. That's probably useful. Let me remember the diagram. Yeah, OK, good.

So this is a node. This is a node. These guys are all at the same voltage level. These guys are all at zero. Wait, I'm messing up. Oh, I forgot the light bulb. What am I doing? Of course. Light bulb. Good. So these are all at zero. Think of that as just being a ground.

And there's a current that runs through here, and it comes down here. And there's a current that goes roughly, you can think of it as going in here, that runs through this light bulb, and gets drained out there. But they're not going to affect each other. Because this current doesn't have any effect on this current.

This current is only affected by the voltage difference here and the resistance. So they're really, really held apart. OK, let's do some more examples. Maybe that will help with intuition. I'm happy to answer more questions.

OK. So we saw this example before. We're tired of it. Good, we put an Op-Amp in. Yay. Now what happens? We close the switch. If we close the switch, then all the light bulbs burn equally brightly. If we close the switch, then this is, you can think of it as a resistor divider. So the voltage here is half of the voltage of the battery.

So that's V over 2. And that V over 2 gets replicated over here. And that voltage is the voltage difference to the light bulb. OK? So, yay. It solves our light bulb problem. All three bulbs are equally bright now.

OK. So an important thing to remember, though, is that in fact, an Op-Amp is connected up to power and ground somewhere. Could be the same ground as we have. And it could be the same top level voltage supply. But whatever formulas we tell you about how Op-Amps work, it's how they work when they're in the kind of middle of their range.

An Op-Amp can never produce a voltage that's bigger than the big voltage or smaller than the small voltage. So we'll see some formulas that govern how the output of an Op-Amp may depend on the input. But those formulas are always, always, always subject to the constraint that they can't make a voltage bigger than Vcc, and they can't make a voltage smaller than Vee.

So that's just the facts. We don't just get voltage for free. So that's something to keep in mind. So I said that, somebody asked about amplifiers, and here we got amplifiers. So here's an arrangement. Now, notice that we're going to see lots of arrangements of the Op-Amp. And they're going to be fancier than the one that we've seen before. They're going to involve some resistors.

But there's always going to be some kind of feedback connection, possibly through a resistor. There's always going to be some kind of feedback connection to the negative terminal. So this arrangement is what's called a non-inverting amplifier, which implies that in a minute, we'll see an inverting one. You could think of it as just an amplifier.

And so let's see, what do we have? We have an input voltage. We have an output voltage. And we have another voltage down here, which we'll call Vr, for some kind of a reference voltage. And in the labs that we do, we'll see that it's really important to keep in mind what the reference voltage is.

So how do we want to think about this? The way I end up explaining these things to people, I'll just do it on the board. So the thing to concentrate on is this path here in the circuit. So see this path here in the circuit? It looks a lot like a resistor divider. Right? We've got some voltage, a resister, another voltage, a resistor, and another voltage. And we're interested in knowing this voltage.

So let's try to understand this guy as a divider. So we have-- and over here we have the reference voltage and resistor R1 and resistor R2. And we have the output voltage that we're interested in. So now the question is, what do we know about the voltage at this node? What do we know about the voltage at that node?

Mumble, mumble. Louder. We know something. We know its value. From the Op-Amp. What does the Op-Amp tell us about that voltage?

STUDENT: v-.

PROFESSOR KAELBLING: OK. That's V-. It's labeled V- in the Op-Amp. And what's the rule about Op-Amps? V- equals?

STUDENT: vi.

PROFESSOR KAELBLING: Vi, right. V- equals V+. So we have a voltage-- oh, I'm probably going to be too high here. Am I? I don't know. All right, too bad. We have a voltage here of Vi. That's the other terminal of the Op-Amp. And the Op-Amp promises to make this voltage equal to that voltage. That's his job in life.

Now, in the ideal model, it makes V+ equal to V-. So that means we know that this voltage here is Vi. OK? So now that we know that, we can solve the circuit. There's a bunch of different ways you could do this. You can write down Vcc stuff. I've evolved this habit of thinking about the voltage drop across here. That's Vi minus Vr, divided by R1. That's a name for the current that's flowing through here.

And a name for the current that's flowing through here is Vo minus Vi over R2. And there's nowhere else for the current to go. That's another thing we know. So these things have to be equal. You buy that?

And so what we find out is that Vo minus Vr is equal to R1 plus R2 over R1 times Vi minus Vr. All right. So it's sensible. Yeah?

STUDENT: Didn't you say that there's no current flow to the output? How can we get the current equal to--

PROFESSOR KAELBLING: There is current-- OK, good. There's no current here. There's no current flowing into the Op-Amp. However, this is a voltage source. And voltage sources make current. That's how they keep their voltage where it needs to be.

So current does flow through this thing. If flows this way. So you can think of current kind of going on a path from the ground connection, the sort of implicit ground connection of the Op-Amp, out this way. So there's current. And the current will be whatever it needs to be in order for the voltage to stay at the level that the Op-Amp equation tells us the voltage has to be.

So there's a current flowing through here. All right. So we can think of this as an amplifier. It makes sense to call it an amplifier now. It says that if you look at the difference between the input voltage and the reference voltage, it's especially easiest to see this if Vr is zero. We'll think about that in a minute. So imagine Vr is zero.

Then it says that the output voltage is R1 plus R2 over the input voltage. OK. So that's an amplifier. Let's look at some examples of how this amplifier works. Because there are subtleties having to do with what we take the reference voltage to be, and what the supply voltages are to the Op-Amp.

So let's consider for right now not even the amplification properties, but how these different voltages affect the results. So let's assume that R1 is equal to R2. If R1 equals R2, what's this fraction? 2. So we're going to kind of multiply by 2. All right.

So now let's consider the case where the reference voltage is zero, where the positive voltage coming in here is plus 10, and the negative voltage is minus 10. Or, the big voltage is plus 10, the small voltage is minus 10. That's known as having a two sided supply. And that's how circuits get designed in this mode.

So this works in the way that seems pretty intuitive, in the way that you might expect. So if the input voltage is plus 4, the output voltage is going to be plus 8, times 2. Input voltage is minus 3, output voltage is going to be minus 6. OK? Input voltage is plus 7, output voltage is-- you might think it should be 14. It can't be 14 because?

Yeah. The supply doesn't go that high. So inputs is 7. We multiply it by 2. But it gets clipped by the maximum and the minimum supply voltages. So the output can't be more than 10 in this case. So the output's 10.

OK. Now let's look at a case that's trickier. But it's also one that we're going to be using when we design stuff in the next couple of labs. So in this case, we don't, in some sense, have two different voltage values, a big positive and a big negative one available to us. Our Vcc's going to be plus 10, and our Vee is going to be zero.

So we're going to go from zero to plus 10. And think about it that way. In that case, it can be useful to set Vr to be plus 5. It's kind of halfway in between. It's a reference value that's halfway between zero and 10. So now, let's think about how this guy works.

So Vi is plus 4 volts, we look at this equation. So Vi minus Vr is what? Minus 1, right? Times 2. That's minus 2. So this thing over here is minus 2. So we have Vo minus Vr is minus 2. In order to make that true, Vo has to be three volts.

So that seems a little mysterious and unintuitive. But the way to think about it is that really, if Vr is plus 5, 4 is minus 1. And if Vr is plus 5, then 3 is minus 2. So the output is still sort of 2 times the input, seen relative to the reference value. Man, I see a lot of sleeping. OK. We're going to fling chalk at people or something. No, OK.

So one more case, one more case. This is really going to matter to you later, I promise. One more case. Let's consider the case where Vi is plus 7 volts. Then what should the output be? Well, you might say 14. We already know that's wrong. You might say 10, because that was the answer before.

But it isn't actually either one of those. So let's understand why. So we look at Vi minus Vr, and we get 2. 2 times 2 is 4. So what Vo minus Vr is 4? That's 9. And again, that might seem silly to you. But it makes sense if you think about everything being relative to plus 5. Relative to plus 5, this is 2. And relative to plus 5, that's 4.

So we still get the multiplied by 2 relationship. Is this OK with everybody? It really is going to matter in the next week or two. Yeah? OK. So here's a question. Now let's assume that Vr is zero. For what values of R1 and R2 can we get Vo equal to 4 times Vi?

Before, we were talking about messing with the supply voltages and stuff. Now, we're going to talk about messing with the resistor values. So don't worry about being clipped or anything. So if we wanted the output to be 4 times the input, well, one thing we can do is let R2 be, say, 300 ohms, and R1 be 100 ohms. Because we get R1 plus R2 over R1. And that gives us a factor of 4.

You could do it with 1 ohm and 2 ohms. Things might get warm. You could do it with bigger resistors. But the ratios are all that matter. Can we arrange it so that Vo is a half of vi? How many people think yes. OK. There's one answer. Anybody else?

I'm not so sure. The relationship is R1 plus R2 over R1. So that ratio can't ever be less than 1. So with a non-inverting amplifier-- this is another little sound bite good to stuff in your head-- with a non-inverting amplifier, you can't decrease the voltage. You can turn it up. You can't turn it down. Does that make sense to everybody? OK.

So it's for that reason that people thought about making an inverting amplifier. It looks a lot like a non-inverting amplifier. It's just that the input comes in in a different place. So basically, we've swapped the places of the input voltage and the reference voltage.

So again, if you analyze this as a resistor divider-- so let's actually do this as a resistor divider. What do we have? We have the interesting divider goes Vi, R1, R2, Vo. And if we look in that picture up there, we see that we have Vr at the other terminal of the Op-Amp. And that again, it's the Op-Amp's job to make these guys equal without current flowing.

So we know that it's like there's a voltage source here, forcing this node to have voltage Vr. Do you see how this picture relates to that one? I've just sucked out that little divider. So now what do I do? Well, let's see. I can, again, do the kind of, look at the voltage, drop across here. Vr minus Vi over R1. That gives us the current.

And that's going to be equal to Vo minus Vr over R2. So dividers are cool. They have to-- you can kind of put a voltage across here, and then you force a related voltage to be from here to here. Exactly what that voltage is depends on the ratio of the resistances. But we can put something here, put something here, and then that's going to force that Vo to go somewhere.

And so here's the equations that describe that. So if we solve that out, we get that Vo minus Vr is equal to minus R2 over R1, Vi minus Vr. That's an r. That's an i. OK. So again, easy to think about. If Vr is zero, then we get that Vo is minus R2 over R1, Vi.

So the difference from the reference voltage is simplified. It's multiplied by R2 over R1. And it's also inverted. And it's inverted-- in some sense, you can think of it as being inverted about Vr. So let's look at a couple of examples here. Because again, this is something that we'll have to think through a lot.

In the case that our supply voltages are plus and minus, and Vr is zero, then the way this works is no big surprise. Let's just look at, if R1 is equal to R2, this is now just an inverter. It's just flipping the sign of the voltage. And so if the input voltage is 4 volts, we get out minus 4. If input is minus 3, we get out plus 3.

So if you were going to go buy an inverter, that's what you would hope for it to do, I think. But let's look at this case down here, the case where the supply voltages are plus 10 and zero. And the reference voltage is 5. So I like to think to say, 5 is the new zero. 5 is the thing that we're going to measure ourselves against, and it's the thing that we're going to think about inverting around.

So if vi is plus 4, then Vo is going to be plus 6. Why? Because again, if Vr is 5, then Vi equal to plus 4 is really like having this be negative. It's like, this is negative 1. We negate the negative 1, and get a positive 1. And that means Vo has to be 6, which is one more than the reference voltage.

So we had something that was one less than the reference voltage. And what we got out was something that was one more than the reference voltage. Here, we come in with something that's two more than the reference. And what we get out is something that's two less. So if the reference voltage is not zero, we're inverting around it. Yep?

STUDENT: So the inverting amplifier doesn't function [? as a current ?] divider anymore? Because there's that path from Vi to Vo now.

PROFESSOR KAELBLING: There is a path from Vi to Vo. And it behaves like that resistor divider there.

STUDENT: We can't [? depend on-- ?] actually, I guess you can. OK, nevermind. I guess it's me.

PROFESSOR KAELBLING: OK. It's just big because Vr can't play here. And the current can't flow through here at all. So these guys are just playing together like this. Yeah. Good. OK. So a couple more things that we can do with Op-Amps, and then we'll be done with Op-Amps.

So another thing. So what we've see is that we can multiply things with Op-Amps. We can take a voltage and scale it up or down. And we can invert it. We can also add. So I'm going to work through these on the board. Because first of all, it's useful to understand what a summer does.

But more importantly, we'll be asking you to first analyze and then design moderately complicated circuits with Op-Amps in them. So it's useful to just get some practice in strategies for dealing with that. So let's do the summer.

And again, I'm going to think about the divider. Now, you can think about, look at that picture, and see two resistor dividers in it. This strategy that I'm teaching you to think about this, it's like the strategy that we used to deal with serial and parallel and so on. That if your circuit offers it to you, it's great, and you can really take advantage. In the end, it's going to turn out that plain old NVCC method works for Op-Amps, just like for everything else.

And you can kind of churn through it if you have to. But here's a way to get some more intuition, maybe, about what's going on. So for the summer picture that's up there, we've got two dividers. There's one that looks like this. It goes from V1 to some intermediate value, we're not sure about that yet, to V2. So you see that in the circuit picture.

And there's another divider that goes-- I'm going to call this zero. We could do it with a general reference voltage, but it starts to get messy. So we'll just do the simple zero case. Zero here, something here, resistor, Vo. And again, for simplicity, although not because it's required, I'm just going to let all these resistors be equal. In fact, what matters is that these guys are equal and those guys are equal. But anyway, we'll just let them all be equal.

So here's a different picture of that circuit, where again, the Op-Amp constraint tells us that those two nodes, although they're not connected to one another, they have to have the same voltage. That's what the Op-Amp is doing for us. So now, we can try to analyze the circuit. And what do we do?

Well, what do we know about this voltage, just by looking at the top divider only? What's this voltage? Yeah. So it's V1 plus V2 over 2. Now-- let's see. I had a momentary choke, but I got it all back again. Is everybody happy with how we derive this? You understand that if these resistors were different values, that's not how that would work out?

OK. So saying it's the average makes us a little bit nervous. It turns out to work out OK, but be careful. So V1 plus V2 over 2. The bottom now, downstairs, if we know that this node has value of V1 plus V2 over 2, now we ought to be able to analyze the rest of the circuit. And it's not probably too hard to see.

So what's the voltage difference between here and here? If this is zero, and that's V1 plus V2 over 2? V1 plus V2 over 2, OK. Now, what does the voltage difference between here and here have to be? The same. Why? Because these two resistors are the same. Right?

So the voltage difference here has to be the same as the voltage difference there. So this is V1 plus V2 over 2. And if this difference is the same as that difference, then this has to equal V1 plus V2. So we just did addition with an Op-Amp. OK?

Don't memorize this arrangement. But be sure that you know how to do these kinds of computations. I'm going to do one more. I'm going to do a subtractor. And again, with the subtractor, so what's going on here?

Now we see that we have one input coming into the negative terminal, and an input coming into the positive terminal. Now, you might wonder, do we need all this hairiness, somehow? Like, what if I took away this resistor and that connection to ground? What if I just erased that?

So if I just erase that, there's no current going through this resistor. There's nowhere for current to go. So this guy can't really play with us. No current is going to flow anywhere. There's not going to be an interesting voltage here.

So we need a place for this current to flow through, so that we get a voltage here on this node. That's what's going on here. And we have our feedback connection up here. So V1 is connected in this with the two resistors and the feedback to the minus. V2 is connected, essentially, through a divider with the middle of the divider going to the plus.

And again, let's, for right now, assume that all the resistances are R. And that this reference voltage is zero. You could do it more generally, but we'll just assume it's zero for now. So if you look at this again, you see two dividers. So let's do the two dividers.

So you see one divider. It's arranged differently than before. So in this case, this divider, one of them has V2. We'll just say R, R, and VR-- oh, let's VR be zero. And this one has V1, and R, and R, and Vo. OK? So there's the two dividers in that picture. You can kind of pull them out, and look at them. Those guys have the same voltage.

So let's see. What do we know? Well, we're interested in finding Vo. But we know V2, and we know zero, over there. So if these resistors are equal, and this is V2 and that's zero, what's this voltage? V2 over 2. OK, so if that voltage is V2 over 2, then this voltage is V2 over 2. And so the voltage difference here is V2 over 2 minus V1. Right?

And the resistors are equal, so the voltage difference here is V2 over 2 minus V1. So the total voltage difference from here to here is V2 minus 2V1. You buying that? If you bought that much, then what's Vo equal to? It's V2 minus V1. Right?

Because, so if this is V2 minus 1, then the difference between here and here is V2 minus V1, minus another V1. Because this is an expression for the relative difference. So the output voltage is going to be V2 minus 1. V2 minus V1, yay, it's a subtractor. So it's pretty cool.

So we can do arithmetic. We can multiply. We can negate. We can add, and we can subtract with Op-Amps. And can wire these things up to do arbitrarily hairy arithmetic stuff. So that's going to be a cool thing that we're going to make use of. So we have a couple of practice problems to do, so let's do them.

This does not look exactly like anything we've looked at, and it doesn't look exactly like a divider, either. But take a couple minutes. Talk to somebody next to you, and do this problem. You can even move to find a human to talk to.

All right. I see some working, and some sleeping.

All right. We can talk about it. Looks like some people finished, and some people didn't. But we'll go ahead. So what do we do? We can just-- so you don't have to apply any new techniques. If we look at this circuit, it's really, the only interesting stuff is involving these three resistors, and this node right here.

So you can abstract it away into a circuit that looks like-- you can make it look like that. You buy that? One, two, three? And what do we know about the voltage here? It's zero. Voltage there is zero. How come? How come the voltage is zero?

Because V+ is tied to ground. We take ground to be zero. V+ is equal to V-. That's the Op-Amp thing. So this is zero. So the currents have to add up to zero at that node. Right? OK, so the currents have to add up to zero. They did that anyway. Currents add up to zero. And what are the currents?

Well, the current through this resistor, so this current, I1, is equal to V1 over 1. Because these are all one ohm resistors. And this current is equal to V2 over 1. And this current, we'll draw it this way, is equal to Vo over one, and that all has to equal to zero.

If these resistors had had different values, there would be different denominators here. If the voltage here had been something other than zero, then we would have had V1 minus whatever that is, V2 minus whatever it is, Vo minus whatever it is. So that explains for the zeroes in that formula up there in the slide.

So you get this equation, V1 plus V2 plus Vo is equal to zero. So Vo is minus V1 minus V2. Yep?

STUDENT: Why does [? V move ?] to the left, or the current?

PROFESSOR KAELBLING: Good. Why does this current move to the left? Because I drew the arrow in that direction. If I drew the arrow in this direction? Let's do that. I draw the arrow in this direction. Then I have to change two signs. This guy is now going out. So I'm going to put a minus here.

And this now has to be zero minus Vo. Because the voltage drop is going in the other direction. So when I switched the arrow on the current, I changed the head and the tail, so the order in which I subtract the voltages. And I changed the sign that it uses when it plays in the KCL equation. So it's arbitrary, but you have to be consistent. Yep?

STUDENT: I actually don't see where we divide V+ equals V-.

PROFESSOR KAELBLING: That's what an Op-Amp does.

STUDENT: Wait, I thought that [? it would be ?] zero equals the difference.

PROFESSOR KAELBLING: It makes V+ equal V-. It makes V+ equal V-. In the simple example where we derived it, Vo was V-. But the ideal Op-Amp approximation is that it makes V+ equal to V-.

STUDENT: But that's only--

PROFESSOR KAELBLING: OK. So the question is, I kind of led you to believe that in a simple example. It's true in general. We can talk about it. But the ideal approximation, V+ equal V-. Because if it's not, if V+ is not equal to V-, then it's going to do some adjustments. And it's going to make it so, if you think about the feedback.

STUDENT: [INAUDIBLE]

PROFESSOR KAELBLING: That's right. That's right. So the feedback will make it true. Good. More questions about this problem? You should feel comfortable with it. We'll do another one in a minute. Any more question? No, in the back? No, that was a stretch. OK. So let's do one more.

OK. So that's an inverting summer. It's sort of like an endless summer, but not. Here's a new one. It's trickier.

I'm just trying to solve it a different way while you guys do it. Keep at it. Probably, I'm not sure that this one's useful, but we'll see.

All right. So we'll just stop and talk about this, and then be done. So here's a way to think about it. It's worked out. I'll post this version on the web. In fact, I think it's probably already posted. So let's see if we can see how this is going. So first of all, if you look at this resistor divider-- so let's look carefully at this one.

So we have 1 ohm and R ohms. So if we have 1 and R, then this voltage right here is going to be R over 1 plus R. Again, that's the resistor divider. 1 plus R is the total resistance. And we have R left to go. So a way to think about it to get to zero, so R over 1 plus R is this voltage. So that's the voltage at the plus terminal.

So now, we can try to understand what's going on over here. So we know that V- is going to equal R over 1 plus R, V1. So that's going to be the value here. And basically at that point, you have all your equations, and you can do the algebra. And you get out that R is equal to 2 ohms.

So if you think about that, let's see if that makes sense intuitively. So let's just think about 2 ohms. So there's two ways always to approach a multiple choice problem. One is to solve the problem, and the other one is to examine the solutions. Let's just examine the solution R equals 2. So if R equals 2, then the voltage here is 2/3 of V1.

So this is 2/3 of V1. So this is going to be 2/3 of V1 right here. And if this is 2/3 of V1, then you can see that we go 2/3 of the V1-- well, let's see. How do I get this out? Oh yeah, I see. OK, good. So Vo is supposed to be-- let's go back and be sure that we see what the answer's supposed to be, right? So Vo is supposed to be 2 times V1 minus V2.

So we have to somehow get the minus 2V2 going through here, and the V1 place here. So algebraically-- yeah, I don't get this intuitively, I get it algebraically. I did the algebra and got the answer out. I'm not good at seeing it intuitively. But one thing that's useful is to see that whatever's coming in the positive terminal, I mean and this is a way to check yourself, whatever's coming in the positive terminal is going to come out positively in the output.

And whatever's coming in the negative terminal is going to come out negatively in the output. You can also see these things as instances of amplifiers. And it should work out-- another way to check your work and be sure that you've done something right--- is to understand what happens if, for instance, one of these things is just not present. So we get a positive amplifier of one of these things is not there, and a negative amplifier in the other case.

So that's another way to think about it, if V1 or V2 is zero. So Op-Amp problems, you can solve them using intuition. You can solve them using algebra. Op-Amps do two important things. Wait, let me just recite this one more time. What the Op-Amp promises is that it sets V+ to V-. And that no current flows between these two terminals.

OK, good. So you're going to go and play with Op-Amps this week. No Homework 3. This week, there's no Homework 3.