From: Dave H. <dhy...@gm...> - 2011-01-20 04:17:01
|
Hi Vaibhav, On Wed, Jan 19, 2011 at 5:31 PM, VaibhavGhadiok <vai...@gm...> wrote: > > Hi Dave, > > I've attached the reads and writes with both the SCL and SDA lines for > better understanding. From the pictures below, the Arduino is able to both > write and read, while the Gumstix is only able to write. It does look like > the Camera is sending back ACKs. > > The Gumstix write and the Arduino write are exactly the same. The Gumstix > read fails for some reason compared to the Arduino. > > They both start out the same with: > the address of the device, a write command, an Ack, > the register to read from, an ACK, > then the address of the device again *** > Here they differ, the Arduino gives a read command and gets an ACK and then > the read bytes follow. > > But with the Gumstix it sends a write command for the second device address > and then at that point it just fails. So the correct sequence for the read of a register should be (see page 30 of http://smbus.org/specs/smbus20.pdf titled "Read Byte Protocol) Send a START (SDA falls while SCL is high) Send the slave address, with the R/W bit clear (write) Receive an ACK Send the register to read from Receive an ACK Send a repeated START (SDA falls while SCL is high) Send the slave address, with the R/W bit set (read) Receive an ACK Receive the data to be read Send an ACK Send a STOP (SDA rises while SCL is high) > Is this failure because the protocol is expecting a read at this point not a > write and there's no bytes being sent to write so it just messes up the > whole line? > > I took pictures of reading using the gumstix from a different sensor, and it > behaves just like the Arduino does when reading from the camera. > Image in two parts: > http://dl.dropbox.com/u/16369427/Gumstix%20Read%20of%20Gyro%20Part%201%20-%200x69%200x1C%200x83.JPG > http://dl.dropbox.com/u/16369427/Gumstix%20Read%20of%20Gyro%20Part%202%20-%200x69%200x1C%200x83.JPG > The read from the gyro sensor is: address 0x69, Write bit, Ack, 0x1C, Ack, > address 0x69, Read bit, Ack, 0x83, Stop bit. > > For the camera, it's the same (with different byte values) up until the > second address sending, for some reason when I work with the camera, the > gumstix sends another write bit instead of a read. The gumstix should only be sending a write if its told to. > Both reads (camera and gyro sensor) are done from the command line with i2c > 0x-- rb 0x--, so the code is exactly the same. > > Why might the camera reading not send correctly? The write works just fine > and it gets ACKs as necessary, but the i2c just doesn't execute the read > command correctly with the camera, by not sending an actual read bit after > the addressing the second time. > > > Hi Jason, > > 1.) I'm using a Verdex and couldn't find i2cget/i2cset packages. > > 2.) Yes, I've tried both 100Khz and 400KHz. > > 3.) Sorry, only had access to one lead - new pictures below have both lines. > Write: > Arduino: > http://dl.dropbox.com/u/16369427/Arduino%20Write%20-%200x58%200x30%200x01.JPG > Gumstix: > http://dl.dropbox.com/u/16369427/Gumstix%20Write%20-%200x58%200x30%200x01.JPG > As shown here, both the Arduino and the Gumstix behave exactly the same, > with an ACK after each byte > > Read: > Arduino: > Full view (wide) first, then 3 parts closer view. > http://dl.dropbox.com/u/16369427/Arduino%20Read%200x58%200x36%200x00%200xFF%200xFF%200xFF%20-%20full%20view.JPG > http://dl.dropbox.com/u/16369427/Arduino%20Read%20pt%201%20-%200x58%200x36%200x00%200xFF%200xFF%200xFF.JPG > http://dl.dropbox.com/u/16369427/Arduino%20Read%20pt%202%20-%200x58%200x36%200x00%200xFF%200xFF%200xFF.JPG > http://dl.dropbox.com/u/16369427/Arduino%20Read%20pt%203%20-%200x58%200x36%200x00%200xFF%200xFF%200xFF.JPG > > Gumstix: > Full view (wide) first, then 2 parts closer view. > http://dl.dropbox.com/u/16369427/Gumstix%20Read%20-%200x37.JPG > http://dl.dropbox.com/u/16369427/Gumstix%20Read%20Part%202%20-%200x37.JPG > http://dl.dropbox.com/u/16369427/Gumstix%20Read%20Part%201%20-%200x37.JPG So, you'll notice that when the gumstix drive the line low, the voltage is slightly high than when the camera drives the line low (which is actually good we can tell who is actually driving the line). When you look at the scope trace (Part 2) it looks like the camera is sending the ACK bit one bit early. This essentially means that the ack bit (low) sent from the camera is obliterating the Read bit (one) being sent from the gumstix. The gumstix then waits for the ACK and doesn't get it (SDA is back high again). I see the same thing happen with the Arduino trace as well, but it just ignores it and keeps going. > 4) The Verdex is a 3.3V Gumstix, but I have to take I2C lines from the > robostix, which is 5V, so I use Sparkfun's logic converter to step down from > 5 to 3.3v. It works fine with 2 other i2c sensors I have. > http://www.sparkfun.com/products/8745 That could be a problem. I know that the data sheet for the voltage converter on the robostix explicitly states that using two of them in a row doesn't work. I don't know about using the robostix voltage converter followed by the sparkfun converter. If you could tap into the 3.3v signals that would be better. > 5) Haven't tried a capacitor, but with all the devices plus adding a > capacitor on the line I'm worried I might get close to the capacitance limit > for the i2c lines. Dave Hylands |