# Electronics/Op-Amps/Linear Configurations
## Inverting Op Amp

The closed loop gain "mon then" of an Inverting Op Amp is
    $R_{1}=R_{in}$
    $A_{f}=-{\frac {R_{f}}{R_{1}}}$ (i)
Input Impedance of this configuration is $Z_{in}=R_{in}$ (because $V_{-}$ is a virtual ground, no current flows into the Op Amp ideally.)
To get formula (i) we take a KVL loop with $V_{in}$, $R_{1}$ and the inputs of the Op Amp. This gives
    $V_{in}=i_{in}R_{1}+v_{d}\,$
Where $v_{d}$ is $v_{+}-v_{-}$ the voltage between the non-inverting and inverting inputs. But for ideal Op Amps $v_{d}$ is approximately zero. $v_{d}$ is zero because the input impedance is infinite, which means the current through the impedance must be zero by Ohms law. The zero current means that there is no voltage drop across the impedance. This gives:
    $i_{in}={\frac {V_{in}}{R_{1}}}$ (5)
Using this idea.
    $i_{f}={\frac {V_{out}}{R_{f}}}$(6)
If we take KCL at the inverting input then
    $i_{in}=i_{d}-i_{f}\,$
For an ideal Op Amp there is no input current because there is infinite resistance. So using equations 5 and 6.
    $-{\frac {V_{in}}{R_{1}}}={\frac {V_{out}}{R_{f}}}$
Since
    $A_{f}={\frac {V_{out}}{V_{in}}}=-{\frac {R_{f}}{R_{1}}}$
Example 1
Design an Inverting Amplifier to amplify a 100mV signal to 1V signal. Assume: No source impedance.
Solution:
Step 1: Work out required gain.
    $|A_{f}|={\frac {1}{0.1}}=10$
Step 2: Select an $R_{f}$ value.
    Choose $R_{f}=100k\Omega$.
Step 3: Work out the required value of $R_{1}$ using equation (i).
    $R_{1}={\frac {100k}{10}}=10k\Omega$
Example 2
Design an Inverting Amplifier to amplify a 10mV signal to a 1V signal. The signal has a 100 $\Omega$ source impedance. The amplifier must not invert the signal.
Solution:
Since the voltage cannot be inverted then there must be an even number of stages. For simplicity let us choose two stages. Assume an ideal Op Amp.
Step 1: Work out the required gain.
    $A_{f_{tot}}={\frac {1}{0.01}}=100$
Step 2: Choose the required gain for each stage.
    The gain will be 10 for both stages. But in the first stage we must worry about loading.
Step 3: Choose a value of input impedance i.e. choose $R_{1}$.
    Choose $10k\Omega$. We can now calculate the voltage that input to the Op Amp by voltage divider.
    $V_{in}={\frac {R_{1}V_{s}}{R_{1}+R_{s}}}={\frac {(10k)(10mV)}{10k+100}}=9.9mV$
We want the output of this stage to be 100mV.
    $A_{f1}={\frac {100}{9.9}}=10.1$
Step 4: Use $A_{f1}$ to work out $R_{f1}$.
    Using equation (i) $R_{f}=A_{f1}R_{1}=101k\Omega$
Step 5: Choose a $R_{f}$ for the second stage.
    Choose 100k.
Step 6: Calculate $R_{1}$ using equation (i).
    $R_{1}=10k\Omega$

## Non-Inverting Op Amp

The closed loop gain of a Non Inverting Op Amp is
    $A_{f}=1+{\frac {R_{2}}{R_{1}}}$ (ii)
The input impedance of this configuration is Zin = ∞ (realistically, the input impedance of the op-amp itself, 1 MΩ to 10T Ω).

#### Ideal Op Amp Derivation

Take a KVL with the inputs of the Op Amp and R$_1$.
    $V_{in}=v_{d}+V_{R1}\,$
But $v_{d}$ is zero since the Op Amp is ideal. Therefore
    $V_{in}=V_{R1}\,$(3)
According to voltage divider rule
    $V_{R1}={\frac {V_{out}R_{1}}{R_{1}+R_{2}}}$(4)
Substitute equation 4 into 3.
    $V_{in}={\frac {V_{out}R_{1}}{R_{1}+R_{2}}}$
Thus
    $A_{f}={\frac {V_{out}}{V_{in}}}=1+{\frac {R_{2}}{R_{1}}}$

#### Feedback Analysis Derivation

