

Ask HN: What's the purpose of the resistor in this circuit? - tocomment
http://blog.makezine.com/archive/2009/03/howto_remote_temperature_sensing_wi.html?CMP=OTC-0D6B48984890
I understand what circuits do a lot of times but I never understood why there's always a resistor even on simple circuits.  And how do you decide when to use one, how do you know what resistance to use when designing a circuit?<p>This really simple circuit illustrates my confusion.
======
brk
It's a pull-down resistor.

Without it, when the temp sensor/thermistor was at infinite resistance, the
Arduino pin would essentially be floating, and you'd get erratic readings.

A pull down resistor is usually proportionally very high resistance in
relation to the sensor or other device that is the variable in the circuit.

If it were tied to Vcc, it would be a pull UP resistor, but same concept.

The idea behind it is that the pin is never just left "open". If there is no
voltage coming through the sensor (temp sensor in this case), then the
resistor pulls the pin to ground and you would get a reading of zero volts.

You want the resistance of the pull-down (or pull-up) to be high, 10K-100K are
typical values. Voltage drops across all elements in a circuit, in proportion
to that elements resistance in relation to the total circuit resistance.

If the temp sensor ranged from 0K to 10K, and you used a 10K pull-down, then
you would have a range of 5V-2.5V for readings at that pin. As you scale up
the value of the pull-down resistor, you will get less voltage drop across
that resistor, meaning that you have a wider voltage range at the input pin
for the same temperature variance, which results in more precise readings.

~~~
robotrout
That's actually not quite true. In digital circuits, we do often use pull-ups
or pull-downs to keep an input from floating. That's not what's happening
here.

You're making a voltage-divider. One half of the voltage-divider is your
temperature sensing resistor (thermistor), and the other half is the resistor
you're asking about. Go look up voltage-dividers. In the meantime, I made a
little javascript helper app as one of my very first 'learn javascript' apps a
while ago. Check out <http://eebug.com> to play with a voltage divider. In the
app, both legs of the voltage divider are constant resistors, while in this
circuit, one leg's resistance varies with temperature, but it's the same
concept.

~~~
brk
Thanks for the clarification. I looked at it quickly last night, but didn't
really think enough about it.

------
jgrahamc
As others have pointed out this is a voltage divider. But what's not been
pointed out is that this type of voltage divider is not ideal because the load
applied to the output voltage can alter the voltage itself. It's very
important that the load applied draws very little current (i.e. has a high
resistance/impedance) otherwise the voltage divider's output voltage changes.

The best way around this is to use a voltage divider to produce a reference
voltage and feed that into an op-amp that adds the reference voltage to the
voltage coming from the device to be measured (in this case the thermistor).

As an example of this see my blog posting on building a temperature probe for
the OLPC: [http://www.jgc.org/blog/2008/03/building-temperature-
probe-f...](http://www.jgc.org/blog/2008/03/building-temperature-probe-for-
olpc-xo.html)

~~~
mindslight
I don't know the Arduino specifics, but if it's just an analog input on the
Atmel chip, the datasheet says that's at least 100M ohm. (A pic18 actually has
a very low recommended source impedance - 2.5k ohm, which can bite you if
you're not careful, but that doesn't seem to be a concern here.)

If you're going to use an op-amp, you'd be better off using a different
configuration, say with the thermistor as the feedback resistor, to get a
linear response.

Taking a look at the circuit on your page, it seems like you could drop R9 and
R3 (while changing the value of R8), as the function of those 3 resistors is
only to feed a fixed current into the node of pin 2 (which is always held at
0V by the op amp). In fact, if you play around a bit, you should be able to
get the proper range using only one op amp, at which point you can use a 5V
rail-to-rail amplifier and get rid of that dual supply.

------
orblivion
Most simple answer I can give:

If the resistor were replaced by a wire, the pin would always be connected to
ground, rendering the thermistor irrelevant.

If the resistor were removed and ground disconnected entirely, the pin would
be connected, through the thermistor, to +5V, again rendering the thermistor
mostly irrelevant.

It needs to be part of a ratio of resistors in order to vary between 0 and
+5V.

------
tocomment
I understand what circuits do a lot of times but I never understood why
there's always a resistor even on simple circuits. And how do you decide when
to use one, how do you know what resistance to use when designing a circuit?

This really simple circuit illustrates my confusion.

~~~
jimmyjim
A resistor is usually to "resist" current on a certain component. If you've 10
volts in a circuit, you wouldn't want to connect a simple LED there, because
you wouldn't want that much current going to the LED. So you'd use a resistor
of appropriate resistance in that instance to keep it from burning out.

