In a project I'm currently working on I thought this would be a nice debug style message, but I can't actually work out what I'm trying to do!
To make everything simple and hopefully easy for anyone to understand, I have shrunk down the problem to this:
(don't know how to upload image, so I'll try some ascii art)
3.3V supply into 560 ohm resistor used a pullup into both a processor pin (ADC) and a 1K resistor to ground. The 1K resister can be anything between 1K and 10K (pot). I want to measure the resistance and display that value.
I can create a table in the software and use analog windows using this equation: Resistance / (Resistance + Pullup) * 3.3 (VIN) which gives me voltage and then converting that voltage to an ADC value is easy as I can just divide the voltages and multiply by my ADC resolution.
What I can't do and trying to do is to do this without tables.
I can convert the ADC result to a voltage quite easily (divide by my ADC resolution and multiply by VIN).
So this makes the question easy:
1K resistor to ground and 560 ohm pullup: 1000/(560+1000)*3.3 = 2.115V
To work out resistance we must work out currant, so I=V/R, so 3.3 / 560 = 0.005892857142857.
So R=V/I, so 2.115V / 0.005892857142857 = 358. Not what I was expecting!
How do I get 1000 ?