Author Topic: Ohms Law, Calculating resistance  (Read 1082 times)

0 Members and 1 Guest are viewing this topic.

Offline ploppityTopic starter

  • Newbie
  • Posts: 4
Ohms Law, Calculating resistance
« on: February 23, 2018, 11:40:38 am »
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 ?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Ohms Law, Calculating resistance
« Reply #1 on: February 23, 2018, 12:27:57 pm »
Let R1 = 560
R2 = 1000
Vdd = 3.3
Vmeas

Vmeas = (R2 * Vdd)/ (R1 + R2) or Vmeas * R1 + Vmeas * R2 = R2 * Vdd
or
R2 (Vdd - Vmeas) = Vmeas * R1
or R2 = (Vmeas * R1) / (Vdd - Vmeas)
         = (2.115* 560) / (3.3 - 2.115) = 1184.4 / 1.185 = 999.5 ohms


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 
The following users thanked this post: ploppity

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: Ohms Law, Calculating resistance
« Reply #2 on: February 23, 2018, 12:57:27 pm »
This is basically your voltage divider circuit as I understand it: http://www.ohmslawcalculator.com/voltage-divider-calculator

Your mistake was in calculating the current. It's not 3.3/560, since the voltage drop over the 560 ohm resistor is only 3.3-2.115 = 1.185 Volts. Which means the current is 1.185/560 = 0.002116 Amps

Current is the same through all components in series, so the current through the other resistor that drops the other 2.115 V will also be 0.002116 Amps. Which means R = V/I = 2.115/0.002116 = 999.5 ohms, which is close enough given ADC precision and rounding.

Which is pretty much what the other respondent said, but with less explanation.
 
The following users thanked this post: ploppity

Offline ploppityTopic starter

  • Newbie
  • Posts: 4
Re: Ohms Law, Calculating resistance
« Reply #3 on: February 23, 2018, 01:07:55 pm »
Thanks Nusa, danadak equation was useful, but your explanation and telling me why and how I messed up was a far better response. Now I know why and not just how  :-+
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf