This entry was posted in piDrone and tagged ESC, Gravity, Sampling by Hove. Bookmark the permalink.
I think you can avoid this problem by using readList from i2c.
readList increments the register address per byte. I used to use it when I was reading the 14 sequential data registers directly; the problem with that was the code had to wait for the next sample to be available and couldn't risk missing one; I swapped to the IMU I2C FIFO because it means the IMU puts every sample in the FIFO, so my code can do something else (like use other sensors), and then come back to the FIFO to get any sensor readings that had happened in the mean time.
You could use readList to read 12 bytes from the FIFO buffer.
I was doing something like this in C and when I was reading all bytes from FIFO buffer I got a error that look similar to yours.
But It worked when I read each batch individually (12 bytes).
Maybe it is related to your problem.
Maybe reading all FIFO or reading individual bytes can lead to errors.
Does sound related, but for me smbus.readList increments the I2C address per byte. This was how I could read all the registers directly by a single readList(14). But for the FIFO, readList(12) on address 0x74 returns one byte each from 0x74 – 0x7F, whereas I need 12 reads all on 0x74. That's why I'm having to read it byte by byte.
Do you know if there's a way to make readList _NOT_ increment the I2C register address per byte. Or is that a function of the I2C slave depending on the register being read? Should I just try it and see?
Lol, actually I was reading all FIFO including incomplete data 😛 (leading to error).
When you power up the motors below the hovering speed, It produces the same errors?
I owe you a beer! Just tried readList on the FIFO address(0x74), and it reads the 12 bytes from the same address – a passive flight is showing valid readings for gravity etc. That was completely unexpected! When I do a readList on the accelerometer address (0x3B), I got one byte each from 0x3B to 0x48!
Even better, it's a fine day tomorrow, so I can test it outside!