Hi Graham,
It looks like the MPU9250 has a non standard (to my way of thinking) I2C read sequence that requires you to resend the register address as part of a consolidated write/read sequence. The default tool i2cget does not deal with this, and only deals with simple (standard to my way of thinking) read sequences.
It’s not the MPU9250 that’s causing the problem. This is the IMU built into the Beaglebone Blue and connect to I²C bus #0. The example I posted uses the input of the IMU to control the motors via the PicoBorgRev board. Reading the IMU on I²C bus 0 works like a charm, btw. Only reading from the motor controller does not work.
Since you can write to the device, and a write requires an acknowledgement from the device, there is nothing wrong down at the hardware and low-level driver level.
Ok, I didn’t know that.
If you are using Python, I would suggest using Python 2.7 rather than Python 3. At least to get started, until you are in control.
I’m a fairly advanced Python programmer and I don’t want to start off with something as deprecated as Python 2.7. Nonetheless, I tried a Python 2.7 of my code, and it yields the same results: Writing to the motor controller works, while reading from it doesn’t.
The last time I did Python control of I2C, you needed to load python-smbus, and it had not yet been updated for Python 3 compatibility.
There are inofficial ports that work. One is in my repo: GitHub - tkurbad/python3-smbus. Works well with Raspberry PI and the built-in devices of the Beaglebone that are connected to I²C bus #0 (i.e. IMU and barometric pressure sensor).
Just for completeness’ sake, I created a very simple test script using Python 2.7 (it does exactly the same as the original Python code for the motor controller does during init):
`
#!/usr/bin/python2
import smbus
address = 0x44
id_cmd = 0x99
i2c_max_len = 4
bus = smbus.SMBus(1)
i2cread = bus.read_i2c_block_data(address, id_cmd, i2c_max_len)
print “Raw I2C read result:”, i2cread
print “Would yield a version of:”, i2cread[1]
`
If I run the script, this is the result:
tkurbad@beaglebone:~$ python revision.py
Raw I2C read result: [0, 0, 204, 204]
Would yield a version of: 0
The correct value of i2read[1] would be 21 (or 0x15), not 0.
The raw result, btw., is also the same, regardless of what register of the motor controller I read from.
So, I’m still convinced that it has to do with the hardware and/or the setup of the I²C bus of the beaglebone…
Where else could I look?
Best, Torsten