# Electronics

## Opamp tutorial

### The summing amplifier

We saw that one of the operations an opamp can perform is scalar multiplication (amplification) of a signal. Now we'll see how an opamp can add multiple signal together.

There doesn't flow any current into the $V_+$ node, so when we choose $R1=R2=R3$ that node will show the average voltage of the three inputs. This can be easily shown using Kirchhoff's current law (KCL). So we can substitute the inputs: $$ V_+ = \dfrac{V_1 + V_2 + V_3}{3} $$ What we have now is simply the noninverting amplifier, so that $$ V_{OUT} = \left(1 + \dfrac{R5}{R4} \right) \cdot \dfrac{V_1 + V_2 + V_3}{3} $$ When we choose $R5 = 2 \cdot R4$ we get $$ V_{OUT} = V_1 + V_2 + V_3 $$ That's our summing amplifier. In general the values of the input resistors don't matter, as long as they're equal. Then in general: $$ \bbox[10px,border:2px solid #96BFCB]{ \large{ V_{OUT} = \left( \dfrac{R4 + R5}{N \cdot R4} \right) \cdot \Sigma V_i }} $$ When you choose $R5 = (N-1)\cdot R4$ for $N$ inputs this simplifies to $$ \bbox[10px,border:2px solid #96BFCB]{ \large{ V_{OUT} = \Sigma V_i }} $$

We also have an inverting summing amplifier:

To show how this works we'll use a property of the negative feedback opamp we saw earlier: that the opamp sets the output so that both inputs are equal. So $V_-$ is at 0 V *level*. It's at 0 V, but it's not ground. Being ground would mean the current would be drained back to the power supply. There doesn't flow any current into the opamp's inverting input, so all the current coming from the inputs must leave through feedback resistor $R4$. Since $V_-$ is at 0 V the current from each of the inputs is
$$ I_{Ri} = \dfrac{V_i}{Ri} $$
and if all the input resistors are equal
$$ I_{R4} = \Sigma I_{Ri} = \dfrac{1}{Ri} \cdot \Sigma V_i $$
Note that the current through $R4$ flows from 0 V to $V_{OUT}$, so $V_{OUT}$ will have the inverse sign from the inputs:
$$ V_{OUT} = - I_{R4} \cdot R4 $$
$$ \bbox[10px,border:2px solid #96BFCB]{ \large{ V_{OUT} = - \dfrac{R4}{Ri} \cdot \Sigma V_i }} $$
We can also simplify this by choosing all resistors equal:
$$ \bbox[10px,border:2px solid #96BFCB]{ \large{ V_{OUT} = - \Sigma V_i }} $$
If there's only one input we have the inverting amplifier we discussed earlier.

next: the difference amplifier