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?
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?
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.
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.
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:
There's an online calculator to help you work out the resistor values.
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:
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.