Go Down

### Topic: Trying to understand pull-up resistors (Read 8508 times)previous topic - next topic

#### vdavidoff

##### Nov 07, 2012, 11:39 pm
I am melting my brain trying to understand a very simple pull-up resistor configuration. I think I'm making this harder than it is.

Here's how I'm trying to think through this. Some or all of this may be wrong.

First off, my understanding of how at least part of this system works, is that sensor pin 2 is switched on and off internally by the sensor. The rest of my "understanding" is based on that, so if that's wrong, then it's all wrong.

* The pull up resistor ensures that when sensor pin 2 is switched off (disconnected) from arduino pin 3, arduino pin 3 still sees a small, consistent amount of current (from +5v) to keep it from floating. The resistor is called a pull-up resistor because the resistance it provides increases the voltage between the +5v output and arduino pin 3.

* When sensor pin 2 is switched on (connected) to arduino pin 3, arduino pin 3 sees a higher amount of current and a lower voltage (from sensor pin 2), because of the lack of resistance (as compared to running through the 4.7k ohm resistor).

Is that much correct?

FWIW, I think I have found the following documents to be helpful, but I'm certainly still not sure of myself.

http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
http://www.seattlerobotics.org/encoder/mar97/basics.html
http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

Thanks so much for any help.
Andy

#### be80be

#1
##### Nov 07, 2012, 11:52 pm
Your totally wrong here the DS18B20 is one wire the resistor is used to hold the line high when the chip is not sending data.

The ardunio send out a call for the DS18B20 and it send back that its on the line after is sees that the Line is high it sends data. Then when the line is high the ardnuio can send to the DS18B20 what it wants if it needs to set the chip or just let the chip tell how hot or cold it it is.

#### Palliser

#2
##### Nov 08, 2012, 12:05 am
Hi Vdavidoff,
Here a link of the DS18B20 datasheet.
http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

Open it and search for 'resistor'. They explain in an easy way (at least for me) how the pullup resistor works for this specific sensor.
It is important to know that the pullup resistor has also a leading role in electronic concepts like totem-pole and three-state. Regards

#### kf2qd

#3
##### Nov 08, 2012, 12:26 am
Think of it this way -

A transistor is just a switch. A silicon switch instead of a mechanical switch, but a switch all the same.

When the switch is turned on the input and output are connected together and it the input is conected to +V the output will be at +V also. If the input is connected to Ground then the output will be at ground also.

Now = turn the switch off. What state is the output? Don't Know, it is FLOATING. So we add a pullup or pull down resistor so when it is not active we are making our input go to a known state.

So - if our switch is connected to ground (low side switching, common for simple transistor switches) we use a pull-up resistor so when the switch is open the input to our device is at +V. If our switch input is at +V then our resistor will be tied to ground for a pull down resistor.

The resistor is there so when our input device is in its inactive , or off state, our input will be at known state. Things just work more rliably that way.

#### MarkT

#4
##### Nov 08, 2012, 12:47 am
The way the OneWire bus works is that the data line is a wired-AND gate.  Only if every device lets the line go HIGH, will it be HIGH.

Any device that pulls the line LOW will mean its LOW everywhere.  Only if no devices pull it low will it go HIGH, and that is due to the pull-up resistor.

For this to work devices never _actively_ pull the line HIGH, only the resistor does that, and it can only do it if nothing actively pulls it low because its weaker than active pull-downs (which will be something around 30 to 300 ohms or so).

The OneWire protocol is quite complicated and clever to use this wired-AND to be able to communicate with many devices and identify them all uniquely, all from one signal wire.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### vdavidoff

#5
##### Nov 08, 2012, 01:31 am
I appreciate the quick and thoughtful replies. I am really trying here but every time I dig into this I just lose a hold on these concepts.

Let me take a big step back and ask a question related to how I'm trying to understand this schematic, aside from the pull-up resistor specifically. This one should really highlight where I'm coming from.

If sensor pin 2 is input/output as the spec sheet explains, does this mean that pin 2 both sources and sinks power at different times depending on what it's doing? Or does power always flow through pin 2 in the same direction (and if so, how does data go the opposite way?). Related: does arduino pin 3 supply power to pin 2, sink power from pin 2, or both at different times?

