# Choose the resistence with voltage divider sensor

I'm on voltage dividers circuits for reading some sensors that changes their resistance (force sentive resistor).

With my tester (with input scale set on 200K ohms) I read 23 if sensor is not touched and 65 if the sensor is touched at maximum.

Now, I'm trying to read it with a microcontroller and with a 220 ohms resistor (red red brown) i read values from 7 (not touched) to 1 (touched). With a 1000 ohms (brown black red) i read values from 40 (not touched) to 15 ( touched).

I would like to get the best from this sensor and this microcontroller (it could read analog values from 0 to 1023) and I want to calculate the best resistor for get the best result and the biggest range of values i can.

Can someone point me out?

Ah, I once wrote an absolutely fantastic answer :-) for that!

I found that you get the maximum output range if the series resistor is equal to

$R_S = \sqrt{R_{MIN} \times R_{MAX}}$

You'll have to admit that this just looks beautiful. So for your sensor that would be

$R_S = \sqrt{23 k\Omega \times 65 k\Omega} = 39 k\Omega$

If you feed the resistive divider with the ADC's reference voltage you'll get readings of 380 and 640 for 23 kΩ and 65 kΩ, resp. That's a range of 260 discrete values, or a 0.4 % resolution. You can't get better than that without amplification or a higher voltage difference across the resistive divider.

Note that using the same supply for the divider and the ADC's reference the reading is completely independent of voltage variations!

• yeah, i definitly have to admit it! :) – nkint Jul 23 '12 at 16:52
• @stevenvh, yea the equations are pretty, but my graphs are pretty nice too! :p – vicatcu Jul 23 '12 at 17:02
• @vicatcu - very thoughtful to make a version for Australia and one for the Northern Hemisphere :-) – stevenvh Jul 23 '12 at 17:05
• @stevenvh See? I knew that australia would come in handy! – W5VO Jul 23 '12 at 18:06
• @W5VO - Haha! Good one! – stevenvh Jul 23 '12 at 18:11

The equation for a voltage divider with R1 connected to Vcc and R2 connected to GND, and R1 and R2 connected to each other is:

V_out = Vcc * R2 / (R1 + R2)

You could formulate this as an optimization problem and start taking derivatives and stuff, but I find the brute force graph approach to be more instructive.

You know the minimum value you read from your force sensor was 23kOhms and the maximum value you read from your force sensor was 65kOhms. Assuming your force sensor is R2, then the range of values you will get for Vout for a range of R1 looks like this at the high and low ends of R2: ... and likewise if you flip the divider around and vary R2 you get: Long story short, your best bet is something around 40kOhms for the range of resistances you have empirically measured.

The resistive solution is the simplest, but it is not linear as the resistance varies: The above is a simulation using a 5V supply, the 39k from Stevens answer as the top resistor and varying the bottom resistor (the sensor) from 23k to 65k. Note the graph is curved rather than straight. This may not matter for your application, but if it does you will need to compensate in the firmware.

Another way of doing things would be to use a current source in place of the top resistor: Here are the results for the same sweep as before (supply still 5V): You can see the result is much more linear. This is only to illustrate the concept, Q1 can be any general purpose PNP, D1 and D2 can be just about any silicon diode, and you can alter R3 for your desired constant current:
I = (VD1+VD2-Vbe) / R3 -> (0.6 + 0.6 - 0.6) / 12k = ~50uA. This is pretty rough, so you may need to trim (you can use a trim pot for R3 if you wish)

If you want a very reliable current source, then you can use an opamp instead of the transistor: The idea is basically the same as the transistor, just using an opamp. Iout = V+ - Vref / R2.

• You've got a point, iff the sensor has a linear characteristic. In this answer I show that a non-linear characteristic may be converted to a very good linear approximation (over a 30 °C range) by adding just that series resistor. In this case a current source will look bad. – stevenvh Jul 23 '12 at 18:28
• @Steven - Yes, that's another nice and simple option, but will be more sensitive to supply variations. Linearity should be better than the simple PNP source though (a cascode would be better) The opamp source would be best. – Oli Glaser Jul 23 '12 at 18:45
• Au contraire! If the divider uses the same supply as tha ADC's reference voltage it's completely insensitive to voltage variations! – stevenvh Jul 23 '12 at 18:57
• Good point, if it does share the supply and the ADC is not e.g. driven from a buffered reference. Also, depending on decoupling and layout, the (short term) variations may not be exactly the same, so I wouldn't say completely insensitive ;-) – Oli Glaser Jul 23 '12 at 19:01