# Reading a potentiometer with an unknown voltage

I have a potentiometer that ranges from 0-400kΩ. One pole is connected to a supply of unknown voltage (but it's in the neighborhood of 12-14V: it's a vehicle power supply). The other pole is connected to my circuit. I would like a circuit whose voltage varies from 0 to 3.3V based only on the value of the potentiometer, for feeding into a microcontroller. That is, varying the supply voltage should not affect the output voltage.

Of course, this would be trivial if the supply voltage were fixed: just use a voltage divider! The untrustworthy supply (which I can't rewire) makes it much more challenging, however. I suspect that this simply cannot be done with simple resistors.

How should the "black box" in the schematic below be wired?

simulate this circuit – Schematic created using CircuitLab

(this all is assuming you intend the pot to be 0 to 400kOhm as seen from V-pow wire, with no access to the centre tap, that's how I interpreted it. If you have access to the centre tap other cool tricks are available as well)

This should give a high degree of power supply noise rejection, as long as it is above, say 5V:

simulate this circuit – Schematic created using CircuitLab

The local stable is also allowed to be 5V, that doesn't matter much.

Q1, Q2, D1 and R1 form a current drain that pull a constant current through the external resistor R2. This current should be in the range of 2.5μA to get a range of 0V to 1V over the resistor R2.

The resistor R1 will have the same voltage across it (forced by Q1) as the diode D1. Assuming a voltage of 0.7V, the resistor should be 280k to get 2.5μA. It's very likely the diode will only have 0.6V across it, in that case R1 needs to be 240k. For any other voltage things may need some more tuning.

The current drain pulls a constant voltage across R2, if R2 is only 200k, the voltage will be 0.5V. If it's 400k it will be 1V, if it's 100k it will be 0.25V. Etc.

So the range of voltages between the supply and the resistor contact is 0V to 1V after you tuned R1 to a good resistance.

OA1 acts as a 3.3times difference amplifier. To show that, assume the supply to be 10V (low battery / starting engine):

V+ = 33kOhm * (10V / (10kOhm + 33kOhm) ) =~ 7.674V.

The negative will be held at approximately 7.674V as well, because of the negative feedback, ignoring the effects of R5 and R6 on the voltage at the connection with R2 that means with R2 being 400kOhm (and thus the incoming wire from R2 at 9V):

V(R5) =~ 9V - 7.674V =~ 1.326V

Which causes a current to flow, that will induce a voltage drop in R6 of:

V(R6) = 3.3 * V(R1) =~ 4.374V

This means that the output will be at:

Vout = V- - V(R6) = V+ - V(R6) =~ 7.674V - 4.374V = 3.3V

If the R2 is 0kOhm, the incoming voltages will be the same, so the output needs to be 0V, to get V- the same as V+. Any value between, as can then be seen, will create a voltage between those two extremes.

Of course, you could see that R5 and R6 will pull some extra current through R2, so this will be slightly inaccurate. The leak in this set-up is not constant, this will cause some non-linearity in the response, but the full ADC range can be used if you tune R1 using the output voltage at R2 maximum.

The totality of behaviour of this circuit, once tuned, is stable over all source voltages that fall within the capability of the op-amps, with a minimum of about 5V.

If you need more linearity in the response, you can find a good enough rail-to-rail op-amp and buffer the R2 voltage:

simulate this circuit

The OA2 is a simple voltage follower, and R5 and R6 can now decrease in value, which can benefit noise immunity.

As a last note: If it is truly a vehicle supplying the voltage, you should consider some input protection as spikes and load dumps can go very, very high and be dangerous to any circuit you apply to get your voltages. If you protect your circuit against high spikes, you will also need to add a little capacitance to the incoming leg of R4, at the least, to get some of the influence of the spikes and noise out of it, or you will also be seeing that noise and those spikes as signal.

• Please do explain; I'm curious how this works. Commented Jul 19, 2015 at 23:25
• @thirtythreeforty Done Commented Jul 19, 2015 at 23:30

Your schematic doesn't look correct- presumably the 0-14V comes off the wiper of the pot and the pot is effectively connected across the vehicle supply.

simulate this circuit – Schematic created using CircuitLab

You could perhaps derive the ADC reference from the vehicle supply, or simply measure it and correct the reading from the pot by doing a digital division.

The voltage follower buffers shown are optional if the micro is happy with the relatively high source impedance of the divider. For example if you use 499K and 137K to get 0-15.3V in for 0-3.3V out, the source impedance will be more than 100K.

An actual block that gives a fixed voltage for a ratio of two input voltages would require an analog divider (or a multiplier and an op-amp) as well as a reference voltage. That would be possible, but a very expensive way to solve the problem.

• Ah, you're correct about the pot, thanks. I'm fine with using even 4.9K and 1.3K resistors to be able to omit the buffers, because the micro does need a relatively low resistance. I do think just measuring the unknown voltage is probably the cheapest way (not sure why I didn't think of it! :). Does Asmyldof's answer illustrate the alternative you mentioned? Commented Jul 19, 2015 at 23:06
• Since the pot is 400K, the total resistance of R2 and R3 should be more than 1 megohm to avoid loading the pot excessively. Does the pot serve some vital function in the car controls? If so, I would avoid doing anything that could affect safety or engine operation. Commented Jul 19, 2015 at 23:13
• @PeterBennett is correct- the resistors should be kept fairly high. The values I suggested would change the pot voltage by about -1V worst-case (affecting the linearity by < 10%). Using higher values would likely be required if the signal goes somewhere else. Commented Jul 19, 2015 at 23:21
• @PeterBennett, the pot represents the position of the wiper delay knob. I suspect it's also rated pretty highly, because the current for the motor runs through the switch (!) in the original design. Commented Jul 19, 2015 at 23:23
• @thirtythreeforty Through the switch, as in through the potentiometer? Because then I seriously doubt it being 400k. I'm probably misunderstanding you, but if you do mean that, with 400k the wiper motor would only get micro-watts for the majority of the range. Commented Jul 20, 2015 at 0:06

I think what you want is a Wheatstone bridge.

• Hmm, but how would the microcontroller control the fourth leg to measure? Commented Jul 19, 2015 at 23:00
• I believe you leave it fixed and you measure the voltage instead of adjusting the resistor to zero the reading. I believe the point of it is that the voltage should not vary with the supply voltage, in principle. Commented Jul 20, 2015 at 3:39