If the output is connected to the inverting input, after being scaled by a voltage divider K = R$_1$ / (R$_1$ + R$_2$), then:
    V+ = V$_{in}$
    V$_−$ = K V$_{out}$
    V$_{out}$ = G(V$_{in}$ − K V$_{out}$)
Solving for V$_{out}$ / V$_{in}$, we see that the result is a linear amplifier with gain:
    V$_{out}$ / V$_{in}$ = G / (1 + G K)
If G is very large, V$_{out}$ / V$_{in}$ comes close to 1 / K, which equals 1 + (R2 / R1).
This negative feedback connection is the most typical use of an op-amp, but many different configurations are possible, making it one of the most versatile of all electronic building blocks.
When connected in a negative feedback configuration, the op-amp will tend to output whatever voltage is necessary to make the input voltages equal. This, and the high input impedance, are sometimes called the two "golden rules" of op-amp design (for circuits that use feedback):
* No current will flow into the inputs
* The input voltages will be equal to each other
The exception is if the voltage required is greater than the op-amp's supply, in which case the output signal stops near the power supply rails, V$_{S+}$ or V$_{S−}$.
Example 3
Design a Non-Inverting Amplifier to amplify a 100mV signal to 1V signal. Assume: No source impedance.
Step 1: Work out required gain.
    $A_{f}={\frac {1}{0.1}}=10$
Step 2: Select an $R_{2}$ value.
    Choose $R_{2}=90k\Omega$.
Step 3: Work out the required value of $R_{1}$ using equation (ii).
    $10=1+{\frac {90k}{R_{1}}}$
    $R_{1}={\frac {90k}{9}}=10k\Omega$
Example 4 (a quick design procedure):
I want to amplify a signal A with a gain of 8. We want an output swing of at least -3 to +3 V.
We have a 5V and -5V power supply handy, so we can use that.
1. gain of 8 for A.
2. Ground gain = 1 - (8) = -7.
3. feedback-resistor value: Rf = 100 kiloOhms.
4. resistor values for each input:
* R$_A$ = 100 kΩ / 8 = 12.5 kΩ
* R$_{ground}$ = 100 kΩ / | -7 | = 14.3 kΩ
Since A has a positive gain, connect its resistor to V+. Since ground has a negative gain, connect its resistor to V$_−$
Example 5
Design a two stage Non-Inverting Amplifier to amplify a 10mV signal to 1V signal. The signal has a source impedance of 100 Ω.
Solution Assuming an ideal Op Amp. Since this configuration has the input impendance of the Op Amp itself. We do not have to worry about loading since the input impedance is infinite.
Step 1: Work out the required gain.
    $A_{f}={\frac {1}{0.01}}=100$
Step 2: Choose the gain for each stage.
    Choose 10 for both stages.
Step 3: Choose a value for the $R_{2}$ resistors in both stages.
    Choose 90kΩ for both.
Step 4: Work out the value of $R_{1}$.
    Using equation (ii) $R_{1}=10k\Omega$.

## Voltage Follower

This configuration is also known as the unity gain Buffer. Since it can be used to counter the effects of loading of the source. It provides an input impedance even higher than a normal Non-Inverting amplifier since the gain reduces that input impedance. The gain is given by equation (ii). But R_2 is short circuited and R_1 is an open circuit.
    $A_{f}=1+{\frac {R_{2}}{R_{1}}}=1+{\frac {0}{\infty }}=1$

## Difference amplifier

This configuration is just an Inverting and a Non-Inverting configuration connected simultaneously. Resistors R$_2$ and R$_4$ are a voltage divider. Consider the situation when R$_4$ is open circuited and R$_2$ is short circuited. Now from equations (i) and (ii) we know that the gain of V$_1$ is
    $A_{f1}=-{\frac {R_{3}}{R_{1}}}$
and the gain of V$_2$ is
    $A_{f2}=1+{\frac {R_{3}}{R_{1}}}$
Now if we set $A_{f1}$ to -10 then $A_{f2}$ will be 11. This means that V$_{out}$ will be
    $V_{out}=V_{1}A_{f1}+V_{2}A_{f2}=V_{2}(11)-(10)V_{1}$
This means that if $V_{1}=V_{2}$ that V$_{out}$ will be V$_2$. This is not very useful for the most because mathematically we would like the answer to be zero. But if we make the voltage at the non-inverting input equal to 10/11 then when the voltages are equal we will have zero.
When R$_4$ and R$_2$ are connected the gain of V$_2$ is
    $A_{f2}={\frac {(1+{\frac {R_{3}}{R_{1}}})R_{4}}{R_{4}+R_{2}}}$ (x)
