# Perform addition operation in analog computing?

In digital computing, addition operations are commonly performed using circuits composed of logic gates, such as the full-adder circuit, which combines multiple bits to generate a sum along with a carry-out bit. The full-adder circuit is foundational how CPU is created because Arithmetic Logic Unit (ALU) in CPU depends on that circuit. However, I'm curious about how addition operations are executed in analog computing, where values are represented continuously through voltages or currents.

About the representation of output values in analog addition operations. I understand that in analog world, the output voltage shouldn't exceed a certain voltage reference. Therefore, the input and output operations essentially involve mapping values. For instance, if a voltage reference is set to 1, and the operation 1 + 1 is performed, the output should be mapped to 1, despite the mathematical result being 2.

Here is a table with example values that illustrates the mapping between voltages and the gauges display, where VIN_A and VIN_B represent the operands of the addition operation, VOUT represents the result of addition operation, and GAUGE_A, GAUGE_B, and GAUGE_OUT represent the corresponding gauge device displays:

VIN_A VIN_B VOUT GAUGE_A GAUGE_B GAUGE_OUT
0 0 0 -10 -10 -20
0 0.25 0.125 -10 20 10
0 0.5 0.25 -10 50 40
0 1 0.5 -10 110 100
0.25 0 0.125 20 -10 10
0.25 0.25 0.25 20 20 40
0.25 0.5 0.375 20 50 70
0.25 1 0.625 20 110 130
0.5 0 0.25 50 -10 40
0.5 0.25 0.375 50 20 70
0.5 0.5 0.5 50 50 100
0.5 1 0.75 50 110 160
1 0 0.5 110 -10 100
1 0.25 0.625 110 20 130
1 0.5 0.75 110 50 160
1 1 1 110 110 220

So, what the circuit will be looks like to achieve relationship between VIN_A, VIN_B, and VOUT?

In general, arithmetic addition (and subtraction, which is merely addition of a negative) in analogue systems is trivial, since one of the key principles at work in such systems is the principle of superposition. It's how electricity works, and is the basis for laws such as Kirchhoff's Voltage Law and Kirchhoff's Current Law.

It means that currents add together at junctions, and voltages across components add together when they are joined end to end. Using these fundamental principles, it's easy to build circuits that add voltages or currents.

For instance, from your table, I gather that the relationship you require is:

$$V_{OUT} = \frac{V_A+V_B}{2}$$

That's what this circuit will do:

simulate this circuit – Schematic created using CircuitLab

Being entirely passive, this circuit imposes no constraints on the voltages at A or B, except the limits imposed by the resistors themselves. This design will work with inputs up to many tens of volts, and will handle negative voltages just fine.

Unfortunately, any load connected to OUT (such as a gauge) will probably draw current, which will influence $$\V_{OUT}\$$, so you may need to buffer the signal with a voltage-follower. I'll use an op-amp in that role:

simulate this circuit

This is no longer passive, and there are now constraints on the acceptable range of inputs, and the range of possible outputs, related to the power supply potentials of 0V and +5V shown here.

With the lower supply at 0V, the op-amp won't be able to output all the way down to exactly 0V, probably getting as far as +50mV or so, but not lower. If you need precision right down to 0V then you'll have to provide a negative supply to the op-amp:

simulate this circuit

The op-amp designs require that the op-amp's own input potentials never fall outside the supply range (that is, 0V to +5V, or -5V to +5V in last two schematics above). In fact, the LM358 shown, and many other models, won't be happy with inputs within 1.5V of the positive supply. $$\(+5V) - 1.5V = +3.5V\$$, so whatever you apply to A and B, make sure that $$\ \frac{V_A+V_B}{2} \$$ doesn't exceed +3.5V, or fall below 0V. If that's a problem, then increase the supply potentials, or choose a different op-amp model.

As long as you are careful about power supplies, and input and output constraints, you can get really creative using op-amps. I won't explain why, but the next circuit performs the function

$$V_{OUT} = -\left(\frac{1}{2}V_A + V_B + 2V_C \right)$$

simulate this circuit

That circuit both adds and inverts (negates), and if you haven't guessed already the coefficients $$\\frac{1}{2}\$$, 1 and 2 are determined by the ratios of the resistances.

As I pointed out before, the op-amp's power supply potentials impose limits upon what range of inputs are acceptable, and what output range you can expect. Here I am using ±12V supplies, and an LM358, so as long as you don't provide inputs that would map to an output outside the range -11.95V to +10.5V, it will work well.