Let's go back to the inverting amplifier. In its original form, we had
one input resistance, one feedback resistance and one input voltage; but
what happens if we have two or more inputs?
The math goes like this:
Vrin1 = Vin1 - Vinv
The inverting terminal is at the same potential as the non inverting, which is tied to ground, so:
Vrin1 = Vin1
Then separate Vrin into current times voltage, according to ohm's law:
IinRin1 = Vin1 => Iin1 = Vin1/Rin1
But then again, we have more than one input, so for any Nth input, we have
IinRinNth = VinNth => IinNth = VinNth/RinNth
And the voltage at the feedback resistor, same as before
Vfb = Vinv - Vout
Separate by ohm's law
IfbRfb = Vinv - Vout
Ifb = (Vinv - Vout)/Rfb
Since the inputs try to draw no current, the current through the
feedback resistor must be equal to the sum of the currents through each
input resistor, by kirchoff's laws.
Ifb = Iin1 + Iin2 + ... + IinNth
In terms of the voltages and resistances
(Vinv - Vout)/Rfb = Vin1/Rin1 + Vin2/Rin2 + ... + VinNth/RinNth
Let's simplify to just two inputs, this can be expanded to more if needed; the equation holds true for more inputs.
(Vinv - Vout)/Rfb = Vin1/Rin1 + Vin2/Rin2
Since we are interested in the output voltage, the equation is solved for it
Vinv - Vout = (Vin1/Rin1 + Vin2/Rin2) Rfb
- Vout = (Vin1/Rin1 + Vin2/Rin2) Rfb - Vinv
(-1)(- Vout) = [-1][(Vin1/Rin1 + Vin2/Rin2) Rfb - Vinv]
Vout = -(Vin1/Rin1 + Vin2/Rin2) Rfb + Vinv
Vout = Vinv - (Vin1/Rin1 + Vin2/Rin2) Rfb
The voltage at the inverting input will be the same as the voltage at
the non inverting, which is tied to ground, so this becomes
Vout = - (Vin1/Rin1 + Vin2/Rin2) Rfb
If we assume equal resistors
Vout = - (Vin1/R + Vin2/R) R
Vout = - (Vin1 + Vin2) (R/R)
Vout = - (Vin1 + Vin2) (1)
Vout = - (Vin1 + Vin2)
Notice how the output is the inverse of the sum of the voltages. This
happens because we are using an inverting amplifier base, so as expected
the output is inverted. Also note that the ratio of input and feedback
resistors also set the gain by multiplying the sum by the ratio of
resistances; if all input resistances are the same the gain is
controlled by the feedback resistor.
Another variation of this circuit is using different input resistors for
each input voltage, thus creating a weighted sum, useful in some very
simple digital to analog conversion circuits.