en:i2c
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
en:i2c [2013/11/27 12:35] – created kaklik | en:i2c [2014/12/21 00:39] – [Linking of I²C devices] kaklik | ||
---|---|---|---|
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:// | ||
+ | |||
+ | Thanks to an advancement in computer technologies [[en: | ||
- | The I2C port needs to be enabled in kernel before you can use it. This can be achieved by | + | ===== Linking of I²C devices ===== |
- | sudo modprobe i2c-dev | + | 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:// |
- | + | ||
- | Then I²C bus interfaces | + | |
- | sudo i2cdetect -l | + | 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: |
- | ===== Checking For Connected Devices ===== | + | Over more extensive distances the bus is linked through shielded signal cables ending in female connectors and connected to [[en: |
- | At the command prompt type one of these depending on whether you are using the I2C-X port: | + | In the case of extensive networks I²C is replaced by other physical layer (CAN, Ethernet) that interconnects individual I²C network segments. |
- | sudo i2cdetect -y X | ||
- | 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). | ||
+ | ==== 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. | ||
- | ===== SMBus (System Management Bus) Functions ===== | + | The installation of the [[en: |
- | + | ||
- | 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. | + | |
+ | sudo pip install pymlab | ||
- | write_block_data(int addr,char cmd,long vals[]) | + | In case of having some older version of pymlab already installed, it is enough to run: |
- | Write up to 32 bytes to a device. | + | 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: | ||
- | long[] block_process_call(int addr,char cmd,long vals[]) | + | sudo apt-get install libudev-dev libusb-1.0-0-dev libhidapi-dev python-setuptools python-smbus cython |
- | Block Process Call transaction. | ||
- | I2C Access Functions | ||
+ | ===== Convertors to connect I²C to PC ===== | ||
- | long[] read_i2c_block_data(int addr,char cmd) | + | 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:// |
- | Block Read transaction. | + | ==== USB interface ==== |
+ | Proprietary designs: | ||
- | write_i2c_block_data(int addr,char cmd,long vals[]) | + | * [[http:// |
+ | * [[http:// | ||
+ | * [[http:// | ||
- | Block Write transaction. | + | These share a common problem with a quality of drivers. Furthermore, |
+ | ==== USB HID ==== | ||
- | ===== References ===== | + | To connect without having to use drivers designed for specific hardware [[http:// |
- | * [[http:// | ||
- | * [[http:// |
en/i2c.txt · Last modified: 2014/12/21 10:42 (external edit)