The gain of V$_1$ is
    $A_{f1}=-{\frac {R_{3}}{R_{1}}}$ (y)
If we want $A_{f2}=|A_{f1}|$
    ${\frac {R_{3}}{R_{1}}}={\frac {(R_{1}+R_{3})R_{4}}{(R_{4}+R_{2})R_{1}}}$
We just set $R_{4}=R_{3}$ and $R_{2}=R_{1}$.
This configuration has a low input impedance. The input impedance seen by V$_1$ is R$_1$ as in the Inverting Amplifier. The input impedance seen by V$_2$ is R$_2$ + R$_4$.
Example 6 (a quick design procedure):
We often want to subtract one signal A from another signal B, and amplify the difference by 10. We want an output swing at least -6V to +6V. Oh, and for safety reasons, A and B each have a source impedance of 8 kΩ.
Our 5V and -5V power supply isn't adequate, so we pick a +12V and -12V power supply.
1.
* gain of +10 for B.
* gain of -10 for A.
2. Ground gain = 1 - ( +10 + -10 ) = +1.
3. feedback-resistor value: Rf = 100 kiloOhms.
4. resistor values for each input:
* R$_A$ = 100 kΩ / | -10 | = 10 kΩ
* R$_B$ = 100 kΩ / | +10 | = 10 kΩ
* R$_{ground}$ = 100 kΩ / | +1 | = 100 kΩ
So we connect the 100 kΩ Rf from V$_{out}$ to V$_−$, another 100 kΩ from ground to V+. Then we connect a 2 kΩ from R$_A$ to V$_−$, and another 2 kΩ from R$_B$ to V+.
If the input has a source impedance, the source impedance is part of the circuit. The 8 kΩ source impedance, plus the 2 kΩ physical resistors we added, give us a total of 10 kΩ between the ideal voltage source and the op amp input.

## Inverting summing amplifier

This is merely an Inverting Amplifier with extra inputs. The analysis is nearly identical but we have many currents equal to the feedback current. If we take a KCL at the Inverting input.
    $i_{n}+\cdots +i_{2}+i_{1}=-i_{f}$
The value of the currents can be determined by Ohm's Law using the fact that v$_d$ is zero for an ideal Op Amp.
    ${\frac {V_{n}}{R_{n}}}+\cdots +{\frac {V_{2}}{R_{2}}}+{\frac {V_{1}}{R_{1}}}=-{\frac {V_{out}}{R_{f}}}$
If $R_{n}=\cdots =R_{2}=R_{1}$ then
    ${\frac {1}{R_{1}}}(V_{n}+\cdots +V_{2}+V_{1})=-{\frac {V_{out}}{R_{f}}}$
    $A_{f}=-{\frac {V_{out}}{V_{sum}}}=-{\frac {R_{f}}{R_{1}}}$
Just as it is for the Inverting Amplifier.
Note: There is also a Summing Amplifier made using the Non-Inverting Amplifier configuration. The configuration is a bit more complicated and harder to use, since it requires an understanding of Superposition.

## Ideal integrator

The configuration is an Inverting Amplifier with the feedback resistor a Capacitor. The derivation proceeds the same.
    $i=-i_{f}$
    ${\frac {V_{in}}{R}}=-C{\frac {\;dV_{out}}{\;dt}}$
    ${\frac {V_{in}}{RC}}=-{\frac {\;dV_{out}}{\;dt}}$
Integrate both sides with respect to
    $V_{out}=\int _{t_{0}}^{0}-{\frac {V_{in}}{RC}}\,dt+V_{initial}$
Practically a Resistor is often connected in parallel with the feedback capacitor. This means that there is not infinite gain at very low frequencies, which makes the Real integrator much more stable.

## Ideal differentiator

The configuration is an Inverting Amplifier with a Capacitor as Resistor one so the derivation proceeds the same as before.
    $i=-i_{f}\,$
    $C{\frac {\;dV_{in}}{\;dt}}=-{\frac {V_{out}}{R}}$
    $V_{out}=-RC{\frac {\;dV_{in}}{\;dt}}$
This configuration is unstable for several reasons. The higher frequency inputs are going to have higher derivatives. Which means that circuit acts like a low pass filter, but more importantly this means that it will just saturate if a high frequency signal is put into the differentiator. This is also seen through the gain.
    $A_{f}=-{\frac {R}{1/j\omega C}}$
This means high frequencies mean high gain and thus saturation.
Practically a Resistor is often connected in series with the capacitor.