en:i2c
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
en:i2c [2014/12/20 13:48] – created fluktuacia | en:i2c [2014/12/21 10:22] – [Reading] kaklik | ||
---|---|---|---|
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 ====== | ||
- | [[http:// | + | [[http:// |
- | 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, | + | Thanks to an advancement in computer technologies [[en:arm|new possibilities]] arise allowing the use of the bus for direct communication between sensors and Linux systems. Furthermore, |
+ | ===== 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 (( [[http:// | ||
+ | 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 [[en: | ||
- | ===== Linking | + | Over more extensive distances the bus is linked through shielded signal cables ending in female connectors and connected to [[en: |
- | Although | + | In the case of extensive networks |
+ | |||
+ | |||
+ | |||
+ | ==== 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 | ||
+ | |||
+ | The installation of the [[en: | ||
+ | |||
+ | sudo pip install pymlab | ||
+ | |||
+ | In case of having some older version of pymlab already installed, | ||
+ | |||
+ | sudo pip install --upgrade pymlab | ||
+ | |||
+ | Both commands are equivalent and use the python package manager that contains [[https:// | ||
+ | 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 | ||
+ | |||
+ | 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 | ||
+ | |||
+ | ==== USB interface ==== | ||
+ | |||
+ | Proprietary designs: | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | These share a common problem with a quality of drivers. Furthermore, | ||
+ | |||
+ | |||
+ | ==== USB HID ==== | ||
+ | |||
+ | For connections without the need for drivers designed for specific hardware [[http:// | ||
+ | |||
+ | |||
+ | ==== UART/RS232 to I²C ==== | ||
+ | |||
+ | NXP manufactures [[http:// | ||
+ | |||
+ | ==== Ethernet to I²C ==== | ||
+ | |||
+ | This type of convertor | ||
+ | |||
+ | ===== 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:// | ||
+ | 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 / | ||
+ | i2c-dev | ||
+ | </ | ||
+ | |||
+ | It is now possible to list available | ||
+ | |||
+ | $ sudo i2cdetect -l | ||
+ | i2c-0 i2c | ||
+ | i2c-1 i2c | ||
+ | i2c-2 i2c | ||
+ | i2c-3 i2c | ||
+ | i2c-4 i2c | ||
+ | i2c-5 i2c | ||
+ | i2c-6 i2c | ||
+ | |||
+ | Using // | ||
+ | |||
+ | kaklik@radio-arm-0: | ||
+ | | ||
+ | 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: | ||
+ | |||
+ | ==== 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: | ||
+ | |||
+ | ~$ 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 | ||
+ | |||
+ | === 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 ==== | ||
+ | |||
+ | Některá I²C zařízení mají přímo ovladače v linuxovém jádře. Je tak možné k těmto zařízením přistupovat přímo prostřednictvím souborového systému. V případě MLABu se to týká těchto modulů: | ||
+ | |||
+ | * [[cs: | ||
+ | * [[cs: | ||
+ | * [[cs: | ||
+ | |||
+ | Protože I²C není v principu [[http:// | ||
+ | |||
+ | echo název_driveru i2c_adresa > / | ||
+ | |||
+ | Tím dojde k převzetí kontroly nad I²C zařízením jádrem Linuxu. Ve výpisu i2cdetect můžeme takový stav vidět označený jako UU. Podrobnosti o provedení a úspěšnosti inicializace můžeme pak obvykle najít v [[http:// | ||
+ | |||
+ | ===== Other operating systems ===== | ||
- | Linking of I²C devices within MLAB is implemented on several levels according to extent of a network. Locally | + | 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. |
- | Over more extensive distances the bus is linked through shielded signal cables ending in female connectors and connected to [[cs: | + | ===== Related sites ===== |
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: | ||
+ | * [[en: |
en/i2c.txt · Last modified: 2014/12/21 10:42 (external edit)