Now, I'd like to talk a little bit about the gain control or the distortion part of the circuit. Now, this uses a circuit component that we haven't talked about at all here. And I'm just going to briefly introduce the diode. so a diode is a semiconductor device that has the property that when I apply a voltage across it, a current flows. And the current follows a log that looks like this. The amount of current as a function of the voltage, so V is the applied voltage. And I is the current, it follows this kind of an expression. So, it has an exponential dependence on the voltage. Now, this in factor in front is called the reverse saturation current and Vt is the thermal voltage which is about 26 millivolts. And now, if we take and plot this then the reason for those names will maybe be a little more obvious. But at 0, when V is 0, e to the 0 is 1. And this cancels that 1, and so the current is 0. So, the current is 0 at an applied voltage of 0. Now, when V becomes negative, as it gets larger and larger, e to the minus, some large negative number, goes to 0. And I just get negative 1 times I 0. And so, the current here approaches negative I 0. That's why they call this the reverse saturation current. Under reverse bias, the current level saturates to some value. And it's it varies from different diodes among different diodes, but it's usually very small, just microamps or usually much smaller than that. now when you look at forward bias, when V is a positive number it very rapidly, VT, this is actually equal to Boltzmann's Constant times the absolute temperature, KT, if you've taken any device physics. And that's about 25.9 millivolts. So, 26 millivolts. Close enough. Now, when V is a few times that voltage, then this exponential becomes much larger than 1, and you can essentially ignore the 1. And so, the current then just goes up exponentially. Now, this is a very simple model. It ignores all kinds of other physics going on in these devices, and there's forward saturation current, then it doesn't really quite follow this this curve. But this is a good enough model for, for our purposes. So, that's a diode. That's what it does. It just remember that it's, essentially it's just a, a device that lets current pass in the forward direction, but it hardly lets any current pass in the negative direction. So, it's kind of like a, a one-way check valve. It lets, the check valve lets water through one way, but it can't flow back the other way. And so, essentially, that's what a diode is. Now, what we're going to do to build the distortion circuit is put a diode in the feedback path. Now, what happens here is that the the signal, when I get a voltage across here, now this let's take a closer look at this. This is still a not, this is an inverting op amp configuration. So, just imagine, forget the diode for now. I just built a simple inverting stage here. It's going to have gain RF over R in. And now, what I'm going to do is just stick a diode across RF. Now, what happens is that when the voltage across RF gets large, the diode is going to conduct more. And more of the current is going to go through the diode less of the current is going to go through the feedback resistor and the voltage is going to drop. So, I effectively can turn down the gain for larger signals by putting this diode in parallel and we'll see how that works. Now, remember, when you're looking at this amplifier, we have the non-inverting input grounded and the op amp always wants to keep the inverting and non-inverting terminals at the same potential. So, this inverting input is essentially grounded too. Now, the output voltage then is dropped all of it has dropped across these components. And so, so the I2 times RF, that is the output voltage. Okay, now let's do a quick analysis of this. So, I can use Kirchhoff's current law, looking at this note at the inverting input of the op amp. Now, remember, no current flows into the op amp itself. And so, whatever is flowing through the resistor has to split and flow through the feedback resistor and the diode. So, I1 is I2 plus I3. Now, I can write. I can substitute in for these currents in terms of the voltages. So, I1 is going to be V in minus 0. This is, this terminal is a 0 potential, so it's V in minus 0 over R in. So, that's I1. And that has to equal I2. Now, I2, you have to be careful of the signs here because the voltage here is 0. The voltage there is V out. So, it's 0 minus V out divided by our feedback, that's the current in the direction that I've indicated. So, that's I2. And then, I3 is just the diode equation but the voltage across the diode is 0 minus V out. And so, there is the expression for the current through the diode. Now, this, if you take and sit down and try to solve this for V out as a function of V in it's going to be, it's not possible. This is a transcendental equation. if you're able to find an analytic solution, then e-mail me about it. I'd like to know. But what I'm going to do, is use a graphical technique to, to get this characteristic. So, let's just rewrite this, this equation. I'm going to rewrite it down here. So, V in over R in equals all of this. And just have to keep track of the signs. Then, I'm going to multiply both sides by R in. So, I get V in is R in times, then I have e to the minus V out over V thermal, minus 1 times I0. And then, there's minus V out over RF. So, here's an expression. You would, you're tempted to take this expression and try to find a way to solve this for V out as a function of V in, but that's not possible to do. So, what I'm going to do is just use a simple graphical technique. And all we're going to do is take that equation and find, let's, let's just flip things around and assume that V out is the input and V in is the thing we're computing, the output. And so, let's just put in a series of values for V out, compute the V ins, and then just flip it and plot it as V out versus V in. And so, so I, I compute V in as a function of V out, but then I turn around, and I plot it as V out. As a function of V in. So, it's really, there's, there's nothing terribly sophisticated here. It's a simple idea, but it's just a trick to come up with a graphical solution. So, I've plotted the input voltage here, from 0 to 1. The output voltage, 0 to 1. And the blue line is if I had a perfectly linear response, so the output was exactly equal to the input. the red line is what I get when I compute V in as a function of V out, and then flip it around and plot V out versus V in. So, you see what happens is the op amp gain initially is quite large, so the slope of the line down here is much larger than unity. So, the gain is, is, is I don't know, five or ten, something like that. And then, as the input voltage gets larger, the diode is going to conduct more of the current. The total voltage across the feedback branch on the op amp is going to start going down and or it's not going to increase as fast and the output doesn't increase. So, here is the output versus input characteristics for that op amp. Now, there's one little thing here, if you're watching the details, if I put in a plus voltage in the inverting amplifier, I get a negative voltage out. And I've taken the magnitude of the transfer function. You actually get If I put in, say, plus 0.2 volts input, then I really get out about about negative 0.13 and but I'm taking the magnitude. And so, I, I don't want to look at the negative numbers. So, I've plotted, that's why we plotted this as magnitude.