Pull up or down ?

Hi all.

Complete newbee. little electronics experience. programmer. new Arduino Mega on its way to me.

I understand the logic of a pull up or pull down resistor, and what happens if I don't use one.

Have browed the 20 pages of topics under the 'General Electronics' forum, but can't seem to find the answers to 2 simple question :

  1. what is the correct value resistor to use ?

  2. why ( is there a calculation for determining the correct value ) ?

Also, is it best to use the built-in pull-up, or add an external resistor ?

http://www.sparkfun.com/tutorials/218

built-in resistors are obviously for convenience, if you don't have a reason not to use them, then use them

Many Thanks.

I believe I now understand this.

  1. what is the correct value resistor to use ?

There is no "right answer". It is a compromise between current wasted, noise immunity and drive capacity of the device feeding into the input.

is there a calculation for determining the correct value

It's just ohms law, the trick is knowing how much current you want at the correct voltage.
If you only pull up to the exact voltage of the logic threshold then any noise will trigger the input. So pull up further gives you immunity against picked up noise.

However the up shot is that you can use between 1K to 10K on an arduino quite happily.

Using LS TTL circuits this is the same for a pull up but TTL inputs require you to sink 2mA for a pull down so then the biggest pull down you could have was a lot lower.

So, is there a down-side to using the internal pullups?

Yankee:
So, is there a down-side to using the internal pullups?

Not for interfacing with simple switch contacts. No external components or board space taken up, what's not to like about that.

Lefty

Yankee:
So, is there a down-side to using the internal pullups?

They are only pull-up, they can't be pull-down

You don't choose the resistance

You don't choose the voltage to pull to

You don't choose the voltage to pull to

What choice do you have other then the chip's Vcc voltage with active sink and source output pins?

Lefty

What choice do you have other then the chip's Vcc voltage with active sink...

Uh oh. I've been working on an idea that relies on sinking a lower voltage than VCC. I was hoping I could...

  • Have a connection between two processors. One processor running at 5 volts the other running at 3 volts.

  • Connect a pull-up to the shared line to hold it at 3 volts.

  • Signal from the high-voltage processor to the low-voltage processor by sinking the line on the high-voltage processor. The high-voltage pin would either be an input (high-impedance; line pulled-up to 3 volts) or a low output (sink).

Is that a problem?

The high-voltage pin would either be an input (high-impedance; line pulled-up to 3 volts) or a low output (sink).
Is that a problem?

That sounds like it should be OK. The potential problem is if the high voltage pin was made an output and made high, then the low voltage pin would see the high voltage.

Lefty

Got it. Thanks. (My apologies for the sidebar)

retrolefty:

You don't choose the voltage to pull to

What choice do you have other then the chip's Vcc voltage with active sink and source output pins?

Lefty

That was my point

But with external resistors, you can pull to whatever voltage you want

That was my point

But with external resistors, you can pull to whatever voltage you want

But you missed my point. When would it be proper to ever pull-up a arduino digital output pin to a voltage higher or lower then the Vcc voltage of the chip? Arduino output pins are not open collector type output pins.

Lefty

retrolefty:

That was my point

But with external resistors, you can pull to whatever voltage you want

But you missed my point. When would it be proper to ever pull-up a arduino digital output pin to a voltage higher or lower then the Vcc voltage of the chip? Arduino output pins are not open collector type output pins.

Lefty

An ATmega running at 5V with an I2C bus interface to a 3.3V device would require external pull-up resistors connected to 3.3V

would require external pull-up resistors connected to 3.3V

Yes and a hack to the I2C library to not enable the internal pullups.

actually, if you interface any device that's open-collector or open-drain which use a voltage different from the voltage used by the ATmega, you'll want to avoid internal pull-up resistors, I2C is just one example

Yes but that will only apply if the voltage you are pulling it up to is above the zero / one threshold voltage. Otherwise a pull up is not going to cut it. Even so you erode noise margin by only pulling up to a lower voltage so in most cases you are better off using a level shifter.

An ATmega running at 5V with an I2C bus interface to a 3.3V device would require external pull-up resistors connected to 3.3V

But the bus would still be held at +5vdc due to the active sourcing output of the 5 volt mega's output pin. Current would flow through the pull-up from 3.3v to 5v, but the bus side of the resistor would still be at +5vdc, or am I missing something stupid?

I2C signals are bidirectional, so at times the 5vdc system side has to be an output and will not be constrained to the pull-ups 3.3vdc value. I guess most here are just considering the 5vdc system side as being an input where the bus pull-up is the only thing defining the logic high voltage level.

Lefty

Yes but that will only apply if the voltage you are pulling it up to is above the zero / one threshold voltage. Otherwise a pull up is not going to cut it.

Well that applies to anything digital signal regardless of whether you are using a internal or external pull-up resistor or neither.

Even so you erode noise margin by only pulling up to a lower voltage so in most cases you are better off using a level shifter.

Obviously that's the best solution in any scenario but it costs more in parts and board space. For something like a small low speed I2C bus, a resistor is fine.

retrolefty:

An ATmega running at 5V with an I2C bus interface to a 3.3V device would require external pull-up resistors connected to 3.3V

But the bus would still be held at +5vdc due to the active sourcing output of the 5 volt mega's output pin. Current would flow through the pull-up from 3.3v to 5v, but the bus side of the resistor would still be at +5vdc, or am I missing something stupid?

I2C signals are bidirectional, so at times the 5vdc system side has to be an output and will not be constrained to the pull-ups 3.3vdc value. I guess most here are just considering the 5vdc system side as being an input where the bus pull-up is the only thing defining the logic high voltage level.

Lefty

On a I2C bus, absolutely NO device is ever allowed to drive the bus anything but low.

At the physical layer, both SCL & SDA lines are of open-drain design, thus, pull-up resistors are needed. Pulling the line to ground is considered a logical zero while letting the line float is a logical one. This is used as a channel access method. High speed systems (and some others) also add a current source pull up, at least on SCL; this supports faster rise times and higher bus capacitance. Transitions for data bits are always performed while the clock is low, transitions while it is high indicate start and stop bits.
When one node is transmitting a logical one (i.e., letting the line float to Vdd) and another transmits a logical zero then the first node can sense this because the line is not in a logical one state — it is not pulled up to Vdd. When used on SCL, this is called "clock stretching" and gives slaves a flow control mechanism. When used on SDA, this is called arbitration and ensures there is only one transmitter at a time.