If that question makes you think I have baked beans for brains, I can assure that when it comes to electricity and electrical engineering, I do. But I'm really trying here.

Andy

#### dhenry

#6
##### Nov 08, 2012, 01:58 am
It is really simple: all a pull-up resistor does is to "pull-up" the line to rail, absent of other load on the line.

It becomes more interesting when you do put a load on the line, like a transistor between the line and ground. When that transistor is turned on, it looks like a resistor with very low "resistance", this will overcome the pull-up resistor and the line goes low.

If the transistor is turned off, it looks like a resistor with very high "resistance", and the pull-up resistor prevails and the line goes high.

A 1-wire devices uses time to transmit logic '1' and '0'.

#### vdavidoff

#7
##### Nov 08, 2012, 04:10 am

I'm working on the understanding that to have current flow, you need an emitter (-) on one side of a circuit, and a collector (+) on the other.

If when S1 is open current is flowing between Vcc and pin 1, that means that whatever is on the other side of pin 1 is Vee, right? And ground is an emitter, right? So why would connecting Vee (whatever is on the other side of pin 1) to ground by closing S1 have any impact on how current is flowing between Vcc and pin 1? Even if you then have current flowing from Ground to Vcc, wouldn't current still be flowing from the other side of pin 1 to Vcc, too?

I guess the crux what I don't get is what happens on the line to make pin 1 go low (low voltage/small current, yes?) when S1 is closed.

