Hello,
This is my first post so plz go easy on me.
A quick foreword,
I am trying to to best understand I2C protocol and really use it to its maximum potential and not build bad habits. I have an LSM9DS1 orientation sensor that I am using for an IoT project. I have successfully used the sensor using node, then python, now C++. I see that the lower level languages seem to be better for this kind of work bc they have more control and use less resources (I think). One thing I am noticed is that the readings can be pretty noisy (I think is the right term) so averaging can really help reduce the noise. Naturally, I came to the conclusion that the faster I can read data, the more I can average the data, the more accurate the data is. So, I read the datasheet for the sensor more carefully and some of the concepts are hard to understand as they are constantly jumping from register to register. It can be a bit confusing to get the full picture. What I am focused on in this post is:
"The LSM9DS1 embeds 32 slots of 16-bit data FIFO for each of the gyroscope’s three output channels, yaw, pitch and roll, and 16-bit data FIFO for each of the accelerometer’s three output channels, X, Y and Z."
And more specifically I just want the Accelerometer buffer for now at least.
The Questions:
- If I am using the FIFO and interrupt pin, what is the best way to burst read data using I2C?
- If one I2C message can carry 2 bytes (16 bits, 1 word), Can I just read the "low" register and I2C will give me the 16 bit word, low and high together?
- (Continuation of 1.) If I am attempting to empty the FIFO with a burst read, do I read:
In code it would look something like:
readRegisters(foo, OUT_X_XL, 32)
readRegisters(foo, OUT_Y_XL, 32)
readRegisters(foo, OUT_Z_XL, 32)
VS
for (32)
readRegister(foo, OUT_X_XL)
readRegister(foo, OUT_Y_XL)
readRegister(foo, OUT_Z_XL)
Afterword,
My thinking is if I can utilize the built in buffer and the interrupt pin, then I can free up the i2c bus and all the arduino needs to do is average the data. Basically, wait for the FIFO to fill, burst read the data, then average the read data. I am sure this is a common question, but whenever I research I2C, there seems to be plenty on doing basic I2C reading but not a whole lot on the proper way to utilize the FIFO buffer as the manufacturer intended.
Hopefully someone can help! Thanks in advance!