Resistor to math calculation

r2 and r3 are not fixed, and can be any value.

That equation gives the value of r1 and r3 in parallel, which they are not. Doesn't the fact that r3 is pulled down 4.7 volts further than r1 make a difference?

Or are you saying I can count them in parallel, and then calculate them to be pulled down to the average of 4.7 and 0 (2.35 volts)?

mattallen37: So assuming all resistors were 10k, how would I calculate the voltage of "n volts"?

...

mattallen37: r2 and r3 are not fixed, and can be any value.

The problem seems to be changing on the fly here.

Back up a tad further in the first post:

...r2 and r3 can be whatever. I would probably go with 10k for each.

r1 is 10k...

...So assuming all resistors were 10k, how would I calculate the voltage of "n volts"?

...r2 and r3 can be whatever. I would probably go with 10k for each.

r1 is 10k...

...So assuming all resistors were 10k, how would I calculate the voltage of "n volts"?

With the only voltage source defined in the circuit is the +4.7 from the pull-up on R1, then a DVM meter measuring point 'N' will read +2.35, assuming all resistors are 10K ohms.

R1 and R3 form a simple voltage divider cutting the voltage down by 50%, R2 will have no effect if measuring the voltage at the top of R2 assuming a standard volt meter impedance of 10 megohms.

But somehow I don't think that is what you are looking for, as I don't think you have stated the 'problem' correctly or completely. Is point 'N' is going to be a source of voltage input into the network, or a measurement point only?

"5 - 9.4" = "n Volts", which is the voltage to be measured. ADC is the measurement point.

Voltage measuring with NXT ADC.jpg|361x213

In the above circuit, when n=5V, ADC = 4.85V. When n=9.4V, ADC = 7.05V

Disregard... Late night calculations don't work.

Hmm. I just set up a test on a breadboard and measured this:

n     meter
n/c   2.35
5     3.26
6     3.60
7     3.93
8     4.29
9     4.60
9.4   4.72

I did a simulation using Circuit Wizard :

At 5 V = n Vout = V adc = 3.23 V All R1, R2 and R3 is 10 K and V at R1 is 4.7 V

At 9.4 V =n Vout = V adc = 4.7 V. hum... what if ... N = 10 Vout = 4.9 V

I change R2 to 6.2 k. , R1 = 10 K , R3 = 10 K

at n = 10 V, V adc = 4.07 V

at n=9.4 V , V adc = 3.9 V

at n= 5 V , V adc = 2.68 V

@Nick Gammon

You are close... XD

@Techone:

Thanks for that!

After carefully adjusting my test voltages by measurement rather than relying on the readouts of the power supplies, I indeed get 3.23 on the meter for a 5V value of n.

More precise readings:

n     meter
n/c   2.35
5     3.23
6     3.56
7     3.90
8     4.23
9     4.56
9.4   4.70

@Nick Gammon

I change R2 to 6.2 K. In case the input go above 10 V, at least the output will not reach so close to 4.7 V <-- the ADC limit.

It seems to me on inspection that my figures are pretty linear. That is, ADC = (n - 5) * 0.33 + 3.23. So you could solve that for n.

It's an interesting little problem you got there.

First off, you should make R2 and R3 as small as possible compared to R1. Of course there is the current consumption/power to regard as well, but say 1/10th-ish of R1. Because then the fixed voltage of 4.7V won't have so much to say, so to speak, on the result (IE the ADC voltage is more closely R2/(R2+R3) * n Volt, but not exactly - also it will be more linear (I think, but not completely linear anyway).

Continuing on what MarkT was on track of, this needs some of Thevenin's genius (or was it Norton? - either way works); any network of voltage sources and resistors, can be replaced by an equivalent circuit consisting of one voltage source and one resistor in series. Or the "opposite" method (Norton/Thevenin, not the above, I can't remember atm), replace it with an equivalent current source in parallel with one resistor.

Treat the three resistors in steps. Using the first method (voltage source equivalents):

First, disregard one of them, for example R1. Then:

E1 = n * R3 / (R2 + R3) Re = R2 || R3, or R2*R3/(R2+R3)

Where: n = the unknown voltage E1 = an equivalent voltage source Re = Equivalent internal resistance for this voltage source.

If R2 = R3 then E1 is simply half of n Volts.

Then there is the complication of R1 and 4.7V (source E2 below). Now this is the situation: (bad ASCII schematics coming up)

    .------------------[ R1 ] -----,
   |                                |
   |                .----[ Re ]------+--o ADC
   | +             | +
-------        -------
  ---  E2       --- E1
   |  4.7V       |
   |             |
    `-----------+----------------- GND

Shorting (theoretically speaking! :P) the voltage sources one at a time, then calculating the resultant voltage in the new resistor divider of Re and R1, and then simply adding the voltages should give the answer at point ADC. IE:

Calculating equivalent voltage sources yet again: E3 = E1 * R1 / (R1 + Re) and E4 = E2 * R2 / (R1 + Re)

Then VADC = E3 + E4.

However, this is what's measured, and you know that. You need to shuffle the formula around to get to Vn.

Expanding it a little:

VADC = ( (E1*R1) + (E2*Re) ) / (R1 + Re) VADC = ( ( ((Vn * R3 / (R2+R3)) *R1) + (E2*Re) ) / (R1 + Re)

As I'm a little rusty and lazy, I let Wolfram Alpha solve for Vn :) (I had to change some variable names to make it work, it seems Wolfie there assumes any e is euler's e, and/or some other things too)

So if I have done all this correct, it seems that the voltage at point n is:

Vn = ((R2+R3)*(R1*VADC + Re (VADC - E2))) / (R1*R3)

But, if those 4.7 volts are the results of say a germanium diode in series with a 5V source (about .3V drop), I don't think this will be correct all the time.. but I'm not sure how to compensate for that situation. Probably divide it even more, depending on if the diode conducts or not.

If all the resistors are the same then symmetry makes the solution easy, the ADC voltage is just the mean of N, 0 and 4.7, ie 1.567 + N/3

MarkT: Nice! That was somewhat simpler :P (Wolfram seems to agree.)

Also, if only R2 and R3 are the same, it becomes this, or in plain text:

Vn = (2*R1*VADC + R3*VADC - R3*V2) / R1 where V2 = 4.7V. Not as simple and elegant, but might be useful.

[quote author=Nick Gammon link=topic=93679.msg704922#msg704922 date=1330235699] That is, ADC = (n - 5) * 0.33 + 3.23. So you could solve that for n. [/quote]

If you factor my measured formula out you get:

ADC = 0.33 * n - (5 * 0.33) + 3.23
3 * ADC = n - 5 + (3.23 * 3)
3 * ADC = n + 4.69
ADC = (n + 4.69) / 3

Looks like my observations were out by 0.01 volts.

So to solve for n:

n = (3 * ADC) - 4.7

It's nice to see the theory agreeing with the observations! Thanks MarkT.

And after calculating within .1%, make the circuit with 5% tolerance parts.

Thanks y'all!

That's more what I was looking for! I'll try it in practice, and see how it goes.