Hacker News new | comments | show | ask | jobs | submit login
Ask HN: What's the purpose of the resistor in this circuit? (makezine.com)
23 points by tocomment 2778 days ago | hide | past | web | 29 comments | favorite

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.

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.

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

R2 is not a pull-down resistor.

They are taking an analog reading here, and the resistor is used as part of a voltage divider. You can use Ohm's law to calculate the output voltage.

To understand why R2 is needed, imagine the circuit without it. It would always read 5V, no matter the temperature.

Pull-down (and up) resistors are used on digital components with floating outputs, like switches, buttons, etc. For example, if a button is either open or connecting to a high potential, you would use a pull-down resistor to give meaning to that open state.

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...

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.

It's also not ideal because it's ratiometric to the supply voltage, not reference ground. They're reading the voltage across R2, and subtracting that from "5V" to determine the voltage across the sensor.

There should also be an anti-aliasing filter.

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.

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.

Look at it this way - a thermistor varies its resistance based on temperature. But an A/D port doesn't read resistance - it reads voltage. Therefore, you need some circuitry to translate the sensor resistance into a voltage. The simplest way of doing this is the "voltage divider" shown.

Other people have answered what the resistance does (create a voltage divider that feeds a voltage to the A/D converter), so I'll describe ways to select the resistance value.

There are several specifications that might have to be met:

  * Power delivery limit of the energy source
  * Current specification for optimal operation of the thermistor
  * Voltage level of the A/D input
The resistance value might be completely constrained by one of these requirements or, in tougher cases, might be constrained by more than one requirement (often in different directions).

For example, if the thermistor has an effective resistance of about 1kOhm and requires a current of about 1mA, then you need to set the resistor to 4kOhm (assuming the A/D input draws negligible current). If this is the case, you're stuck on the other requirements. Your power consumption will be 5mW (5Vx1mA) and the nominal level of the A/D converter input will be about 4V (5Vx4k/(1k+4k)).

Experienced circuit designers seem to magically come up with correct values because they are familiar with typical requirements and can quickly identify the limiting specification. You'll have to struggle a bit at the beginning to get the hang of it.

To understand circuits, you really have to become familiar with some common building blocks. When I saw this circuit, I didn't think "okay, a couple resistors in a configuration"; I thought, "oh, a voltage divider."

So read up on voltage dividers, RC circuits, pull-up and pull-down resistors, and diode current-limiting resistors. Google them right now and start reading. That will make you dramatically better equipped to understand real-world circuits.

As an electronics engineer (yes, someone gave me a degree! :o) I quickly learned that resisitors are mythical magical beasts that can fix anything.

In a circuits lab you would regularly hear the cry "grrr, it's not working! Fetch me the resistors". No one has quite worked out how they do it every time.

Or as one of my favourite lecturers put it "you can design the most impressive, streamlined, cut down, beautiful circuit in the world. But I bet it still has a resistor in it"


Considering that even the wiring & conductors you use to interconnect components have resistance, I'd have to agree completely :-)

pfft now your being geeky!

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!)

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.

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?

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.

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.


Ohm my god.

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

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.

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

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)

You make a valid point ;)

It's a voltage divider.


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

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.

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.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact