Thanks Bob. I thought he wanted a few steps to switch automatically in. How can one opamp do this without intervention?

Thanks

Adam

Start with the differential amp configuration of an opamp.

The equation for a differential amp is:

Vout = (Vin+ - Vin-) * g

So if you want to convert the range (V1 to V2) to the range (V3 to V4), put in the two endpoints to the equation above to get two equations: Because the voltage range is being inverted, we are going to feed the input voltage to Vin-. So our two equations are:

V3 = (Vin+ - V1) * g

and

V4 = (Vin+ - V2) * g

First, lets calculate the gain:

Subtract second equation from first to get:

V3 - V4 = (Vin+ - V1) * g - (Vin+ - V2)g

V3 - V4 = g*Vin+ - g*V1 - (g*Vin+ -g*V2)

V3 - V4 = g*Vin+ - g*V1 - g*Vin+ + g*V2

V3 - V4 = g*V1 - g*V2

V3 - V4 = g(V1 - V2)

(V3 - V4) / (V1 - V2) = g

Now substitute g back into either equation to get Vin+, which is the bias voltage we will put on the non-inverting input.

So, let's do an example.

Map a voltage ranging from 1 to 2 onto a voltage ranging from 5 to 3.

i.e.

V1 = 1

V2 = 2

V3 = 5

V4 = 3

So:

g = (V3 - V4) / (V1 - V2) = 2 / -1 = -2

So now we make Vin- the input voltage Vin and we make Vin+ the bias voltage Vb.

From the original equation:

Vout = (Vb - Vin) * g

We use 2 for the gain since we have reversed the two inputs.

Vout = (Vb - Vin) * 2

Substitute in the V1 for Vin and V3 for Vout:

5 = (Vb - 1) * 2

5 = 2 * Vb - 2

7 = 2 * Vb

3.5 = Vb

To check our work, let's also substitute the other end of the range. I.e. make V2 Vin and V4 Vout:

3 = (Vb - 2) * 2

3 = 2 * Vb - 4

7 = 2 * Vb

3.5 = Vb

Eureka!

So we make a differential amplifier with a gain of 2. Put the input voltage to the inverting input, and a bias voltage of 3.5V on the non-inverting input.

Let's see how that works out in LTSPICE. Input is blue, going from 0 to 1V, output is green, going from 5 to 3V.

Now, the biasing for the + input is just a voltage divider that is going to put 3.5V * 2 / 3 on the + input. So we can actually do this with a voltage divider from V+ to ground, as well. We need:

3.5V * 2 / 3 = 2.33V.

So We need a divider with a ratio of 2.33 / 10 = 0.233

So R2 / (R1 + R2) = 0.233

Set R2 to 10K

10K / (R1 + 10K) = 0.233

10K = 0.233 R1 + 2.3K

7.7K = 0.233 R1

7.7K / 0.233 = R1 = 33K

Sure enough:

Bob