Op-Amp Experimentation 2: Basic Circuit Math

First published August 11, 2016 on my old site. Copied here as written.

Op-Amp Experimentation 1: Op-Amp Basics

Op-Amp Experimentation 2: Basic Circuit Math

Op-Amp Experimentation 3: Op-Amp Applications

Op-Amp Experimentation 4: From Ideal to Real

Op-Amp Experimentation 5: Integrator

Op-Amp Experimentation 6: Differentiator

Op Amp Experimentation 7: PID Controller – coming soon

As much as I’d like to, I’m not going to cover basic circuit analysis here. Therefore, this page assumes some familiarity with DC circuit analysis, although I won’t go too deep here. Anyways, this page will cover the basic math involved in analyzing op-amps, which should give us a good preparation for the next page where we cover some applications of op-amps. The main three op-amp configurations will be covered, the non-inverting op-amp, the inverting op-amp, and the differential op-amp. The basic steps involved are the same as any circuit, ie. basic node equations. Just a few things to note, for an ideal op-amp the voltage at the inputs is equal, no current can flow into or out of the inputs, and no current can flow out of the output.

Example 1: Non-Inverting Op Amp

Looking at this, we know that V−=V+{V_ - } = {V_ + } and there is no current flowing into or out of the op-amp. Doing a current balance between iRf{i_{{R_f}}} and iRg{i_{{R_g}}} yields

iRf=iRg{i_{{R_f}}} = {i_{{R_g}}}

where

iRf=Vout−VinRf{i_{{R_f}}} = {{{V_{out}} - {V_{in}}} \over {{R_f}}}     and

iRg=VinRg{i_{{R_g}}} = {{{V_{in}}} \over {{R_g}}} .     Substituting these into our current balance yields

Vout−VinRf=VinRg{{{V_{out}} - {V_{in}}} \over {{R_f}}} = {{{V_{in}}} \over {{R_g}}} .     Solving for     Vout{{V_{out}}}     results in

Vout−Vin=RfRgVin{V_{out}} - {V_{in}} = {{{R_f}} \over {{R_g}}}{V_{in}} Vout=Vin+RfRgVin{V_{out}} = {V_{in}} + {{{R_f}} \over {{R_g}}}{V_{in}} Vout=Vin(1+RfRg){V_{out}} = {V_{in}}\left( {1 + {{{R_f}} \over {{R_g}}}} \right)

Now it is sometimes useful to express the Gain (G) of an op-amp circuit as the ratio of the output to the input.

G=VoutVin=1+RfRg=Rf+RgRgG = {{{V_{out}}} \over {{V_{in}}}} = 1 + {{{R_f}} \over {{R_g}}} = {{{R_f} + {R_g}} \over {{R_g}}}

Okay, so we went through the theoretical equations. Now lets try some values. Let’s say we are dealing with a small analog sine wave, with an amplitude of 10mV. We want to bump that amplitude up to 1V. So our input is 10mV, output is 1V, our required gain is 1V/10mV = 100. So we would need resistors that follow the ratio

G=100=1+RfRgG = 100 = 1 + {{{R_f}} \over {{R_g}}} RfRg=99{{{R_f}} \over {{R_g}}} = 99

This will all get more interesting very soon, I promise. I’ll cover one more example on this page, the inverting amplifier, then the next page will have much more fun things.

Example 2: Inverting Op-Amp

Again, starting with V−=V+{V_ - } = {V_ + }  and knowing that there is no current into or out of the Op Amp, we can start with the current balance at the node between Rf{{R_f}} and Rg{{R_g}} .

iRg=−iRf{i_{{R_g}}} = - {i_{{R_f}}} iRg=VinRg{i_{{R_g}}} = {{{V_{in}}} \over {{R_g}}} iRf=VoutRf{i_{{R_f}}} = {{{V_{out}}} \over {{R_f}}}

Solving for Vout{{V_{out}}}

VinRg=−VoutRf{{{V_{in}}} \over {{R_g}}} = - {{{V_{out}}} \over {{R_f}}} Vout=−RfRgVin{V_{out}} = - {{{R_f}} \over {{R_g}}}{V_{in}}

Solving for the gain G

G=VoutVin=−RfRgG = {{{V_{out}}} \over {{V_{in}}}} = - {{{R_f}} \over {{R_g}}}

Notice that this creates an amplified output that is negative. This was probably the trickiest part in going from theoretical circuits to actual circuit designs for me, so I will cover this in more detail later on.

Example 3: Differential Amplifier

Here is a very useful configuration for op-amps. We will analyze this the same exact way as before. First, we set V−=V+{V_ - } = {V_ + } and i−=i+=iout=0{i_ - } = {i_ + } = {i_{out}} = 0 .

Next we will do a current balance at the node between R1{R_1} and R2{R_2} :

Va−V−R1=V−−VoutR2{{{V_a} - {V_ - }} \over {{R_1}}} = {{{V_ - } - {V_{out}}} \over {{R_2}}}

And a current balance between R3{R_3} and R4{R_4}

Vb−V+R3=V+R4{{{V_b} - {V_ + }} \over {{R_3}}} = {{{V_ + }} \over {{R_4}}} .

Substituting Vin{V_{in}} in for V+{V_ + } and V−{V_ -} and solving for Vout{V_ out }

Starting with Vb−VinR3=VinR4{{{V_b} - {V_{in}}} \over {{R_3}}} = {{{V_{in}}} \over {{R_4}}}    we get

Vin=Vb(R3R4+1){V_{in}} = {{{V_b}} \over {\left( {{{{R_3}} \over {{R_4}}} + 1} \right)}}     Substituting this into Va−VinR1=Vin−VoutR2{{{V_a} - {V_{in}}} \over {{R_1}}} = {{{V_{in}} - {V_{out}}} \over {{R_2}}}   results in

Va−Vb(R3R4+1)R1=Vb(R3R4+1)−VoutR2{{{V_a} - {{{V_b}} \over {\left( {{{{R_3}} \over {{R_4}}} + 1} \right)}}} \over {{R_1}}} = {{{{{V_b}} \over {\left( {{{{R_3}} \over {{R_4}}} + 1} \right)}} - {V_{out}}} \over {{R_2}}}

Simplifying results in

Vout=(R1+R2R1)(R4R3+R4)Vb−R2R1Va{V_{out}} = \left( {{{{R_1} + {R_2}} \over {{R_1}}}} \right)\left( {{{{R_4}} \over {{R_3} + {R_4}}}} \right){V_b} - {{{R_2}} \over {{R_1}}}{V_a}

Now that doesn’t really look very appetizing, and there is quite a bit more to the math. I’m just going to simplify that by saying if R1R2=R3R4{{{R_1}} \over {{R_2}}} = {{{R_3}} \over {{R_4}}}  then the equation reduces to

Vout=R2R1(Vb−Va){V_{out}} = {{{R_2}} \over {{R_1}}}\left( {{V_b} - {V_a}} \right)

So this system just amplifies the difference between Va{V_a} and Vb{V_b} . But now that we have a few examples, we can cover some fun tricks you can do with op-amps. Check out the next page for op-amp applications.

Previous page: Op-Amp Experimentation 1: Op-Amp Basics

Next page: Op-Amp Experimentation 3: Op-Amp Applications