User Tools

Site Tools


en:i2c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
en:i2c [2013/11/27 12:35] – created kakliken:i2c [2014/12/20 13:48] – created fluktuacia
Line 1: Line 1:
-====== I2C in MLAB system ======+FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)//
  
-===== Activating The I2C Port =====+====== I²C bus as an MLAB's component ======
  
 +[[http://en.wikipedia.org/wiki/I²C|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 [[http://en.wikipedia.org/wiki/System_Management_Bus|SMUus]] 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 [[cs:arm|new possibilities]] arise allowing the use of the bus for direct communication between sensors and Linux systems. Furthermore, with the help of [[cs:usbi2c|I²C adapter ]] the bus can be connected to PC as well.  
  
-The I2C port needs to be enabled in kernel before you can use it. This can be achieved by  
  
-  sudo modprobe i2c-dev  
-   
-Then I²C bus interfaces can be listed by 
  
-  sudo i2cdetect -l 
  
-===== Checking For Connected Devices =====+===== Linking of I²C devices =====
  
-At the command prompt type one of these depending on whether you are using the I2C-X port:+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 (( [[http://cladlab.com/electronics/circuit-design/communication-protocols/i2c-protocol#gallery|I2C Transmission Distances And Buffer’s]] )). 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.    
  
-sudo i2cdetect -y X+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 [[cs:i2chub]]. This module also solves the conversion between logic 3.3V and +5V.
  
-The 7 bit I2C address of all found devices will be shown (ignoring the R/W bit, so I2C address 0000 0110 is displayed as hex 03).+Over more extensive distances the bus is linked through shielded signal cables ending in female connectors and connected to [[cs: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
  
-  
-===== SMBus (System Management Bus) Functions ===== 
- 
-SMBus (System Management Bus) is a subset from the I2C protocol 
-When writing a driver for an I2C device try to use the SMBus commands only (if it possible). It makes  possible to use the device driver on both SMBus adapters and I2C adapters. 
- 
-Note address is the 7 bit address excluding the read / write bit (it will be shifted left 1 bit whne added to the read/write bit) 
- 
-long write_quick(int addr) 
- 
-Send only the read / write bit 
- 
- 
-long read_byte(int addr) 
- 
-Read a single byte from a device, without specifying a device register. 
- 
- 
-long write_byte(int addr,char val) 
- 
-Send a single byte to a device 
- 
- 
-long read_byte_data(int addr,char cmd) 
- 
-Read Byte Data transaction. 
- 
- 
-long write_byte_data(int addr,char cmd,char val) 
- 
-Write Byte Data transaction. 
- 
- 
-long read_word_data(int addr,char cmd) 
- 
-Read Word Data transaction. 
- 
- 
-long write_word_data(int addr,char cmd,int val) 
- 
-Write Word Data transaction. 
- 
- 
-long process_call(int addr,char cmd,int val) 
- 
-Process Call transaction. 
- 
- 
-long[] read_block_data(int addr,char cmd) 
- 
-Read Block Data transaction.      
- 
- 
-write_block_data(int addr,char cmd,long vals[]) 
- 
-Write up to 32 bytes to a device.  This fucntion adds an initial byte indicating the length of the vals array before the valls array.  Use write_i2c_block_data instead! 
- 
- 
-long[] block_process_call(int addr,char cmd,long vals[]) 
- 
-Block Process Call transaction.      
-I2C Access Functions 
- 
- 
-long[] read_i2c_block_data(int addr,char cmd) 
- 
-Block Read transaction. 
- 
- 
-write_i2c_block_data(int addr,char cmd,long vals[]) 
- 
-Block Write transaction.  
- 
- 
-===== References ===== 
- 
-  * [[http://www.raspberry-projects.com/pi/programming-in-python/i2c-programming-in-python/using-the-i2c-interface-2|Using the I2C Interface]] 
-  * [[http://wiki.erazor-zone.de/wiki%3alinux%3apython%3asmbus%3adoc|python-smbus documentation]] 
en/i2c.txt · Last modified: 2014/12/21 10:42 (external edit)