(source: http://www.seattlerobotics.org/encoder/mar97/basics.html)

Andy

#### Grumpy_Mike

#8
##### Nov 08, 2012, 07:32 am
Forget using the terms collector and emitter, these are used specifically for transistors.
In that circuit with the switch open the voltage on pin 1 is Vcc, with the switch closed the voltage on pin 1 is zero or ground.
Without the resistor the voltage on pin 1 would be nothing with the switch open. Nothing is diffrent from zero. Zero is a voltage level that can cause current to flow. Nothing is just not connected to anything, no current can flow from Vcc to nothing.

#### cjdelphi

#9
##### Nov 08, 2012, 10:38 am
Maybe I can simplify your understanding.

Imagine a pipe of water, we can have current/voltage, which is the water flowing, when the water stops flowing, there's no more water/current.

You supply the water into the pipe, now at the other end we have a guy checking the amount of water flowing, just to make it simpler, the guy who's checking the water flow happens to be an Arduino on digital pin 2.

Now, if you're still with me..

On digital pin 2, we have a High and Low voltage, High meaning you're dumping water into the pipe to keep that pipe flowing... and LOW means there's little or no water flowing.... so what happens if you dump some of the water into the pipe?..

Arduino may see HIGH or it may see LOW.  depending on how much water is flowing at the time, so what you do is add another pipe, either as a Pull Up, or a Pull Down, so when you press a button, the water either flows and fills up with a pull up, or with a pull down, the pipe will empty, if you don't the excess water just sitting in the pipe could give you false readings either reporting high (flowing) or low (not flowing) the extra pipe/pull up/down is there to make sure it's not floating....

#### AWOL

#10
##### Nov 08, 2012, 10:53 am
Quote
Imagine a pipe of water, we can have current/voltage, which is the water flowing, when the water stops flowing, there's no more water/current.

That's not a good analogy; water represents both current (flow) and pressure (voltage). Even if there is no water flowing out of a tap, there is still pressure.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### vdavidoff

#11
##### Nov 08, 2012, 04:16 pm

Forget using the terms collector and emitter, these are used specifically for transistors.

No problem. I looked up "Vcc" and that's where I picked up "collector" and "emitter".

In that circuit with the switch open the voltage on pin 1 is Vcc,

This I get, because I can see the physical connection between Vcc and pin 1, and there are no other connections (in the schematic) to confuse me.

with the switch closed the voltage on pin 1 is zero or ground.

I accept that this is what is happening, but what I don't understand is why. If pin 1 is connected to both ground and Vcc, why does the connection to ground "overtake" the connection to Vcc, dropping the voltage to 0? Is there not still a potential difference (voltage) between Vcc and pin 1, when it is connected to both Vcc and ground? Maybe I am missing how the resistor impacts the connection to Vcc when pin 1 is connected to both it and ground?

Without the resistor the voltage on pin 1 would be nothing with the switch open. Nothing is diffrent from zero. Zero is a voltage level that can cause current to flow. Nothing is just not connected to anything, no current can flow from Vcc to nothing.

I think I understand what you're saying here to mean that "without the resistor on pin 1" it would be floating when S1 is open. Just for the sake of clarification though, when you say "without the resistor on pin 1", you really mean "without the connection to Vcc (including the resistor) on pin 1", right?

Thanks to all. I feel like I'm getting closer.
Andy

#### Grumpy_Mike

#12
##### Nov 08, 2012, 04:30 pm
Quote
If pin 1 is connected to both ground and Vcc, why does the connection to ground "overtake" the connection to Vcc, dropping the voltage to 0?

The ground wins because the resistance between the pin and the ground is zero. So the pin "feels" the ground. The Vcc is connected to ground through the resistor, so all the current from Vcc flows through the resistor to ground, the pin doesn't get a look in. The voltage at the resistor / pin is ground.
Look up a potential divider, http://en.wikipedia.org/wiki/Voltage_divider, it is only when the switch has some series resistance in it does the current flowing down the resistor from Vcc develop any voltage at the pin. In your case this voltage of the bottom leg of a potential divider is zero because the resistance is zero.

Quote
Is there not still a potential difference (voltage) between Vcc and pin 1

Yes there is, but it is the potential difference between ground and the pin that defines what the pin "sees" and that is zero.

Quote
how the resistor impacts the connection to Vcc when pin 1 is connected to both it and ground?

All the current flows into ground, ground wins, there is no resistance between the pin and ground to turn that current flow into a voltage.

Quote
when you say "without the resistor on pin 1", you really mean "without the connection to Vcc (including the resistor) on pin 1", right?

Yes you can have a resistor with one end on pin 1 but it is still electrically connected to nothing. It is only when the other end of the resistor is connected to Vcc is there a path. The resistor "pulls up" pin 1. If the resistor were replaced by a wire it would have the same effect. Only when you closed the switch there would be nothing to limit the size of current through the switch and you would have a dead short from Vcc to ground. The resistor is there to limit the current that flows when the switch is closed. If the switch were never closed this could still be a wire.

#### dhenry

#13
##### Nov 08, 2012, 04:40 pm
Think of it as a divider: the pull-up resistor is the upper resistor and the load / other active devices as the lower resistor whose resistance is controlled by a signal. By applying a particular signal, you can change the resistance of the lower resistor thus changing the output signal of the divider, creating logic '1' and '0'.

#### MarkT

#14
##### Nov 08, 2012, 09:50 pm

I'm working on the understanding that to have current flow, you need an emitter (-) on one side of a circuit, and a collector (+) on the other.

Forget all about current, I suspect its confusing you - most(+) digital logic is voltage driven (and no(*) current flows except for tiny spikes as signals change).

Think about connecting an input to either LOW or HIGH (but never both at once) - that's how most logic circuits work - once connected the voltage rapidly jumps to that of the rail it is connected to.

Once pull-up or pull-down resistors appear we have to break this rule - an input is being connected via a resistor to one rail and via a low impedance switch/transistor to the other.  The low impedance switch will always win when closed (and current will then flow through the resistor - but that's not normally important/interesting if the resistor is a high enough value).  We think purely of the voltage of the signal being either LOW or HIGH.

Incidentally Vcc/Vee/Vdd/Vss are dodgy shorthand names that normally tell you nothing about the devices on the chip.  For instance CMOS devices use FETs that are symmetrical - there isn't a source and a drain so Vdd and Vss are meaningless, it's pure convention that Vdd means positive supply and Vss means ground.  Vcc etc dates from older logic families so are also just taken to mean supply rails.

(+) this wasn't always the case
(*) well almost no current - pA or nA per gate isn't unusual.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up