11

I have a joystick that puts out analog voltage somewhere between 1.5V and 3.5V.

I want to transform this range of voltage to control a motor controller that takes analog voltage between 0V and 5V.

How do I level shift and amplify properly?

jfenwick
  • 221
  • 1
  • 2
  • 8
  • Is there no intermediary microcontroller? If so just use an ADC. – sptrks Apr 26 '12 at 05:24
  • 2
    I think you might want to elaborate on what exactly you want to do here. Are you trying to scale an analog voltage from 1.5V-3.5V to 0V-5V? Are you trying to convert an analog voltage to some digital output? – bjthom Apr 26 '12 at 05:27
  • A boost converter could help you in going from 3.5 V up to 5 V, but not in going from 1.5 V down to 0 V. Its gain is always greater than or equal to 1. – Telaclavo Apr 26 '12 at 09:21
  • 1
    @Telaclavo a boost is not useful here, since it's used for powering, but we assume he has a greater supply than 3.5 V. – clabacchio Apr 26 '12 at 09:23
  • @clabacchio I know what are boost converters used for. I wanted to point out to him that half of the equation is not only not recommendable, or not usually done that way, but impossible mathematically. – Telaclavo Apr 26 '12 at 09:27
  • @Telaclavo I understand your point. I just say that DC/DC converters are just to exclude, and you were just discouraging the use of a boost. I was trying to be more general about that, to avoid confusion. – clabacchio Apr 26 '12 at 09:32
  • 1
    We know that those are analog voltages. What is your supply? – clabacchio Apr 26 '12 at 09:37
  • Clabaccio < YOu have the right idea but the wrong IC TL082 will go 0.5 to 3.5V on 5V single supply I believe. Olin has the right design & the right chip MCP6041 with rail to rail out. and the right cct values . If using the MCP6042 dual OA, then you can use the spare for unity gain buffer for V/2 Ref. and then gain goes up a tad. ( from 2.475 to 2.500 +/- %R tolerances) but "close enuf for government work" using 100 KΩ & 152 KΩ Rocket did U really want to invert ? – Tony Stewart EE75 Apr 27 '12 at 06:06
  • The Opamp is not meant to be the right one, it's just the default for the simulator. And it's not sure that it won't work, because he may have a different supply. But thanks for the advice, I'll write a disclaimer. But you should post this as a comment. – clabacchio Apr 27 '12 at 06:16
  • i've got a question to Rocketmagnets circuit. I'm very new to electronic stuff and have builded a dynamic motion platform with arduino and wiper motors. The motors use a potentiometer for position feedback. The pots are turend about 180° so i get some range of about 1,6v-3,6 V so i treid to increase the voltage with this circuit. I've build this one like this http://www.x-sim.de/forum/gallery/image.php?image_id=2326 . I've checked the wireing many times and can't find an issue. I use 10k pots insteat of 1k maybe this is my problem? I'm using lm324N http://www.produktinfo.conrad.com/datenblaett – Thomas Nov 25 '13 at 18:08

3 Answers3

14

You want a simple gain of 5/2 = 2.5 centered around 2.5 V. This is easy assuming you have 5 V power available, like from the motor controller:

This needs to be a rail to rail output opamp that can run from 5 V power, like the MCP6041 and many others. R1 and R2 form a voltage divider to make the 2.5 V around which the input signal will be amplified. C2 attenuates noise from the 5V supply even more than the DC to make a quiet and smooth DC level. The opamp is in a classic positive gain configuration, with R4 and R3 setting the gain. The impedance of the 2.5 V source produced by R1 and R2 effectively add to R3 for the purposes of gain, but that is a small contribution of 1.2 kΩ on 100 kΩ. The gain will be slightly less than 2.5.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
  • 1
    +1. More precisely, rail-to-rail output (rail-to-rail input not needed here) – Jason S Apr 27 '12 at 15:59
  • @Jason - Fixed. – Olin Lathrop Apr 27 '12 at 16:06
  • How did you pick the values for R1 and R2? – abdullah kahraman Apr 27 '12 at 22:41
  • 1
    @abdullah: Since the supply is 5 V and the point is to make 2.5 V, one constraint was R1 = R2. The other choice was what the impedance of the 2.5 V source should be, which is R1//R2. Lower is better, but lower also means more current. I felt 100 kOhm was about as high as I wanted to go with R3 to keep stray noise pickup down. 1.2 kOhms seemed low enough impedance relative to that, and draws about 1 mA from the 5V supply, which sounded reasonable. – Olin Lathrop Apr 27 '12 at 23:22
  • @OlinLathrop thanks for the info. If the our power budget is tight, should we introduce a voltage follower for the 2.5V, using an another OP-AMP (in the same package maybe)? – abdullah kahraman Apr 27 '12 at 23:50
  • Opamps are new for me... I can see that R1 and R2 form a voltage divider. The differential amplifier takes in the joystick signal on 3(+) and the 2.5V signal on 2(-) and after following the differential amplifier math we get this: `Differential Amplifier: Vout = Ad(Vin+ - Vin-) Vout = Ad(3.5 - 2.5) = 1Ad Vout = Ad(2.5 - 2.5) = 0Ad Vout = Ad(1.5 - 2.5) = -1Ad` I'm assuming Ad = 5, which comes from 5V going into Vs+ and GND going into Vs-. But the level shift doesn't look right to me. The bottom is at -1Ad and the top is at 1Ad. Shouldn't Vin- be at 1.5 instead of 2.5? – jfenwick Apr 28 '12 at 23:16
  • Also I'm not clear on how R3 and R4 set the gain. I'm also a bit confused as to why at the top of the diagram, 5V and GND seem to come together and then go into Vs+. I would have thought just 5V should go in there. – jfenwick Apr 28 '12 at 23:20
  • 1
    @jfenwick: I can't tell what you think those equations mean without your properly defining terms, like "Ad". Also, it seems you may have missed the fact that there is negative feedback in this circuit, which sets the gain. The open loop gain of the opamp is so large as to not matter to the gain of the closed loop circuit. I don't see 5V and GND coming together anywhere. You'll have to be more specific with less waving of hands. – Olin Lathrop Apr 29 '12 at 00:54
  • @OlinLathrop Ad: "differential gain", I think this means gain in voltage to output, not sure how to calculate how much Ad is in this circuit. Vin+ is the the positive input on the op amp, which is where the output from the joystick goes. Vin- is where the 2.5V goes into. If you agree with all that, in the ideal case, the voltage range after the going through the op amp will be [-1Ad,1Ad]. I can't think of a value for Ad that could turn the Vout range into [0,5]. Maybe the feedback affects Ad in some way that I don't understand. How do you calculate the feedback? – jfenwick Apr 29 '12 at 02:05
  • @OlinLathrop I guess R4 provides a path for the Vout signal to create a feedback loop back into the Vin-, but I don't know what effect that has. – jfenwick Apr 29 '12 at 02:13
