Jump to content
Electronics-Lab.com Community
Sign in to follow this  
windoze killa

Voltage level shifting

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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



post-8387-14279142711726_thumb.png

Share this post


Link to post
Share on other sites

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??

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Hi Staigen and Enac,
You are both right.
With input=5v, inv input=5v, output =5v and no current flows through the resistors.
With input = 2.5v, inv input=2.5v, output=0v because current flows through both resistors and giving equal voltage drop across each. So inv input is 2.5v below +rail (5v), and output is 2.5v below inv input.

EdwardM,
Your circuit is flawed because with R1=R2, the LH side of R3 is effectively sourced from 2.5v
When input=2.5v, inv input must be at 2.5v. So no current flows through R3 or R4 and output will be 2.5, whereas it should be 0v

Windoza,
This is such a simple circuit it cannot possibly fail. If you are still having trouble simulating it then either the simulator is handling the parameters of the opamp incorrectly, or it is selecting the wrong opamp. I cannot beleive the simulator has a fault - but worst things have happened.
Don't mess about with the simulator - just build it. It will work!

Share this post


Link to post
Share on other sites

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.



It sounds like you are connecting a sensor to the A2D on a micro. If this is the case, you do not need to waste your time converting the voltage. Just use what you have. Adjust the reference voltage on the micro if you need better resolution.
Also, if this is not your application, I think there would be an interest in what you are making. Please share with the forum if you are able to do so.

MP

Share this post


Link to post
Share on other sites

It sounds like you are connecting a sensor to the A2D on a micro. If this is the case, you do not need to waste your time converting the voltage. Just use what you have. Adjust the reference voltage on the micro if you need better resolution.
Also, if this is not your application, I think there would be an interest in what you are making. Please share with the forum if you are able to do so.

MP

You are partly right. This voltage will be fed into a micro but the I/P has to be 0V to 5V. The code in the micro is being used in many places and all the other inputs are 0V to 5V so we can't change the code just for this one. They are to be interchangable between each other.

I will give you a little bit more info for this project. I have a bunch of current sensors measuring various rails of a power supply. The current sensors have an O/P of 0V to 5V for the range of current. Unfortunately 0A equals 2.5V. Negative current is 0V to 2.5V and positive current is 2.5V to 5V. We are only interested in the positive bit. The problem is we need a current sensor that has a 5V supply and can handle 25A. These are the only ones available
in this range.

Share this post


Link to post
Share on other sites

Guess what. In the process of building up my circuit I have been informed (after 3 weeks of toil) that I can have a 10V rail and have to use an LM324. Not bad seeing I was supposed to have this design finished last week. Oh well back to the drawing board.

While i am trying to work this out I will be happy to accept any suggestions.

Share this post


Link to post
Share on other sites

Now you have said what the purpose of the project is, could I suggest an alternative?

How about a dedicated micro just for this data input. Input would be to the A/D convertor section of this micro reading the 2.5v to 5v. Compare the digital readings obtained with a lookup table that will give equivalent outputs in the range 0v to 5v. Then output that to an R2R ladder network to give D/A to go into your main micro. You can still use just the 5v supply.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...