Trying to understand pull-up resistors

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

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

Here's a perfect example of something about this that keeps confusing me.

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

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.

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

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.

Grumpy_Mike:
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".

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

Grumpy_Mike:
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?

Grumpy_Mike:
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

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, Voltage divider - Wikipedia, 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.

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.

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.

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.

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

vdavidoff:
Here's a perfect example of something about this that keeps confusing me.

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.

My 2 Cents... markT gave an excellent description of how 1-wire works...

There are basically 3 states in TTL logic. "High", "Low", and a word I like "Uncommitted". We commonly call that "floating", and in some cases, it is used on purpose with TTL devices that claim they are "tri-state", like a 74125 for example.

When you have devices that can only create a connection to GND (switches, transistors, whatever) , a 5V "high" logic level signal does not magically appear in the absence of GND or "low" state. You can assume it will be low... but a nearby finger can make it be otherwise.

So, back to the transistor idea... if you have a ttl input attached to TP, without R2 to pull the input signal pin HIGH, no amount of turning "on" or "off" either transistor will guarantee that signal at TP will go to logic "1" or "HIGH". Adding R2 will PULL UP the voltage on TP to hold the signal "HIGH" or at "1" unless either or both transistors turn on, pulling the signal... in a stronger manner.. closer to ground... changing the logic state at TP from Logic 1 "high" to Logic 0 "low".

The PULLUP will eliminate an undesired "3rd" state.

NOR.JPG

I'll need to sit down with this all later, but MarkT, your advice/explanation to ignore current for this discussion has been extremely helpful. I didn't realize that in this context the current wasn't really important, and thinking about where current was flowing was definitely confusing the hell out of me.

So in general then (at least in situations as simple as the one we're examining), is it true that if part of a circuit is connected to more than 1, what I'll call terminator (ex: +5v, GND), measuring voltage at that part will always reflect the connection to the lowest impedance terminator?

Andy

Something that often surprises is the case of a 1 kohm resistor with one end connected to, say, 5V and the other end to one side of an open switch whose other side is connected to ground.
What is the voltage across the open switch?
And if the resistor is 1 Mohm?

AWOL:
Something that often surprises is the case of a 1 kohm resistor with one end connected to, say, 5V and the other end to one side of an open switch whose other side is connected to ground.
What is the voltage across the open switch?
5V
And if the resistor is 1 Mohm?
Still 5V
Lefty

Still 5V

It depends on what this switch is.

dhenry:

Still 5V

It depends on what this switch is.

Your trying too hard to be helpful, once again, and failing once again.

Lefty

AWOL:
Something that often surprises is the case of a 1 kohm resistor with one end connected to, say, 5V and the other end to one side of an open switch whose other side is connected to ground.
What is the voltage across the open switch?
And if the resistor is 1 Mohm?

Another "I know nothing" question: By "across the open switch" do you mean measuring between each side of the open switch? Essentially closing the switch with the tester?

Andy

do you mean measuring between each side of the open switch

Yes.

Essentially closing the switch with the tester?

No the tester is a very high impedance so it does not close the switch.

Note to dhenry :- That is unless you have the meter set on current which you should not be doing here.

Essentially closing the switch with the tester?

Yes, but the impedance of the voltmeter is (should be) extremely high.