7

This is possible with only one op amp. What you're trying to do is level shift and amplify. We used to make these all the time. They're useful in robots where you have a sensor with a small analog voltage output range, and you want to expand the voltage swing so that you can get maximum resolution from your ADC.

We'd usually make them with variable offset and gain, so that we could adjust them for each sensor on the robot.

Op amp variable level shift and amplify

Having got your settings right, you could always measure the resistances of the pots, and used fixed value resistors instead.

Or you can calculate the values directly:

Op amp level shift and amplify

There's an online calculator to help you work out the resistor values.

Rocketmagnet
  • 26,933
  • 17
  • 92
  • 177
4

Contrarily to what Cybergibbons says, it's quite simple analog electronics. But you have to specify which supply you intend to use for your circuit.

You need a circuit which brings down your common mode signal (1.5 V) to 0, and applies a gain of 5/2 = 2.5 to the rest. You can easily do it with an Op-Amp based level shifter with some gain.

A solution is to use an analog subtractor with a reference voltage placed at 1.5 V, an even simpler solution is just a non-inverting amplifier with the reference in the right place.

This circuit will do the job:

enter image description here

The Opamp is just the default in the simulator, you may need another one, depending on the supply.

It's a non inverting amplifier with gain given by \$ \dfrac{R_1 + R_2}{R_1} \$, and the reference voltage makes the voltage shifting.

clabacchio
  • 13,481
  • 4
  • 40
  • 80
  • It's simple if you are just drawing a schematic - the complication comes with the requirement that the signal must go from 0-5V and it is an input to a motor controller. 0.05V isn't going to cut it - so it needs a split supply opamp. That means you need to provide a split supply, which is a lot of additional effort. – Cybergibbons Apr 26 '12 at 06:46
  • @Cybergibbons not so much, depending on what he's got; and, using rail-to-rail op-amps, he might also do the job without it. – clabacchio Apr 26 '12 at 07:07
  • Possibly. I've been taught that relying on rail to rail performance is a bit of a no no for control for a few reasons. Firstly, rail to rail is never really rail to rail - the best performing opamps get to around 10mV or so, which can cause problems. Second, they aren't that linear in that region. Third, if you load the output the rail to rail performance gets much worse (a motor control may load the output - we don't know). Of course, if the motor controller has a dead band it doesn't matter. – Cybergibbons Apr 26 '12 at 07:28
  • @Cybergibbons well, about the degradation of performance, you may be right (I don't know) but Analog Devices has rail-to-rail op-amps which go to about 2-5 mV (max) from the rails. But this problem doesn't exist if he has 12 V supply for instance, so it's dependent on how he wants to supply it. About the driving capability, he can use another op-amp to buffer the signal, as long as he has the right supply. – clabacchio Apr 26 '12 at 07:34
  • @Cybergibbons - Is it any more likely that a processor PWM output pin will go to within 10mV of ground - even at 0% duty cycle? – MikeJ-UK Apr 26 '12 at 09:10
  • @MikeJ-UK Yes, PWM will give you perfect 0 V (if the load is connected to ground) and almost perfect 5 V (the deviation being the load current times the PMOS on resistance). – Telaclavo Apr 26 '12 at 09:18
  • @MikeJ-UK I would expect PWM to give between 10 and 50mV on most microcontollers when using a highish VCC like 5V. – Cybergibbons Apr 26 '12 at 09:28
  • @Cybergibbons No, if the load only sinks current (it does not source any current), a 0% duty ratio PWM will create a perfect 0 V output, because no current will create any drop across the NMOS on resistance. – Telaclavo Apr 26 '12 at 09:31