Voltage level shifting

windoze killa

Mar 4, 2006
136
Joined
Mar 4, 2006
Messages
136
I am try to work out how to take an I/P voltage that is between 2.5V and 5V and produce an O/P of 0V to 5V. I only have a +5V supply to work with which is where I am having the problem. I have tried everything but just can't come up with an answer.

There has to be someone that can trip over an answer.

 

EdwardM

Apr 12, 2005
246
Joined
Apr 12, 2005
Messages
246
Hi wk

with this sort of problem you have to start with the transfer function. In this case you are transferring an input of between 2.5 and 5v into an output of 0 to 5v and it should be linear, ie Vout = m*Vin+C. (The equation for a straight line).

So m will equal the slope of the line (5-0)/(5-2.5) = 2 and C from the same formula = -5 after plugging-in the value of m.

Vin            Vo=2*Vin -5

2.5                  0
3.0                  1
3.5                  2
4.0                  3
4.5                  4
5.0                  5

You then need an Opamp circuit to achieve this transfer function: see attached .png

It would be a good idea to use an Opamp designed for single supply, rail to rail use and values of R1 to R4 (to start experimenting) are 1K1, 1K, 9K, 10K.

Hope I've got this right  ???

Best of Luck

Ed

View attachment 38599

 
Last edited by a moderator:

windoze killa

Mar 4, 2006
136
Joined
Mar 4, 2006
Messages
136
Thank you. I think that is so close to what I have been trying to do. Will give it a try during the week.

 

windoze killa

Mar 4, 2006
136
Joined
Mar 4, 2006
Messages
136
I haven't been able to build this but have tried to sinulate it in Altium designer. It gives a steady output of 120mV. I have tried to vary the values but it stays at a steady O/P around 100 to 150mV. My OP AMP theroy is obviously very depleted. Any more suggestions or variations??

 

Staigen1

Oct 26, 2003
695
Joined
Oct 26, 2003
Messages
695
Hi windoze killa and EdwardM

There must be something wrong with the picture and the resistors here!
R1=1K1? R2=1K R3=9K? R4=10K?

Instead R1 should be 0(short), R2 omitted, R3=R4
And the IC an ideal rail to rail one, else there should be a resistor in the +input too(R3/2)

//Staigen

 

windoze killa

Mar 4, 2006
136
Joined
Mar 4, 2006
Messages
136
Still have a steady DC output but this time it varies withe the value of the 2 resistors and the load resistor. My head hurts.

 

Staigen1

Oct 26, 2003
695
Joined
Oct 26, 2003
Messages
695
Hi

and the load resistor
Load resistor? What load resistor? There is no load resistor!

Use 3 resistors, R1, R2 and R3. R1=R2=lets say 100K and R3=50K
Connect one end of R1 to +5V and the other end to the -input of OP-amp.
Connect one end of R2 to the -input of OP-amp too and the other end to output of OP-amp.
Connect one end of R3 to the +input of OP-amp and the other end to Vin.
Use a OP-amp that can go rail to rail!
Thats it! :)

//Staigen
 
Last edited by a moderator:

windoze killa

Mar 4, 2006
136
Joined
Mar 4, 2006
Messages
136
Well we need a load resistor. This shall be driving into an analog I/P of an AVR.

With a load of 100K I get an steady O/P of 1.5V.
1M gives an O/P of 0V
No load gives an O/P of 5V

This doesn't make sense. I am obviously missing something. I shall pull out that dusty 20yo book and read some more.

 

EdwardM

Apr 12, 2005
246
Joined
Apr 12, 2005
Messages
246
Hi Chaps

R1 and R2 provide an offset voltage of about +2.5v (your minimum input), this means you need something more positive than that at the non-inverting input to make the output voltage rise above 0v. The value of all the resistors is almost immaterial provided that they maintain the same ratio.

With a bit of good luck and a following wind, it ought to work.

Best of Luck

Ed

PS If you are interested in the theory behind this, I'd suggest you read chapter 4 of OP AMPS for EVERYONE it's freely available on the web.

 

pebe1

May 3, 2004
45
Joined
May 3, 2004
Messages
45
windoze killa said:
Well we need a load resistor. This shall be driving into an analog I/P of an AVR.

With a load of 100K I get an steady O/P of 1.5V.
1M gives an O/P of 0V
No load gives an O/P of 5V

This doesn't make sense. I am obviously missing something. I shall pull out that dusty 20yo book and read some more.
I gave you the same answer as Staigen's on another forum.
Trust him. It will work!
 

windoze killa

Mar 4, 2006
136
Joined
Mar 4, 2006
Messages
136
Thanks Pebe but I am not denying that it may work. It just doesn't seem to work in Altium designer simulation. When you pay $10K for a program you expect it to work. I am still obviously missing something.

