2

I'm trying to determine the minimum value of pull resistor for Arduino Uno

The datasheets says for arduino; VOL = 0,4 for IOL = 20 mA. (VDD = 5V)

For formula for calculation of minimal pull-up is: Rmin=Vcc−0.4V/20mA = 4,6V / 20mA = 230 ohms.

But I saw that people use 0,4V for 3mA. Than the minimal value is 1,6K ohms.

So whats the minimum value of pull-up for arduino?

(also my slave has 0,4 Vol for 20 mA IOL)

Kono
  • 21
  • 1
  • 4

2 Answers2

1

The full datasheet of the atmega328p can be found here: https://www.microchip.com/wwwproducts/en/ATmega328P.
It is called "ATmega328/P AVR MCU with picoPower Technology Data Sheet".

In section "32.7 Two-Wire Serial Interface Characteristics" in table 32-10 on page 372 it shows different voltage levels for the input.

On page 110 it says: "When the TWEN bit in TWCR is set (one) to enable the 2-wire Serial Interface, pin PC4 is disconnected from the port and becomes the Serial Data I/O pin for the 2-wire Serial Interface. In this mode, there is a spike filter on the pin to suppress spikes shorter than 50 ns on the input signal, and the pin is driven by an open drain driver with slew-rate limitation".

I wrote here before that the i2c (the twi hardware inside the microcontroller) did not use the digital pin hardware. However, the i2c pins can still sink a lot of current. Thanks to @Berkay for noticing the same behaviour of the sink current as a normal digital pin.

According to the datasheet the atmega328p of the Arduino uno might not use the digital pin hardware for i2c. It is not known if the same mosfet circuit is used with the same (large) sink current. Perhaps the chip uses a similar mosfet circuit with added slew rate for the output and added spike filter for the input. Perhaps the same mosfet of the digital pin is used after all.

In the Arduino sketch, calling Wire.begin turns on the dedicated i2c hardware in the atmega328p chip. The sink current and voltage levels are according to the i2c specifications.
As you can see in the i2c tutorial by Nick Gammon, the Arduino can sink more than 3 mA.

When the pullup resistors are too low, for example for a sink current of 4 mA, the Arduino uno can handle that, but the slave might not.

When all the pullup resistors are combined, the required sink current can be calculated. The maximum is 3 mA to meet the i2c specifications. To compensate for wire capacitance the i2c bus speed can be lowered.

The i2c bus is not ment to go into a cable, it is not ment for long wires. A cat6 cable is 46 pF/m. That means your 800 pF is for 17 meters cable? That is not what the i2c bus is for. It is for 17 centimeters. The rule of thumb is maximum 50 cm for a normal 100 kHz to 400 kHz i2c bus.

Jot
  • 3,276
  • 1
  • 14
  • 21
0

I assume you want to work out the minimum value for a pullup resistor that will give a voltage below VIL for an IO pin in open-drain mode.

That is not a simple task, chiefly because you don't know the ON resistance (RDSON) of the low-side MOSFET in the chip.

It's possible to come up with a rough estimate (see here) though.

With VIL of 1.5V and maximum current of 40mA that's an estimated theoretical resistance of 1.5/0.04 = 37.5Ω.

Note: this is just an estimate based on the absolute maximum and DC Characteristics values from the datasheet.

So if we take that value as actually true you can work out the upper half of a voltage divider that would result in 1.5V coming out. There's two ways of doing that - using the resistance or using the current.

Taking the resistance R1=R2(Vin/Vout-1), 37.5 x (5/1.5-1) = 87.5Ω.

If you want to do it with the current (40mA "absolute maximum"), then R=V/I = (5-1.5) / 0.04 = 87.5Ω.

However, that comes with a big caveat. The IO pin, while it can, for short periods, sink 40mA, it's not designed to do that for long periods. For that 25mA is the recommended maximum. So a resistor should be chosen that keeps the current below 25mA.

Assuming 37.5Ω for the MOSFET resistance, and 25mA through it, that gives a voltage drop across it of 0.94V (well below VIL). The upper resistor in that divider would then be (5-0.94)/0.025=162.5Ω

So to sum up:

  • The absolute minimum resistor would be 87.5Ω
  • The recommended minimum resistor would be 162.5Ω
  • The resistor you would choose to use would bear no real relationship to those values since you would normally choose something more sensible, like 3.3kΩ unless you wanted to run the I2C bus at insanely high speeds or with massive load capacitances.

You really don't need to know the theoretical minimum. You know the maximum already, and all you really need to know is "is the value I'd like to use safe for the IO pin" - i.e., does it draw less than 20mA?

For that you can ignore all the other values. All you care about is your resistance, the Vcc voltage, and the resultant current.

For instance, for a 900Ω resistor with 5V across it you get 5.6mA. You know for a fact that you can never have more than 5.6mA regardless of the resistance of the MOSFET - it can only go down from there.

5.6mA is below the recommended maximum of 20mA, so you're perfectly safe with that resistor.

Majenko
  • 105,851
  • 5
  • 82
  • 139