Converting 0-2.5-5 voltage to 5-0-5 voltage

Hightower1027

Joined Dec 23, 2021
9
I have a hall effect single axis joystick that outputs 0-5V from backwards to forwards (2.5V at center). I need it to output 5V when back, 0V at center, and 5V when forward. I believe this can be done with op amps and/or resistors but haven't found a great solution yet. Can someone help provide a solution?

sghioto

Joined Dec 31, 2017
5,110
but haven't found a great solution yet.
Doesn't look logical in a linear output.
0 volt default = 5 volt desired
5 volt default = 5 volt desired

crutschow

Joined Mar 14, 2008
33,363
I have a hall effect single axis joystick that outputs 0-5V from backwards to forwards (2.5V at center). I need it to output 5V when back, 0V at center, and 5V when forward.
What power supplies do you have available?

With a 5V supply I have a circuit that goes to about 4.5V output max.
Would that be okay?:

Last edited:

Hightower1027

Joined Dec 23, 2021
9
What power supplies do you have available?
Right now just 24V and 5V.

BobTPH

Joined Jun 5, 2013
8,117
Offset and scale this output with another opamp and you are there:
Any rail-to-rail opamp will work. The input is a ramp from 0 to 5V.

crutschow

Joined Mar 14, 2008
33,363
Below is the sim of a precision rectifier with offset circuit, using rail-rail op amps supplied with 5V.
Since all the resistors are the same value, you could use a matched resistor array.

Its max output with 0v input is a little over 4.5V due to the forward drop of diode D1.
Is that acceptable?
Edit: If not, then you could use an LM317 or LM78xx to generate a 6-12V supply for the circuit from the 24V supply to get the full 5V output (with a corresponding change is some of the resistor values).

Last edited:

sghioto

Joined Dec 31, 2017
5,110
Offset and scale this output with another opamp and you are there
Added -5 volt reference and summing amp circuit for full 5 volt output at 0 volts Vin.

crutschow

Joined Mar 14, 2008
33,363
Below is my previous circuit with an LM317 regulator powered by the 24Vdc supply, configured to generate V+ = 10Vdc, which allows a full 0 to 5V output for both 0V and 5V inputs (if needed):
Resistor R7 was added, and several resistor values changed to accommodate the new voltage.

sghioto

Joined Dec 31, 2017
5,110
My version using a MCP6004 or two MCP6002 with 5 volt Vcc and rail to rail output.

Last edited:

BobTPH

Joined Jun 5, 2013
8,117
My circuit with the added scaling and offset.

Needs only 5V supply and two opamps. The feedback and divider for the second opamp need to have a variable resistor to calibrate it for 0V and 5V.

crutschow

Joined Mar 14, 2008
33,363
My version using a MCP6004 or two MCP6002 with 5 volt Vcc and rail to rail output.
Below is the LTspice sim of your circuit.
I didn't have the MCP6004 model, so I used the LMV358 dual CMOS RR out, (LMV324 quad).

My initial sim with the values for R1 and R3 on your schematic (R2 and R9 below) gave a small asymmetry at the output.
I assume you just made a mistake in the calculation for those, as you need 1.25V from the divider.
The values below give 1.25V, giving the desired output.

sghioto

Joined Dec 31, 2017
5,110
Theoretical 1.25 is correct. After actually breadboarding the circuit needed to reduce to 1.20 volts for zero output at 2.5 volt in.

crutschow

Joined Mar 14, 2008
33,363
Theoretical 1.25 is correct. After actually breadboarding the circuit needed to reduce to 1.20 volts for zero output at 2.5 volt in.
That's a fairly significant 4% difference.
Do you know why that was?
Is it from resistor tolerances or op amp offset?

crutschow

Joined Mar 14, 2008
33,363
sghioto, your circuit can be simplified some by eliminating one op amp and its two resistors (below).
But that really only saves the two resistors, since you already have the four op amps:
Edit: Since the resistors are all 10kΩ or multiples of that, you could use 10kΩ matched resistor array(s) to minimize the number of parts.

Last edited:

sghioto

Joined Dec 31, 2017
5,110
Do you know why that was?
Is it from resistor tolerances or op amp offset?
I believe it was from output offset. I'll check again.

Last edited:

crutschow

Joined Mar 14, 2008
33,363
I believe it was from output offset. I'll check again.
Double check all the resistor values.

sghioto

Joined Dec 31, 2017
5,110
Double check all the resistor values.
All the resistors were 5% rated but all read within 1%. Was actually using two MCP602 chips and swapping the two around improve the offset.
Then I wired your mod of my circuit and with 0 volts at the + input on U3 had a 100mv offset on the output. That was the same amount I read before on my circuit with the same chip. Replaced U3 with another chip and offset dropped to appx 5mv.

crutschow

Joined Mar 14, 2008
33,363
My circuit with the added scaling and offset.
You need to lighten the blue trace on your sim graph as it's essentially invisible on my computer (or maybe that's just my computer ).

My only quibble with your design is that is depends upon the matching of two diode forward-drops over current and temperature, as they are not inside a feedback loop.

ElectricSpidey

Joined Dec 2, 2017
2,636
@crutschow

Would you mind confirming the operation of your circuit in post #7.

When V(in) is at 0 volts U1 output is at 5 volts trying to place the minus input at 2.5 volts.
As V(in) rises the output of U1 lowers to try to keep the minus input at 2.5 volts.
When V(in) exceeds 2.5 volts the upper output transistor goes open and the lower transistor closes completely, but the diode blocks any further feedback at that point and the input to U2 starts to follow V(in) exclusively.

U2:
When the voltage at the plus input is 5 volts the output goes to 5 volts to place the minus input at 5 volts.
Then when the input is at 2.5 volts the output must be 0 volts to place the minus input at 2.5 volts.

Is that essentially correct? If not, can you please explain.

Thanks