User Tools

Site Tools

Translations of this page?:

en:i2c

This is an old revision of the document!


FIXME This page is not fully translated, yet. Please help completing the translation.
(remove this paragraph once the translation is finished)

I²C bus as an MLAB's component

I²C bus, also called TWI is a popular electronic bus designed for low-speed communication between different peripherals. As an MLAB's component it is mostly used to ensure communication between microprocessor and sensors. I²C derivative SMBus differs from it in that it contains timeouts' definitions and Packet Error Checking and therefor is, in sense, more robust than the original I²C.

Thanks to an advancement in computer technologies new possibilities arise allowing the use of the bus for direct communication between sensors and Linux systems. Furthermore, with the help of I²C adapter the bus can be connected to PC as well.

Linking of I²C devices

Although the I²C bus was originally designed to link devices on small scales (within the dimensions of PCB), using certain techniques it is possible to enlarge its range to tens of meters 1). However, it must be noted that such approach may not be safe because over long wires a high voltage can be electrostaticilly and electormagnetically induced and can cause damage to connected devices. The exact distance over which it is safe to use the I²C bus depends on the surrounding environment and the required reliability of the system.

Linking of I²C devices within MLAB is implemented on several levels according to extent of a network. Locally (on scale of several meters), the modules are connected by MLAB cables and separated by i2chub. This module also solves the conversion between logic 3.3V and +5V.

Over more extensive distances the bus is linked through shielded signal cables ending in female connectors and connected to uniserial module. This module also contains a basic surge protection and most importantly acts as a mechanical bridge between 'heavy external wiring' and fine internal linking of devices.

In the case of extensive networks I²C is replaced by other physical layer (CAN, Ethernet) that interconnects individual I²C network segments.

Pymlab package

Pymlab represents a software package that enables a creation of network made of I²C devices and modules, which serve as routing points. It defines the structure of a network and addresses of individual nodes in a source file of a control program. Individual points in the network can than be accessed using simple python commands.

The installation of the pymlab packed can easily be done using following command:

sudo pip install pymlab

In case of having some older version of pymlab already installed, it is enough to run:

sudo pip install --upgrade pymlab

Both commands are equivalent and use the python package manager that contains the pymlab. This procedure should also download other packages used by pymlab such as cython-hidapi (reffered only as hid module in python). However it does not install alelibusb, which must still be done manually using:

sudo apt-get install libudev-dev libusb-1.0-0-dev libhidapi-dev python-setuptools python-smbus cython 

Convertors to connect I²C to PC

Although I²C is quite popular bus suitable to connect different sensors over short distances, it is not usually found and readily available on regular computers with exception of DCC leading out of free display port.

USB interface

Proprietary designs:

These share a common problem with a quality of drivers. Furthermore, i2c-tiny-usb does not fully meet the I²C specification, completely fails to comply with USB physical layer specification and only has maximal communication speed of 50Kbps. MLAB replaces these constructions with I2C AVR USB device that is equivalent to i2c-tiny-usb design, but made of MLAB modules. I²C to USB with PIC connector represent another, yet unfinished, alternative.

USB HID

To connect without having to use drivers designed for specific hardware USB HID specification can be used. MLAB has only one module that complies with this particular specification - USBI2C01A. It can be operated using python or HIDAPI - see below.

en/i2c.1419122270.txt.gz · Last modified: 2014/12/21 00:37 (external edit)