Operational amplifiers were originally developed for analog mathematical calculations, and since then they have proven useful in many design applications. As my professor put it, op amps are arithmetic voltage calculators, they can perform the addition of two given voltage values ​​using a summing amplifier circuit and the difference between the two voltage values ​​using a difference amplifier. In addition to this, operational amplifiers are also commonly used as inverting amplifiers and non-inverting amplifiers.

In this tutorial, we will learn how to use an operational amplifier as a difference amplifier to find the voltage difference between two voltage values. It is also known as a voltage subtractor. We will also try out the voltage subtractor circuit on a breadboard and check that the circuit works as expected.

Basics of Operational Amplifiers

Before we dive into differential op amps, let’s take a quick look at the basics of op amps. The operational amplifier is a five-terminal device (single package) with two terminals (Vs+, Vs-) used to power the device. Of the remaining three terminals, two (V+, V-) are used for signals, called inverting and non-inverting terminals, and the remaining one (Vout) is an output terminal. The basic symbol of an operational amplifier is shown below.

The working of an operational amplifier is very simple, it receives different voltages from two pins (V+, V-), amplifies it by a gain value and takes it as an output voltage (Vout). Op amps can have very high gain, making them suitable for audio applications. Always remember that the op amp’s input voltage should be lower than its operating voltage. To learn more about operational amplifiers, check out their use in various operational amplifier-based circuits.

For an ideal op amp, the input impedance will be very high, i.e. no current will flow into or out of the op amp through the input pins (V+, V-). To understand how an op amp works, we can broadly divide op amp circuits into open loop and closed loop.

Op Amp Open Loop Circuit (Comparator)

In an open loop op amp circuit, the output pin (Vout) is not connected to any input pin, i.e. no feedback is provided. In this open loop condition, the op amp acts as a comparator. A simple op-amp comparator is shown below. Note that the Vout pin is not connected to input pins V1 or V2.

In this case, if the voltage supplied to V1 is greater than V2, the output Vout will go high. Likewise, if the voltage supplied to V2 is greater than V1, the output Vout will go low.

Operational Amplifier Closed Loop Circuit (Amplifier)

In a closed-loop op amp circuit, the output pin of the op amp is connected to either input pin to provide feedback. This feedback is called a closed-loop connection. During closed loop, the op-amp acts as an amplifier, in this mode the op-amp can find many useful applications such as buffer, voltage follower, inverting amplifier, non-inverting amplifier, summing amplifier, differential amplifier, voltage subtractor, etc. . If the Vout pin is connected to the inverting terminal, it is called a negative feedback circuit (as shown below), and if it is connected to the non-inverting terminal, it is called a positive feedback circuit.

Differential Amplifier or Voltage Subtractor

Now let’s get into our topic, the differential amplifier. A differential amplifier basically takes two voltage values, finds the difference between those two values ​​and amplifies it. The resulting voltage can be obtained from the output pin. A basic differential amplifier circuit is shown below.

But wait! This is not what an op amp does by default, even though it has no feedback, it takes two inputs and provides their difference on an output pin. So why do we need all these fancy resistors?

Yes, but an op amp will have very high uncontrolled gain when used in open loop (no feedback), which is really useless. So we use the above design to set the gain value using a resistor in the negative feedback loop. In our circuit above, resistor R3 acts as a degeneration resistor and resistors R2 and R4 form a voltage divider. The gain value can be set by using the correct resistor value.

How to set the gain of the differential amplifier?

The output voltage of the differential amplifier shown in the figure above can be given by

Vout = -V1 （R3/R1） + V2 （R4/（R2+R4））（（R1+R3）/R1）

The above formula is obtained from the transfer function of the above circuit using the superposition theorem. But let’s not dwell on that too much. We can further simplify the above equation by considering R1=R2 and R3=R4. so we will get

When R1=R2 and R3=R4, Vout = (R3/R1)(V2-V1)

From the above formula we can conclude that the ratio between R3 and R1 will be equal to the gain of the amplifier.

Gain = R3/R1

Now, let us substitute the resistor values ​​for the above circuit and check if the circuit works as expected.

Simulation of Differential Amplifier Circuit

The resistor values ​​I chose were 10k for R1 and R2 and 22k for R3 and R4. The same circuit simulation is shown below.

For simulation purposes, I provided 4V for V2 and 3.6V for V1. According to the formula, resistors 22k and 10k will set the gain to 2.2 (22/10). So the subtraction will be 0.4V (4-3.6) and will be multiplied by the gain value of 2.2 so the resulting voltage will be 0.88V as shown in the simulation above. Let’s also verify this using the formula we discussed earlier.

When R1=R2 and R3=R4, Vout = (R3/R1)(V2-V1)

= （22/10）（4-3.6）

= （2.2） x （0.4）

= 0.88v

Testing the Differential Amplifier Circuit on Hardware

Now comes the fun part, let’s actually build the same circuit on a breadboard and check if we can get the same result. I’m building a circuit using an LM324 op-amp and using a breadboard power module we built earlier. The module can provide both 5V and 3.3V outputs, so I use the 5V rail to power my op-amp and the 3.3V rail for V1. Then I use my RPS (Regulated Power Supply) to provide 3.7V to pin V2. The difference between the voltages is 0.4 and we have a gain of 2.2 which should give us 0.88V which is exactly what I get. The image below shows the setup and the multimeter, which reads 0.88V.

This proves that our understanding of differential op amps is correct, and we now know how to design our own op amp with the desired gain value. The full work can also be found in the video given below. These circuits are more commonly used in volume control applications.

However, since this circuit has resistors on the input voltage side (V1 and V2), it cannot provide very high input impedance and also has high common-mode gain, resulting in a low CMRR ratio. To overcome these shortcomings, a makeshift version of a differential amplifier called an instrumentation amplifier exists, but let’s leave that for another tutorial.