9
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ Is there no intermediary microcontroller? If so just use an ADC. \$\endgroup\$ – sptrks Apr 26 '12 at 5:24
  • 2
    \$\begingroup\$ 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? \$\endgroup\$ – bjthom Apr 26 '12 at 5:27
  • \$\begingroup\$ 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. \$\endgroup\$ – Telaclavo Apr 26 '12 at 9:21
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – clabacchio Apr 26 '12 at 9:23
  • 1
    \$\begingroup\$ We know that those are analog voltages. What is your supply? \$\endgroup\$ – clabacchio Apr 26 '12 at 9:37
11
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ +1. More precisely, rail-to-rail output (rail-to-rail input not needed here) \$\endgroup\$ – Jason S Apr 27 '12 at 15:59
  • \$\begingroup\$ @Jason - Fixed. \$\endgroup\$ – Olin Lathrop Apr 27 '12 at 16:06
  • \$\begingroup\$ How did you pick the values for R1 and R2? \$\endgroup\$ – abdullah kahraman Apr 27 '12 at 22:41
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – Olin Lathrop Apr 27 '12 at 23:22
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – Olin Lathrop Apr 29 '12 at 0:54
6
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Correct, but he needs to provide his supply voltages \$\endgroup\$ – clabacchio Apr 26 '12 at 12:12
  • \$\begingroup\$ @clabacchio - True. But I think we can assume there's 5v available. \$\endgroup\$ – Rocketmagnet Apr 26 '12 at 12:30
  • 4
    \$\begingroup\$ Note that this inverts. That could be a issue in the user interface if the joystick has to be moved opposite from the intuitive direction to make higher motor speed. \$\endgroup\$ – Olin Lathrop Apr 26 '12 at 12:34
  • \$\begingroup\$ Thanks for pointing out that this is called level shifting. \$\endgroup\$ – jfenwick Apr 27 '12 at 18:04
4
\$\begingroup\$

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_2} \$, and the reference voltage makes the voltage shifting.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Cybergibbons Apr 26 '12 at 6:46
  • \$\begingroup\$ @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. \$\endgroup\$ – clabacchio Apr 26 '12 at 7:07
  • \$\begingroup\$ 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. \$\endgroup\$ – Cybergibbons Apr 26 '12 at 7:28
  • \$\begingroup\$ @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. \$\endgroup\$ – clabacchio Apr 26 '12 at 7:34
  • \$\begingroup\$ @Cybergibbons - Is it any more likely that a processor PWM output pin will go to within 10mV of ground - even at 0% duty cycle? \$\endgroup\$ – MikeJ-UK Apr 26 '12 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.