2
\$\begingroup\$

I'm trying to find a simple way to convert a 0-5 V output from a joystick hall effect sensor to +2.5 -- 0 -- +2.5 V. Here's how I want the response to look:

enter image description here

The output voltage will be sent to a frequency converter and on to a stepper motor driver. I want to have the same voltage at both extremes so the frequency (motor speed) is the same regardless of the positive or negative direction of the joystick. I intend to use a comparator at the zero point (with an appropriate deadband) to reverse the direction of the stepper driver.

I've thought of a few ways to accomplish this, but none seem to be particularly straightforward:

  • Create a second, inverted output from the sensor and switch the input source (via comparator and mux) to the frequency converter at the 2.5 V midpoint. This would provide 2.5-0 V from the inverted output and 0-2.5 V from the original output.
  • Shift the 0-5 V range to -2.5-2.5 V and then use an absolute value circuit to invert the negative portion of the output.
  • Generate a bias voltage, based on joystick position, and add/subtract it from the sensor output.

Ideally, I'd like to have a single input to the frequency converter instead of trying to switch it to another source, such as an inverted output. The second idea above would satisfy that preference, but it would require a negative voltage source. Also, I'm trying to use discrete components in this design, so a microprocessor isn't an option for me.

Is there an easier way to accomplish this task? The problem seems fairly straightforward, but I'm having trouble coming up with a simpler solution. I appreciate the help.

\$\endgroup\$
  • \$\begingroup\$ Welcome to EE.SE. It is best to level shift after the joystick using op-amps and resistor dividers or a TL431 2.5 volt ref. Or use -2.5V for one side, so the joystick has a mid-position with zero volts. \$\endgroup\$ – Sparky256 Nov 9 '18 at 2:03
  • \$\begingroup\$ @Sparky256 Thanks, glad to be here! Just to clarify my post, all of the level shifting ideas I had would be happening after the joystick. The hall effect sensor takes a specific input voltage and only outputs 0-5 V based on the mechanical position. For that reason, it's a little less flexible than a potentiometer joystick where I could manipulate the voltage levels at the two legs of the pot. \$\endgroup\$ – higrafey Nov 9 '18 at 2:51
  • \$\begingroup\$ What are you using as the voltage to frequency converter? \$\endgroup\$ – τεκ Nov 9 '18 at 4:06
  • \$\begingroup\$ @τεκ I'm planning to use an LM331. \$\endgroup\$ – higrafey Nov 9 '18 at 13:09
1
\$\begingroup\$

I'd use the absolute value circuit and a subtractor to shift the output to the 0-2.5V range. Jasen's answer provides an absolute value circuit I've used before and which should work here. I'd follow that with an op amp difference amplifier with a gain of 1.

You'll need a 2.5V reference for both the absolute value circuit and the difference amplifier. You can either use a simple resistor divider from your positive power supply (which I would buffer with another op amp) or a 2.5V reference IC.

Here's a schematic which you can simulate (I assumed a 5V supply was available for the 2.5V reference):

schematic

simulate this circuit – Schematic created using CircuitLab

I didn't pay much attention to the resistor values -- I just made sure they have the right ratios. You'll know better what values work in your application. Similarly, I just used a generic op amp.

A DC sweep of the input from 0V to 5V produces the following outputs for the absolute value circuit (in orange) and the difference amplifier (blue):

DC sweep

Since there are four op amps you might be able to use a single quad op amp IC. Or, if you use a 2.5V reference IC (so you only need 3 op amps), you could use a dual op amp IC for the absolute value circuit and a single for the difference amplifier.

\$\endgroup\$
  • \$\begingroup\$ That's a really nice solution. I wasn't aware that the absolute value circuit would also work on non-negative inputs. I like that this solution can be handled with just one quad op amp IC. Thanks for the clear explanation and circuit simulation! \$\endgroup\$ – higrafey Nov 10 '18 at 15:16
4
\$\begingroup\$

Here is one way to do it that uses a cheap quad op amp and a bunch of 100K resistors (and operate from a single +5V supply):

schematic

simulate this circuit – Schematic created using CircuitLab

OA1 provides the two reference voltages used from the supply.

OA2 subtracts the input voltage from 2*1.25V to give the left part of the output.

OA3 subtracts 2.5V from the input voltage for the right part of the output (both saturate at 0V with a single 5V supply, so no diodes are required).

