# Voltage subtractor using op-amp

I'm trying to design a circuit that produces $$V_{\mathrm{out}}=\begin{cases}V_{\mathrm{in}}-V_{\mathrm{cc}}/3 & V_{\mathrm{in}}>V_{\mathrm{cc}}/3\\0 & V_{\mathrm{in}}

I expected the circuit above to produce the result. However, the SPICE simulation (LTspice) and building the real circuit shows that $$V_-\approx1.5\,V\ne V_+$$ causing high output voltage.

What'd be the problem here?

• Re your edited question: is the single-supply a hard requirement? May 30, 2020 at 22:17

By inspection (using superposition), I get that (assuming ideal op-amp)

$$V_{OUT} = 0.75\cdot \left(1 + \frac{100}{150||300}\right) - 9\cdot\frac{100}{300}$$

$$= 0.75\cdot 2 - 9\cdot\frac{1}{3} = -1.5 \mathrm{V}$$

But, in your schematic, the op-amp cannot produce a negative output voltage. Assuming that it can drive the output to zero, we have

$$V_- = 9\cdot \frac{150||100}{150||100 + 300} = 1.5 \mathrm{V}$$

as you observe.

• Why do you use such low resistor values in the voltage dividers? May 30, 2020 at 18:44
• @Audioguru, I've cancelled the common $k\Omega$ unit for each resistance. That is,$$\frac{100k\Omega}{150k\Omega || 300k\Omega} = \frac{100}{150||300}$$ May 30, 2020 at 19:01

To implement a circuit that meets what you want from your formula in terms of absolute values then you will need to use an actual differential amplifier circuit and respect the virtual ground in a system with both a positive and negative supply. The fundamental circuit can be like the following:

Picture Source

A realistic realization of your equation can be as following this LTSpice simulation.

With this circuit with Vin set at 3V will result in an output at near 0V for a Vcc or 9V. Similarly with Vin set at 1V the output would be at -2V.

• Single-supply operation might be a requirement. I've asked OP in a comment. May 30, 2020 at 22:19

Vcc=9V offers +3V to the inverting input of your opamp. The +input gets 0,75V. To get in balance the opamp should output a negative voltage which should draw the voltage in the minus input to 0,75V. You have no negative supply voltage to make it possible.

Insert a negative supply voltage to the opamp or use so high minimum Vin that no negative output is needed. That minimum is +3V with Vcc=+9V as your equation shows.

The CircuitLAB in this site shows it works perfectly as long as no negative output is expected:

Vcc is in the simulation named V1 and Vin is sweeped from 0 to +12V. The name of Vin is V2.

Nothing guarantees the output goes zero accurately enough if you have some load which tends to pull the output up. The existing parts (in the simulation R1, R2, R3, V1) do not cause a pull-up which is visible in my simulation output, but your case can be different, so negative supply voltage can still be needed.

• My mistake. My intention was to output zero when the input voltage is less than one third of VCC.
– ylem
May 30, 2020 at 18:40