Though, in the example you linked to, there's no use of the resistor -- it's
connected to the ground. It's just useless. Unless of course, I'm not
understanding things right. (If I'm wrong anywhere, please point it out!)

~~~
mechanical_fish
Well, no, you're not understanding things right. ;)

The problem is that resistors have many uses. One of them is, indeed, to limit
the current flowing through some bit of a circuit: If you have a nine-volt
source, and you want some current to flow from nine volts to ground (because,
say, you want to run that current through an LED and make light), and you
don't want that current to be too large, put in more resistance.

Another obvious application that everyone learns is: If you want to heat
something up, strap a resistor to it and run a bunch of current through the
resistor and it will heat right up. (Although you had better heed the wattage
rating on your resistor or it will blow out right away.)

This is a third application: Resistors convert a current to a voltage.
Voltages are often easier to measure than currents. In this case, if you just
hooked a 5 volt source across a thermistor, the voltage at the top of the
thermistor is always 5 volts, and the voltage at the bottom is always zero by
definition. (Because we're defining it as ground -- ground means "the point
which we define as zero voltage in this diagram", although sometimes it _also_
means "a point which we literally attach to the earth" -- darned EEs with
their crazy terminology!) You can't use a voltage probe to measure anything
interesting in this thermistor-only circuit. The _resistance_ of the
thermistor is changing with temperature, which means that the _current_ in the
circuit is changing with temperature, but you can't see that with your voltage
probe. Unless you put in a second resistor -- the voltage across that resistor
will be proportional to the current. That's what the resistor is doing here:
Converting current to voltage so that we can see it.

Of course, one of the reasons EE is tricky to grasp is that the resistor is
doing more than one thing at once. For example, it is _also_ limiting the
total amount of current in the circult, just as you suggested. If you let the
current be limited only by the thermistor you might draw too much of it and
break the thermistor. Or, even if the thermistor has enough resistance to
prevent that, there's a catch: If the thermistor draws enough current it will
heat up, which will affect its reading. So you might want to choose a second
resistor that is big enough to keep the current very small. But not _too_
small, or there will be a lot of noise.

Sooner or later you have to stop thinking and use good old trial and error!
Learning this stuff is a little bit of thinking, then some math, then some
more thinking from another angle, then some tinkering. Occasionally you have
to melt some things -- that can help you learn too. It does take time. I was
probably halfway through college before I could _see_ this stuff, and I'm
still blind compared to the _real_ circuits guys.

~~~
jimmyjim
Thank you very much for the elaboration.

> ...the voltage at the top of the thermistor is always 5 volts, and the
> voltage at the bottom is always zero by definition. (Because we're defining
> it as ground -- ground means "the point which we define as zero voltage in
> this diagram", although sometimes it also means "a point which we literally
> attach to the earth" -- darned EEs with their crazy terminology!)

Isn't what you're referring to rather a "common" than a ground?

~~~
blackguardx
Technically that is true, but any common reference point is usually referred
to as a ground. If it does indeed connect to the earth, then it is usually
called an earth ground.

~~~
mechanical_fish
Yeah, in an ideal world we would all use "common" for the one concept and
"ground" or "earth ground" for the other. But in practice we use "ground" to
mean "common" and "earth ground" to mean "earth ground".

I remember, when I was a beginner, being completely confused about what all
those ground symbols meant. That was one of my first big stumbling blocks in
electronics. The answer is that they're usually nothing but notational: They
save you drawing some wires (every ground symbol is assumed to be attached
directly to every other ground symbol by a very-low-resistance wire [1]) and
more importantly they define your reference voltage (once you've drawn a
ground, you can say things like "this point in the circuit is at 3.2 volts",
instead of "this point in the circuit is at 3.2 volts relative to Point X".)

\---

[1] There are times when the connections from ground to ground have too high a
resistance, or when you pour so much current into ground that the ground-lead
resistance can't be ignored anymore. Those are called _ground loops_ , and are
topics for advanced class. I have a nasty ground loop when I connect my stereo
system to my cable TV. It manifests as the sixty-hertz hum from hell.

<http://en.wikipedia.org/wiki/Ground_loop_(electricity)>

------
avishvak
I request you to look at it differently from all the other posts. This
resistor is a constant current sink. Albit a mediocre one. but its just a
penny [a paisa in india] This thermister needs to sink a constant current in
order to produce a temperature dependent voltage at its bottom leg. Normally,
about a milliamp does the trick.

A resistor is a meiocre surrent sink because its own voltage drop is current
dependent. these would be better choices [lot more expensive, but hugely more
accurate] <http://octopart.com/search?q=constant+current+sink>

avishak, new delhi india

~~~
mechanical_fish
This is great! Another aspect of electronics that one must get used to is that
there is usually more than one way to interpret every part of a circuit. And
this current-sink point of view is quite useful -- as you point out, it
immediately suggests a way to improve the circuit: Put in a better current
sink, like a transistor.

------
jussij
Given that : V = I x R

Where: V = voltage I = current R = resistence

For this circuit: R = VR1 + R2 V = 5 I = 5 / (VR1 + R2)

That means the voltage at analog pin 0: VO = 5 - I * VR1 = 5 - VR1 * 5 / (VR1
+ R2)

So if you did not have the R2 resistor: VO = 5 - VR1 * 5 / VR1 = 0

~~~
jimmyjim
You're using 'x' as the multiplication operator in some examples and '*' in
others.

Stay consistent for goodness' sake! (Or someone might confuse 'x' to be a
variable)

~~~
jussij
You make a valid point ;)

------
tjic
It's a voltage divider.

<http://en.wikipedia.org/wiki/Voltage_divider>

Caution: I'm a CS major, not an EE, so your probably want to verify my
assertion before trusting it...

------
djahng
voltage divider: v_analog = 5V * R2/(R2 + VR1)

it's pretty meaningless by itself, you also need to know the bit resolution of
the ADC and reference voltage.

------
tocomment
Thanks for all the answers. It's starting to make sense now. Maybe I'll do
better actually starting to build circuits than from reading books.