OA4 sums the two to give the desired output voltage.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ This could definitely work for me, especially being able to fit in a quad op amp package. Thanks for including a simulation and a step-by-step description of how the circuit works. There sure are a lot of resistors :) but I like how the summing and subtraction roles are clearly defined at each stage of processing. \$\endgroup\$ – higrafey Nov 10 '18 at 15:26
1
\$\begingroup\$

the circuit you want is an "absolute value circuit"

enter image description here

but to get the vee shape you'll need 2.5V on the non-inverting input of the first op-amp.

\$\endgroup\$
  • \$\begingroup\$ I think what you are proposing will end up with the output never being below 2.5 V, which isn't what OP asked for. But if you included a schematic of the actual proposal it would be more clear. \$\endgroup\$ – The Photon Nov 9 '18 at 2:29
  • \$\begingroup\$ Close. But I think the second stage has to have a gain of 2 and should be biased off 3.75 \$\endgroup\$ – Edgar Brown Nov 9 '18 at 5:09
1
\$\begingroup\$

I can see a possible solution with a super-diode circuit biased at 2.5V and a couple of extra op-amps to invert the signal and add it back to the input with the proper gain.

However, at that point I have to ask: “is that really more efficient than a tiny micro controller?”

A 6-pin microcontroller with no external components can perform this function AND directly provide you with the output frequency. Thus removing the need for yet another IC.

\$\endgroup\$
  • \$\begingroup\$ I'll have to read up on super diodes, but at first glance they look pretty clever. Would this approach require a negative supply voltage? Can you post a circuit and/or go into a bit more detail as to how this might work? \$\endgroup\$ – higrafey Nov 9 '18 at 13:31
  • \$\begingroup\$ I agree that a microcontroller is probably the more efficient approach. Doing it with discrete components is more of an educational thing in my case. (I did actually try this with an Arduino, with some admittedly crappy code, and the transitions were very slow at the lower frequencies due to the sensor being sampled at the same rate as the output frequency. This could surely be fixed with more thoughtful coding, though.) \$\endgroup\$ – higrafey Nov 9 '18 at 13:32
  • \$\begingroup\$ @higrafey the basic idea is already in @Jasen’s answer. It only requires a couple modifications. \$\endgroup\$ – Edgar Brown Nov 9 '18 at 17:08
1
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Opposing magnets will give a null point in the centre of stroke.

If your joystick is amenable to modification you may be able to generate the required response by replacing the one magnet with two opposing magnets separated by the stroke of the movement.

  • With the joystick in mid position the magnetic fields will cancel out.
  • Moving to either end of travel will increase the flux from the respective magnet and increase the output.
  • It may be simplest to adjust for an output voltage > 2.5 V and attenuate it with a resistor divider.

Get out the hot-melt glue gun!

\$\endgroup\$
  • \$\begingroup\$ Clever idea! That would be the ideal hardware solution, I think. The joystick can actually be configured by the manufacturer with a variety of output options, but the 2.5 V "vee" isn't one of them. The closest I can get is 0-5 V from a primary sensor and 5-0 V from a secondary sensor, with 2.5 V at the midpoint. Your trick would be a neat option to have. Thanks for the idea! \$\endgroup\$ – higrafey Nov 10 '18 at 15:21
0
\$\begingroup\$

Connect a VCO to the raw input and beat the output against a fixed oscillator, send the beat frequency to the stepper driver.

you could also beat agaisnt a quadrature of the fixed oscillator and get the other phase for your stepper drive that way, and not need a stepper driver :)

\$\endgroup\$
  • \$\begingroup\$ I am not sure that the filter you would need would be feasible, but I guess that depends on what is the minimum frequency. \$\endgroup\$ – Edgar Brown Nov 9 '18 at 5:14
  • \$\begingroup\$ Interesting idea. Would this approach still give me the same frequency at the positive and negative ends of the joystick stroke? Seems like I would need to feed the VCO the same voltage at either extreme, which is the situation I'm encountering with the V/F converter and my chart above. \$\endgroup\$ – higrafey Nov 9 '18 at 13:14
  • \$\begingroup\$ @EdgarBrown I'm shooting for a frequency range of 0-112 Hz, so it's pretty low. Fed through a 400 step/rev motor at 16:1 microstepping, this gives me just over 1 rpm. \$\endgroup\$ – higrafey Nov 9 '18 at 13:17
  • \$\begingroup\$ properly adjusted it'd give +112 Hz at one end and -112 Hz at the other end. you could amplify it and drive a stepper motor directly. \$\endgroup\$ – Jasen Nov 10 '18 at 5:47

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.