I'm very new to electronics, but I'm trying to reverse the signal coming from a throttle position sensor as well as change the voltage range slightly. The throttle position sensor output signal range is 0.325v-4.75v. How can it be converted to a 4.5v-0.38v signal? I found a similar question on here, but I don't know what would need changed to fit my situation (Reversing a .5-4.5V analog sensor output to 5V-0V) or (How to invert a digital signal). I was told maybe a NPN transistor could be used??? But what size and what size resistors in the circuit to get the range to change? Thanks for any help!

  • \$\begingroup\$ Link to the other question, please. Put it in your question rather than in the comments so that others have all the info they need in the question. Welcome to EE.SE. \$\endgroup\$ – Transistor Mar 29 '16 at 23:36
  • \$\begingroup\$ @transistor I edited my question with the link to the similar question. Thank you \$\endgroup\$ – Nick M Mar 29 '16 at 23:43
  • 1
    \$\begingroup\$ Got it. Your signal is not classed as digital but rather as an analog signal as the voltage is "analogous" to the position of the throttle. A simple NPN transistor circuit won't work in this case. Tell your source that "a rail-to-rail op-amp configured in inverting mode about a 2.5 V offset should do the trick." If you read my answer below a few times you might actually understand what you're telling him. ;^) \$\endgroup\$ – Transistor Mar 30 '16 at 0:08

Use the same circuit as in the answer you linked to. In your case the maths is easier because it's an almost straight inversion.

For an inversion about a 2.5 V offset just change R2 to 100k. How it works:

  • The op-amp (operational amplifier) is wired as an "inverting amplifier" with its gain calculated by \$ -\frac {R2}{R1} \$ and with equal values for R1 and R2 the gain is -1.
  • The signal is inverted around the voltage set on the op-amp '+' input. R3 and R4 are equal so pin 3 is held at half-supply = 2.5 V. C2 holds that voltage steady in the event of any noise on the 5 V supply. C1 performs a similar function for the whole op-amp.

If you find that the controller isn't quite giving zero speed or full speed then increase the gain a little by increasing the value of R2 by adding series resistance to bring it up to 105 to 120 kΩ. The worst that will happen is that you will have a little "dead-zone" at one or both ends of the throttle. This will result in having to turn a few more degrees before the motor starts or / and reaching full power before the throttle is fully rotated. This will be better than not being able to fully reach zero or full power.

The MCP606 is chosen because it is a rail-to-rail op-amp. This means that it can control its output all the way from the negative rail (0 V) to the positive rail (5 V in your case) unlike some other op-amps which can only get within a volt or two of each rail.

More maths:

The full equation for the configuration is given by

$$ V_{OUT} = -(V_{IN} - V_3)G + V_3 = -(V_{IN} -V3) \frac {R_2}{R_1} + V_3 $$

where \$ G \$ is the gain and \$V_3\$ is the voltage on pin 3.

Let's sort out the gain, G, first.

The throttle position sensor output signal range is 0.325v-4.75v. How can it be converted to a 4.5v-0.38v signal?

From the data you provided the input span is 4.75 - 0.325 = 4.425 V and the output span is 4.5 - 0.38 = 4.12 V. So the gain we require is \$ \frac {SPAN_{OUT}}{SPAN_{IN}} = \frac {4.12}{4.425} = 0.931 \$ as you calculated in the comments. We can pop this value back into our equation:

$$ V_{OUT} = -0.93(V_{IN} - V_3)G + V_3 = -0.93 V_{IN} + 1.93 V_3$$

Solving this for \$ V_3 \$ gives

$$ V_3 = \frac {V_{OUT} + 0.93 V_{IN}}{1.93} $$

Putting in the values for one end of the throttle we get

$$ V_3 = \frac {4.5 + 0.93 \cdot 0.325}{1.93} = 2.49 V $$

Double-checking with the readings for the other end of the pot:

$$ V_3 = \frac {0.38 + 0.93 \cdot 4.75}{1.93} = 2.49 V $$

Bingo! 2.49 is 0.4% off 2.5 V so we'll go with 2.5 V which is conveniently half the 5 V supply. Set R3 and R4 to 10 kΩ.

  • \$\begingroup\$ Thank you very much! I will let my source know about this :) \$\endgroup\$ – Nick M Mar 30 '16 at 0:11
  • \$\begingroup\$ Thanks for the quick "accept" of my answer. You are generally advised to wait 24 h or so to see if a better answer comes along or if someone smarter spots a big flaw in my solution. If it does happen you can select the other answer. Welcome to EE.SE. Good first question. +1. \$\endgroup\$ – Transistor Mar 30 '16 at 0:18
  • \$\begingroup\$ I've been trying to study this and figure out how it all works and do the calculations, but I think I'm doing something wrong. Using the math in the answer in that other link I believe that the exact gain should be -0.931. I found this by finding the difference of the input range (4.75-0.325=4.425) and the difference of the output range (4.50-0.38=4.12). Then 4.12/4.425=0.931. If I take the formula V-out=Gain*(V+ - V-), then I get 5.16 V that needs to come from the voltage divider, which doesn't make sense \$\endgroup\$ – Nick M Mar 30 '16 at 19:01
  • \$\begingroup\$ Perfectly correct on your calculations for the gain of -0.931. So if we go for a gain of -1 that would be 7% or 3 or 4% dead zone at each end of the throttle which you would be very unlikely to notice. Your resistors, power supply voltage and throttle will all have a tolerance so my approach would be to try it out and adjust if required. I monitor the site regularly so ask another question if you get stuck. \$\endgroup\$ – Transistor Mar 30 '16 at 19:23
  • \$\begingroup\$ As a matter of interest, is the throttle from an electric bike? Have you got a part number? There's a small chance that you can reverse the output by reversing the polarity of the magnet but the mechanisms can be difficult to reassemble. \$\endgroup\$ – Transistor Mar 30 '16 at 19:26

By reversing the magnet position (the magnet is inside the throttle, the throttle needs to be dismantled, which isn't difficult). The poles will change (north with south) and you will have almost 5v at beginning and drop to 0.8v at max.

  • \$\begingroup\$ Welcome to EE.SE. That doesn't always work. How do I know? I tried it. Please capitalise and punctuate your sentences properly. It's site policy. See Write to the best of your ability on the site's help pages. \$\endgroup\$ – Transistor Apr 2 '19 at 21:13

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.