# Op-amp - Converting a negative ramp to a positive ramp

I want to try and measure that output with an ADC, which has a 0-3.3 V range.

I want -10 V to be 0 V, +10 V to be 2.5 V, and 0 V to be 1.25 V.

Right now, I have -10 V = 5 V, 0 V = 2.5 V, 10 V = 0 V (I can handle just a simple voltage divider to halve the range)

This is the circuit I have now:

simulate this circuit – Schematic created using CircuitLab

I figure that there's some difference amplifier circuit I can use, but my knowledge of these analog circuits is lacking.

On the board, I have spare op-amps, as well as a 1.25 V reference to use.

Here is an easily editable simulation of the circuit.

This resistor divider gets you close:

simulate this circuit – Schematic created using CircuitLab

A sweep of V1 from −10V to +10V outputs 0V to +2.22V:

If you want the full 0V to +2.5V, you'll need some gain $$\A\$$:

$$A = \frac{2.5}{2.22} = 1.125$$

In this next design, the op-amp is configured as a non-inverting amplifier with gain 1.125. The overall response to inputs from −10V to +10V is an output going from 0V to +2.5V:

simulate this circuit

Sadly, that would require a negative supply for the op-amp, because it cannot get all the way to 0V output without one. If you want to use 0V for the negative supply, you'll have to sacrifice a few tens of millivolts at the bottom end.

simulate this circuit

Note that I've increased R2 slightly, to raise the minimum potential at X to a little over 0V. Since this also increases maximum potential there, I've also had to reduce gain a little. For inputs between -10V and +10V, this last design will output +30mV to +2.5V:

• +1 for showing that some things can be done just using resistors (almost). Feb 20 at 19:28

As per RusselH's suggestion below, here's the improved version:

simulate this circuit – Schematic created using CircuitLab
The output is no longer reversed, but follows the input, except scaled & shifted from -10V ... +10V to 0V ... +2.5V (roughly).

If you can live with the ramp being reversed, so -10V gets translated into +2.5V and +10V gets translated into 0V, then you can do it with a single opamp.
You could easily reverse it back again in your MCU's code.

simulate this circuit

The inverting gain of 0.12 isn't perfect, but it gets you to within about 50mV at each end.

The output offset is set by Vref, scaled by R1 & R2, and multiplied by the non-inverting gain: $$\1 + \frac{R3}{R4}\$$

so:
$$\(\frac{Vref . R1}{R1 + R2}).(1 + \frac{R3}{R4})\$$

= $$\(\frac{1.25 . 10k}{10k + 1.2k}).(1 + \frac{1.2k}{10k})\$$

= $$\(1.116) . (1.12)\$$

= 1.25V

• This is a differential amplifier. Lift R1 from ground. Connect to V1+. Lift R4 from V1+. Connect to ground. Then the polarity is correct. Feb 28 at 20:26
• @RussellH thx for the hint - updated my answer accordingly. Feb 28 at 20:56

I'd start with reducing the gain using a simple potential divider like this: -

• negative 10 volts in maps to -1.25 volts out
• positive 10 volts in maps to +1.25 volts out

So, all you have to do is add an offset like this: -

And, you get what you want.

Of course this task is made easier by using a standard voltage reference such as +2.5 volts and attenuating it to +1.42857 then adding an op-amp buffer before connecting it to R1.

Here is a way that uses only two standard values of resistors and your present op-amps.

Note the need for a negative supply for the op-amps, however -5V is adequate. The worst-case output voltage of U1 is -1.25V at +10V input. With your idea of buffering it first, you'd need something like -12V to handle a -10V input. If you don't have a negative rail, you could use something like a 7660 charge pump to generate it from +5V.