Hello,
I'm working on a project with the Teensy Prop Shield (which is awesome by the way) and I'm running into trouble with increasing the IMU sensors output rate from 100 Hz to 200 Hz. I think the problem is related to the fact that there are two sensors on the I2C bus that I'm trying to read near-simultaneously. Let me explain:
First, the datasheets for the FXOS8700CQ and FXAS21002 have a table in their CTRL_REG_01 section that explains what binary values correspond to what data rates. I changed the gyro from 0x0E to 0x0D and the accel/mag from 0x15 to 0x0D.
Now, when I try to read each one individually, I get a data rate of just over 5 ms. However, when I read both together (the same way the library normally does it--literally the only change I've made is those hex values) the data rate collapses to every 10 ms. Clearly there is something about I2C I do not understand, but I am struggling to find resources online. Any help would be much appreciated!
For reference, I've attached the version of the NXPMotionSense library I made the changes in. Literally two lines of code are changed, but whatever.
PS: I've also tried an iterative version, where it reads one sensor repeatedly until it gets a value, then it reads the other sensor. This gets my data rate down to 5.4 ms, but it doesn't scale if, for example, I add another I2C device. This makes me thing I'm doing something wrong with I2C in general.
View attachment NXPMotionSense.zip
I'm working on a project with the Teensy Prop Shield (which is awesome by the way) and I'm running into trouble with increasing the IMU sensors output rate from 100 Hz to 200 Hz. I think the problem is related to the fact that there are two sensors on the I2C bus that I'm trying to read near-simultaneously. Let me explain:
First, the datasheets for the FXOS8700CQ and FXAS21002 have a table in their CTRL_REG_01 section that explains what binary values correspond to what data rates. I changed the gyro from 0x0E to 0x0D and the accel/mag from 0x15 to 0x0D.
Now, when I try to read each one individually, I get a data rate of just over 5 ms. However, when I read both together (the same way the library normally does it--literally the only change I've made is those hex values) the data rate collapses to every 10 ms. Clearly there is something about I2C I do not understand, but I am struggling to find resources online. Any help would be much appreciated!
For reference, I've attached the version of the NXPMotionSense library I made the changes in. Literally two lines of code are changed, but whatever.
PS: I've also tried an iterative version, where it reads one sensor repeatedly until it gets a value, then it reads the other sensor. This gets my data rate down to 5.4 ms, but it doesn't scale if, for example, I add another I2C device. This makes me thing I'm doing something wrong with I2C in general.
View attachment NXPMotionSense.zip