SRF08 is an ultra sonic range finder, I'm trying to connect it to BeagleBoard. The hardware interface is i2c and we need to do some modify to kernel & u-boot to get it work.
http://www.robot-electronics.co.uk/htm/srf08tech.shtml
Reference
http://yetanotherhackersblog.wordpress.com/2011/04/07/interfacing-the-beagleboard-with-an-srf08-ultrasonic-ranger-over-i2c/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+BeagleBoard+%28BeagleBoard.org%29&utm_content=FaceBook
1.Hardware interface
BeagleBoard i2c interface runs at 1.8v and SRF08 i2c interface runs at 5v. In order to get it work, we need i2c level shift. There are some chips can do it, what I got is PCA9517.
http://elinux.org/BeagleBoard_Hardware_Interfacing
http://ics.nxp.com/support/documents/interface/pdf/an97055.pdf
2.The circuit
We are planing to use BeagleBoard I2C2 interface, which pins are at expansion connector pin 23 and 24.
Be attention ! all the 10k resisters are rquired.
http://groups.google.com/group/beagleboard/browse_thread/thread/a6c42ef56c6a2da2/1608e6c0f0207a8d?lnk=raot
3.u-boot
First, make sure the pin mux is correct.
boards/ti/beagle/beagle.h
-MUX_VAL((CP(I2C2_SCL), (IEN | PTU | EN | M4) \
-MUX_VAL((CP(I2C2_SDA), (IEN | PTU | EN | M4) \
+MUX_VAL((CP(I2C2_SCL), (IEN | PTU | EN | M0) \
+MUX_VAL((CP(I2C2_SDA), (IEN | PTU | EN | M0) \
Then enable pull-up internal resister on i2c2
http://groups.google.com/group/beagleboard/browse_thread/thread/f5d308f24b27bb38/21febf1a98e0be0c?lnk=raot
4.kernel
Enable I2C2 interface
static int __init omap3_beagle_i2c_init(void)
{
omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
ARRAY_SIZE(beagle_i2c_boardinfo));
+#if defined CONFIG_INPUT_ST_MOTION_SENSOR
omap_cfg_reg(AE4_34XX_GPIO136);
omap_register_i2c_bus(2, 400, beagle_i2c2_boardinfo,
ARRAY_SIZE(beagle_i2c2_boardinfo));
+#else
+ omap_register_i2c_bus(2, 100, NULL, 0);
+#endif
/* Bus 3 is attached to the DVI port where devices like the pico DLP
* projector don't work reliably with 400kHz */
omap_register_i2c_bus(3, 100, NULL, 0);
return 0;
}
Then you can find /dev/i2c-2 device node
5.Testing
# ls /dev/i2c-2 -al
crw-rw---- 1 root root 89, 2 Jan 1 00:00 /dev/i2c-2
# i2cdetect -r 2
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --
Get range in centimeters
# i2cset 2 112 0 81
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will write to device file /dev/i2c-2, chip address 0x70, data address
0x00, data 0x51, mode byte.
Continue? [Y/n] y
# i2cget 2 112 2
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will read from device file /dev/i2c-2, chip address 0x70, data address
0x02, using read byte data.
Continue? [Y/n] y
0x00
# i2cget 2 112 3
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will read from device file /dev/i2c-2, chip address 0x70, data address
0x03, using read byte data.
Continue? [Y/n] y
0x25
We got 0x25 = 37 cm
沒有留言:
張貼留言