User Tools

Site Tools


en:i2c

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:i2c [2014/12/21 00:39] – [Linking of I²C devices] kakliken:i2c [Unknown date] (current) – external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-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 as an MLAB's component ======
Line 39: Line 38:
 ===== Convertors to connect I²C to PC ===== ===== 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 [[http://www.paintyourdragon.com/?p=43|DCC leading out of free display port.]]+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. (([[http://www.paintyourdragon.com/?p=43|with exception of DCC leading out at free display port.]]))
  
 ==== USB interface ==== ==== USB interface ====
Line 50: Line 49:
  
 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 [[en:i2c_avr_usb|I2C AVR USB]] device that is equivalent to i2c-tiny-usb design, but made of MLAB modules.  [[en:i2c-pic-usb| I²C to USB with PIC connector]] represent another, yet unfinished, alternative. 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 [[en:i2c_avr_usb|I2C AVR USB]] device that is equivalent to i2c-tiny-usb design, but made of MLAB modules.  [[en:i2c-pic-usb| I²C to USB with PIC connector]] represent another, yet unfinished, alternative.
 +
  
 ==== USB HID ==== ==== USB HID ====
  
-To connect without having to use drivers designed for specific hardware [[http://en.wikipedia.org/wiki/USB_human_interface_device_class|USB HID]] specification can be used. MLAB has only one module that complies with this particular specification - [[en:usbi2c|USBI2C01A]]. It can be operated using python or HIDAPI - see below.+For connections without the need for drivers designed for specific hardware [[http://en.wikipedia.org/wiki/USB_human_interface_device_class|USB HID]] specification can be used. MLAB has only one module that complies with this particular specification - [[en:usbi2c|USBI2C01A]]. It can be operated using python or HIDAPI - see below. 
 + 
 + 
 +==== UART/RS232 to I²C  ==== 
 + 
 +NXP manufactures [[http://www.nxp.com/products/interface_and_connectivity/bridges/uart_to_i2c_master_gpio_bridges/SC18IM700IPW.html|konvertor UART na I²C SC18IM700IPW]], which can possibly become the basis for construction of another conversion module. 
 + 
 +==== Ethernet to I²C  ==== 
 + 
 +This type of convertor can be constructed using [[en:eth|ETH01A]] and [[en:stm32f10xrxt|STM32F10xRxT01A]] modules and controlled by Pymlab software package (see below). 
 + 
 +===== I²C implementation in Linux systems ===== 
 + 
 +There exists a package of tools for working with I²C bus for Ubuntu that can be installed through:  
 +  sudo apt-get install i2c-tools 
 + 
 +Due to the usual absence of //i2c-dev// (([[https://i2c.wiki.kernel.org/index.php/Main_Page| Linux I²C Subsystem]])) module in kernel, we need to add it manually: 
 +  sudo modprobe i2c-dev 
 + 
 +<WRAP tip>   
 +Modprobe command adds the module only to the kernel instance that is already running. Therefore, after reboot, the module will probably still be missing. If we do not want to use modprobe command on next computer start, we need to add following line to  /etc/modules: 
 +  i2c-dev   
 +</WRAP> 
 + 
 +It is now possible to list available I²C buses: 
 + 
 +  $ sudo i2cdetect -l 
 +  i2c-0 i2c        i915 gmbus ssc                  I2C adapter 
 +  i2c-1 i2c        i915 gmbus vga                  I2C adapter 
 +  i2c-2 i2c        i915 gmbus panel                I2C adapter 
 +  i2c-3 i2c        i915 gmbus dpc                  I2C adapter 
 +  i2c-4 i2c        i915 gmbus dpb                  I2C adapter 
 +  i2c-5 i2c        i915 gmbus dpd                  I2C adapter 
 +  i2c-6 i2c        i2c-tiny-usb at bus 001 device 030 I2C adapter 
 + 
 +Using //i2cdetect// software we can further search for I²C buses for example on [[en:odroid-x2|Odroid-X2]], which has I²C output through GPIO. 
 + 
 +  kaklik@radio-arm-0:~$ sudo i2cdetect -y 1 
 +        1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 
 +  00:          -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  10: UU -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --  
 +  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  70: 70 -- -- -- -- -- -- --                          
 +  kaklik@radio-arm-0:~$ 
 + 
 +The output above shows, that apart from system device with 0x10 address, there are to additional devices connected to the bus: 0x1e ([[en:mag|MAG01A]]) and 0x70 ([[en:i2chub|I2CHUB02A]]). 
 + 
 +==== Communication with I²C devices ==== 
 + 
 +The bus can be controlled either by using system kernel interface or a service utility that is a part of i2c-tools package: 
 + 
 +  $ apropos i2c 
 +  i2cdetect (8)        - detect I2C chips 
 +  i2cdump (8)          - examine I2C registers 
 +  i2cget (8)           - read from I2C/SMBus chip registers 
 +  i2cset (8)           - set I2C registers 
 + 
 +=== Writing === 
 + 
 +Writing is executed by i2cset command. A following [[cs:i2chub]] setting provides a specific example as the IO has only one register that is not addressed. Data is therefore written directly:  
 + 
 +  ~$ sudo i2cset -y -r  1 0x70 0xff 
 +  Value 0xff written, readback matched 
 + 
 +The command triggers all I²C channels on I²CHub ((caution is necessary as having the same addresses on several channels or devices will cause a collision and locking of the bus. In this event the bus has to be reset by disconnecting the power supply or through RESET pin on I2CHUB module)). 
 + 
 +=== Reading === 
 + 
 +Reading from I²CHub is atypical as well, because the data registry is not addressed:  
 + 
 +  $ sudo i2cget -y 1 0x70  
 +  0xff 
 + 
 +==== Use of Linux kernel drivers ==== 
 + 
 +Some I²C devices have their drivers directly in the linux kernel allowing an access directly through file system. It applies to following MLAB modules: 
 + 
 +  * [[en:usbi2c]] 
 +  * [[en:i2chub]] 
 +  * [[en:i2cspi]] 
 + 
 +Due to the fact that, in principle, I²C is not a [[http://en.wikipedia.org/wiki/Plug_and_play|plug-and-play]] bus, every connected device must be explicitly reported to the kernel. A general procedure of such connection is via a following command:  
 + 
 +  echo driver's_name i2c_adresa > /sys/bus/i2c/devices/i2c-X/new_device 
 + 
 +Linux kernel will take control of I²C device - such state can be seen in i2cdetect list labeled as UU. Details concerning the initialisation can be further found in [[http://en.wikipedia.org/wiki/Dmesg|dmesg]]. 
 + 
 +===== Other operating systems ===== 
 + 
 +On other OS (like Windows or Mac OS), where we cannot or do not want to use kernel I²C interface support, we may use Python programming environment that is multi-platform. 
 + 
 +===== Related sites =====
  
 +  * [[en:usbi2c]]
 +  * [[en:i2c-pic-usb|I2C-PIC-USB]] - Konvertor I²C na USB s PIC
 +  * [[en:i2c_avr_usb|I2C-AVR-USB]] - Konvertor I²C na USB s AVR
 +  * [[en:arm|Procesory architektury ARM ve stavebnici MLAB]]
 +  * [[en:odroid-x2]]
 +  * [[en:friendlyarm]]
 +  * [[en:i2chub]]
 +  * [[en:pymlab]]
en/i2c.1419122346.txt.gz · Last modified: 2014/12/21 00:39 (external edit)