I have also put your other simpler single amp into Altium as well and it doesn't seem to work either. I can see I am going to have to do this for real. I was trying to save time and money and use the tools we have at our call but obviously I am doing something wrong. Also my OP AMP theroy is a little rusty. I will certainly be posting the results here so you know how I go.

Even if I don't get this solved thanks to everyone thats tried.

 

pebe1

May 3, 2004
45
Joined
May 3, 2004
Messages
45
windoze killa said:
Thanks Pebe but I am not denying that it may work. It just doesn't seem to work in Altium designer simulation. When you pay $10K for a program you expect it to work. I am still obviously missing something.

I have also put your other simpler single amp into Altium as well and it doesn't seem to work either. I can see I am going to have to do this for real. I was trying to save time and money and use the tools we have at our call but obviously I am doing something wrong. Also my OP AMP theroy is a little rusty. I will certainly be posting the results here so you know how I go.

Even if I don't get this solved thanks to everyone thats tried.
Even if the Altium isn't simulating with a rail-to-rail op-amp, it should give results that are pretty close. I've not used the package so I don't know. I would try it for real.
 

EdwardM

Apr 12, 2005
246
Joined
Apr 12, 2005
Messages
246
Hi wk

I now realize I was being a bit lazy about the circuit I described, I used an online opamp calculator to provide the starting values but they aren't quite correct.

What I have done is obtained some AD8601 rail-rail single supply opamps and did a quick build using a 500K pot as the feedback element and a 50K pot to derive the reference. 

The reference was set to about 4.75v and the feedback set (by eye) at about 1:1, and lo and behold it did work.

Put in 2.5v and you get 0v out, put in 5v and you get 5v out.  Unfortunately, I don't have the time to produce a graph to prove that the transfer function is linear, however, it should be and I leave it others who may have the time to carry it forward.

Best of Luck

Ed

 

Staigen1

Oct 26, 2003
695
Joined
Oct 26, 2003
Messages
695
Hi Edward

Hehe, have you been lazy again, this must be totally wrong!
When the input is 2.5 Volt, the output saturate at 0 Volt!
When the input is 5 Volt, the output saturate at 5 Volt!
And the scale between that is not linear!
But the choice of op-amp seems to be exellent! ;D

To windoze killa:
Wich op-amp did you use when you simulated the cirquit?
Did it have rail to rail output possibillitys?
Did it have input common mode that include the positive rail?

To pebe:
What do you think?

//Staigen

 

EdwardM

Apr 12, 2005
246
Joined
Apr 12, 2005
Messages
246
Hi Staigen

don't think so...

I shifted the input gradually from 2.5v to 5v and got a gradual change of output from 0v to 5v which was the original requirement, this led me to believe that my original equation might be correct.

Do let us know why you think that it's not linear.

As you rightly say, "when the input 2.5v the output saturate at 0v" It is a rail to rail opamp with a single supply of 5v so that's what I'd expect to happen.

And, "When the input is 5volt, the output saturate at 5 volt" ... Yes, also.

"And the scale between is not linear", please explain - there are no reactive components in the circuit which would cause this nonlinearity.

Thanks for agreeing that the opamps I bought to prove the circuit seem to be excellent.

Ed

 

Staigen1

Oct 26, 2003
695
Joined
Oct 26, 2003
Messages
695
Hi Edward

When you start to rise the input from 2.5V the output is still at a saturated
0V, i havent calculated when the output start to rise! When the input voltage
come near 5V the output saturate against 5V, i havent calculated that voltage
either!

//Staigen

 

Enac

Mar 4, 2004
12
Joined
Mar 4, 2004
Messages
12
Forgive me if one of you guys already suggested this solution.
All you need is two equal-valued resistors and a rail-to-rail I/O op amp. One resistor (Rs) goes from +5V to the inverting input. The other (Rf) goes from the inverting input to the output. The 2.5V-5V input signal goes on the noninverting input.

The transfer function is Vout = Vin*(1*Rf/Rs) - 5V*(Rf/Rs).

 

Staigen1

Oct 26, 2003
695
Joined
Oct 26, 2003
Messages
695
Hi

All you need is two equal-valued resistors and a rail-to-rail I/O op amp.
As i suggested, roughly!

And what do you say pebe?

Anyone else?

//Staigen
 

windoze killa

Mar 4, 2006
136
Joined
Mar 4, 2006
Messages
136
Hi wk

I now realize I was being a bit lazy about the circuit I described, I used an online opamp calculator to provide the starting values but they aren't quite correct.

What I have done is obtained some AD8601 rail-rail single supply opamps and did a quick build using a 500K pot as the feedback element and a 50K pot to derive the reference.
 
Top