# Don't understand how these resistors operate in this circuit

When reading a manual on using a PICAXE and an I2C device I saw this diagram.

I can't work how this would behave as wouldn't it make the connection on the lines constantly high due to the connection to the power rail, so never goes low. I understand that they are open-drain lines and they are needed inorder to make the lines go high but how can it make them go low with that connection to the positive rail?

The resistors you see are called "pull up" resistors; they literally "pull up" the signal to the positive voltage rail.

I2C is a communication bus that allows multiple devices to talk on it. Since there is only a clock and data line there is no way to ensure that two devices won't start talking at the same time, or a device mis-identifies a message as being for it and responds out of turn.

If two devices try to control the data line and one wants it '1' and the other '0' you end up with a condition called contention. Internally a normal digital output is built up out of two transistors: one connects the signal line to +V and the other to ground. The device turns on one transistor or the other to set the output signal to the appropriate level. When two devices are trying to make the same signal two different voltages you end up with +V connected to ground through two transistors. This is known as contention and is something you want to avoid because it causes high currents and can damage one or both of the output drivers.

In order to get around this problem, the I2C specification requires the use of "open collector" or "open drain" (same thing) drivers. This means that the devices on the bus can ONLY connect the signal to ground. The only way for a device to output a '1' is to not drive the line to zero. Something has to bring the line to a logic '1' and that something is the pull-up resistor.

What happens now if two devices try to drive the data line is that one is not doing anything (it wants the line to be '1') and the other device has its output transistor turned on, connecting the signal to ground. The resulting signal is a '0' -- there is no contention because the only thing holding trying to make the line a '1' is a resistor which by design limits the amount of current it allows through. Pull-up resistors are usually selected to offer a bit of resistance to a changing signal but not too much. For I2C the value for a pull up is usually 4700-10000 ohms.