meta data for this page
lamaPLC Communication: I²C
I²C (Inter-Integrated Circuit; pronounced as “eye-squared-C“) is also known as I2C, I²C, or IIC. It is a synchronous, multi-master/multi-slave (controller/target), packet-switched, single-ended, serial communication bus invented in 1982 by Philips Semiconductors.
I²C is a widely used digital communication standard in many devices. The protocol employs a two-wire interface, enabling multiple controllers and peripheral devices. This application note highlights key aspects of the protocol as a guide to using I²C for communicating with controller devices.
This note covers both the protocol and the physical layer for I²C communication. Since I²C is often used with data converter devices, examples include communication with a DAC and an ADC for reading and writing registers.
Several companies, such as Siemens, NEC, Texas Instruments, STMicroelectronics, Motorola, Nordic Semiconductor, and Intersil, have released compatible I²C products since the mid-1990s.
Protocols Similar to I²C
The I²C specification covers several other communication protocols based on I²C. These protocols may be similar and compatible with I²C communication and can be used for specific applications. Some protocols also include defined commands and application-specific extensions for their systems. This section briefly describes the applications for these protocols, but their systems, applications, and uses are detailed elsewhere.
The first of these similar protocols is the Two-Wire Interface (TWI), which is equivalent to I²C.
However, there are some minor differences. TWI does not support a START byte and does not support high-speed modes. Generally, TWI-compatible devices are expected to be compatible with I²C, and the protocol can be seen with the same logic analyzers.
The System Management Bus, or SMBus®, is a protocol similar to I²C that is tailored to a specific function. It is commonly used in servers and computer motherboards for power source management. The protocol is very similar to I²C in the communication protocol and can be understood by an I²C controller.
The SMBus protocol has additional features compared to I²C. The SMBus can dynamically set addresses, allowing for quick communications at the start-up of a system. Also, the bus has a 35-ms timeout, which prevents one device from indefinitely tying up the bus. The protocol also has a packet error checking for error detection in data communication. There is an additional line called SMBAlert that is used by target devices as an interrupt to tell the controller about certain events detected by the target device.
The Power Management bus, or PMBus®, is a variant of SMBus defined by Intel. It is used in the digital management of power supplies. This protocol also defines specific commands to retrieve data about the system's voltage, current, and power.
Intelligent Platform Management Interface IPMI is another I²C-based protocol. This protocol is used by baseboard management controllers (BMCs) to monitor and manage the system's CPU, firmware, and operating system in autonomous computer subsystems. The protocol utilizes a standardized message-based interface for computer motherboards or servers. The BMC is always running even when the central system is off, allowing for operation, measurement, and remote management of a system.
Several other similar protocols are discussed in the I²C specifications. The Advanced Telecommunications Computing Architecture (ATCA) is a follow-on to CompactPCI, used in rack-mounted telecom hardware.
Display Data Channel (DDC) is a protocol that monitors or displays information, allowing hosts to control display functions. Finally, C-Bus is another protocol derived from I²C. As mentioned in the reserved address section, this protocol is used in some parts of the world for home and building automation.
I²C is similar in concept to 1-Wire.
I²C specifications
- In the most common case, the I²C bus contains only one master, but the possibility of a multimaster is also not excluded
- I²C uses an open-ended pair of wires for data transfer: the serial data line (SDA) and the serial clock signal (SCL). The two wires must be pulled to the operating voltage with resistors. The cables typically operate with a voltage of 5V or 3.3V, but a different voltage specification is also not excluded.
- Pull-up resistors are almost always 4.7k
- In principle, the maximum distance of the bus is 7.6 m, but it is typically used within 2-3 m.
- The bus typically uses 7- or 10-bit addressing, but sometimes the 16-bit solution also occurs. Typical transmission speeds:
Mode | Speed |
---|---|
Low speed mode | 10 kbit / sec |
standard mode | 100 kbit / sec |
fast mode (FM) | 400 kbit / sec |
fast mode plus (FM+) | 1 Mbit / sec |
high-speed mode (HS) | 1.7 .. 3.4 Mbit / sec |
Ultra-fast mode (UFm) | 5 Mbit / sec |
Open-Drain Connection
The open-drain connections are used on both SDA and SCL lines and connect to an NMOS transistor. This open-drain connection controls the I2C communication line, pulling the line low or releasing it high. The open-drain refers to the NMOS bus connection when the NMOS is turned OFF. The next pic shows the open-drain connection as the NMOS is turned on:
The NMOS is set on or off to set the voltage level of the SDA or SCL line. When the NMOS is on, the device pulls current through the resistor to ground, pulling the open-drain line low. Typically, the transition from high to low for I²C is as fast as the NMOS pulls down on SDA or SCL. The NMOS drive strength and any bus capacitance on SDA or SCL determine the transition speed.
When the NMOS turns off, the device stops pulling current, and the pull-up resistor pulls the SDA or SCL line to VDD. The following picture shows an open-drain line as the NMOS is turned off. The pull-up resistor pulls the line high. The transition of the open-drain line is slower because the line is pulled up against the bus capacitance and is not actively driven.
I²C addresses
Different manufacturers' applications and addresses with different lengths (7, 8, or 10 bits) significantly limit the usable address range, which is practically 0x08 .. 0x77.
I²C Arduino
The I²C protocol utilizes two lines to send and receive data: a serial clock pin (SCL), which the Arduino Controller board pulses regularly, and a serial data pin (SDA) over which data is exchanged between the two devices.
In I²C, one controller device has one or more peripheral devices connected to the controller's SCL and SDA lines.
As the clock line changes from low to high (known as the rising edge of the clock pulse), a single bit of information is transferred from the board to the I²C device over the SDA line. As the clock line continues to pulse, more and more bits are sent until a sequence of 7 or 8 bits, along with a command or data, is formed. When this information is sent, bit by bit, the called-upon device executes the request and transmits its data back, if required, to the board over the same line using the clock signal still generated by the Controller on SCL as timing.
Each device on the I²C bus is functionally independent of the controller, but it will respond with information when prompted by the controller.
Because the I²C protocol allows each enabled device to have its own unique address, and both controller and peripheral devices take turns communicating over a single line, your Arduino board can communicate (in turn) with many devices or other boards, using just two pins of your microcontroller.
- The controller sends out instructions through the I2C bus on the data pin (SDA), and the instructions are prefaced with the address, so that only the correct device listens.
- Then there is a bit signifying whether the controller wants to read or write.
- Every message needs to be acknowledged to combat unexpected results. Once the receiver has accepted the previous information, it notifies the controller, allowing it to proceed to the next set of bits.
- 8 bits of data
- Another acknowledgement bit
- 8 bits of data
- Another acknowledgement bit
More from Arduino I²C protocol
Arduino applications with I²C communication
I²C Arduino with 3.3V
The I²C communication primarily operates at 5V, but in certain cases, such as when a 3.3V base voltage unit (ESP32) is present in the network, 3.3V is also sufficient for the 5V units. The voltage level can be stabilized with 4.7 kOhm pull-up resistors (SDO, SCL):
According to Texas Instruments' analysis, the above solution does not work because the high voltage levels do not match between 5V and 3.3V. In the case of 5V, 3.5V is the high-level threshold, as seen in here.
They recommend using the PCA9306 IC for this case.
Sources
I²C topics on lamaPLC
This page has been accessed for: Today: 4, Until now: 279