|DMS Consulting | sitemap | log in
|This is a free Spanglefish 1 website.
Java I2C Software
The idea behind this project was to write Java JNI routines to allow Java to drive an I2C bus. The bus could be on any machine that could run Java - all that would be required was the JNI routine and an I2C bus.
The package was developed on a PC using Eclipse and Java. There were three specific parts.
I2C - Inter Integrated Circuit - is a multi master, multi slave, single ended serial computer bus invented by Philips Semi Conductor. It consists of three wires - Serial Data Line - SDA Serial Clock Line - SCL Ground The bus will run at several speeds - 100 KHz, 20KHz, 400 KHz, 750 KHZ. The master controller can talk to up to 128 slave units using 7 bit addressing.
A large number of I2C chips are now available and most are not expensive. Each chip has a base address and often more addresses that can be wired. The chips - Control motors - on, off, forward, backward, slow, fast Control lights - on, off, blink, vary brightness A2D - measure current, voltage or resistance D2A - adjust voltage Range finders - Ultra sonic, Laser
The Bus Hardware
To add an I2C bus to a PC, a USB Dongle was used. There were saveral available - I bought the YS-CH341T on EBay. It has a major problem in that it does not support 'clock stretching' but in most cases, slowing the baud rate works.
Using the Raspberry Pi is very straight forward. The I2C bus is on the GPIO. Connect to pins 3-SDA, 5-SCL and 6-GND. Using the Pi's 5V is not advisable as there is not a lot of spare current available.
Looking on the web for a better I2C dongle, I found the UMFT4222EV supplied by a company based in Glasgow. The product is new and some of the software is still being developed. The advantages of this device are that it supports different baud rates and also clock stretching.
The PC can support I2C by using a USB Dongle. These devices require device drivers before my Java JNI programs can talk to them.
The Raspberry Pi has it's own I2C and should only require a simple JNI driver. To use the UMFT4222EV you will need different JNI drivers.