====== Converter from I²C to USB with AVR microcontroler (known as i2c-tiny-usb) ====== The subject of this construction is solve frequent problem of connection of I2C or SMBus device on sensor to the computer system. Classical solution of this situation is connecting the I2C device to a microcontroler and then to higher computer system. The main drawback of such method is request of known sensor configuration of sensors connected to the microcontroller. The sensors reaeding is based directly on the version of firmware in the microcontroller. A better solution would be a firmware-less connection to computer system. This aproach allows easy changing of sensor configuration or readout drivers directly in running system. ===== Design of the intstrument ===== ==== Interconnection ==== The principial connection of the instrument follows: {{ :cs:designs:tools:original_schematic.png?direct&400 |}} In real implementation is slightly different and consist several MLAB modules. {{ :cs:designs:tools:i2c-avr-usb_top_big.jpg?direct&500 |}} ==== Firmware ==== Firmware is acessible in [[http://www.mlab.cz/WebSVN/listing.php?repname=MLAB&path=%2FDesigns%2FTools%2Fi2c_AVR_USB%2FSW%2F#_Designs_Tools_i2c_AVR_USB_SW_|MLAB documentation folder]]. ===== Instrument function ===== After connection to the computer we should see a new device on USB. $ sudo lsusb -v -d 0403:c631 Bus 003 Device 018: ID 0403:c631 Future Technology Devices International, Ltd i2c-tiny-usb interface Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 255 Vendor Specific Class bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0403 Future Technology Devices International, Ltd idProduct 0xc631 i2c-tiny-usb interface bcdDevice 1.05 iManufacturer 1 Till Harbaum iProduct 2 i2c-tiny-usb iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 18 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 10mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Device Status: 0x0000 (Bus Powered) Toto zařízení je pak automaticity enumerováno a rozpoznáno jako I2C rozhraní. ==== Enumerace na USB ==== [38601.270471] usb 3-3.1: new low-speed USB device number 18 using xhci_hcd [38601.292607] usb 3-3.1: New USB device found, idVendor=0403, idProduct=c631 [38601.292613] usb 3-3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [38601.292616] usb 3-3.1: Product: i2c-tiny-usb [38601.292618] usb 3-3.1: Manufacturer: Till Harbaum [38601.312318] i2c-tiny-usb 3-3.1:1.0: version 1.05 found at bus 003 address 018 [38601.332450] i2c i2c-8: connected i2c-tiny-usb device [38601.332473] usbcore: registered new interface driver i2c-tiny-usb Then we usually need a load of the i2c-dev kernel module to see a new I2C interface. $ sudo modprobe i2c-dev Then we should see all I2C and SMBus interfaces in our computer. $ 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 DPDDC-C I2C adapter i2c-7 i2c DPDDC-D I2C adapter i2c-8 i2c i2c-tiny-usb at bus 003 device 018 I2C adapter ===== Související stránky ===== * [[en:usbi2c|USBI2C - more recent solution how to do the same work]] * [[en:i2c-pic-usb|I²C to USB converter with PIC microcontroller]] * [[en:i2c|I²C bus in MLAB system]] ==== References ==== * [[http://www.harbaum.org/till/i2c_tiny_usb/index.shtml|i2c-tiny-usb]]