I'm currently developing a data logging system and I'm using a bma456 connected to a SparkFun Pro nRF52840 Mini (https://www.sparkfun.com/products/15025) communicating over i2c. I'm working in the Arduino IDE and am having two main issues:
1) At a configuration of 1600Hz, and set up as continuous performance and averaging 4 samples at one time I have issues with the values spiking to -0.06 and crashing (not every time) system. I also note a change in the configuration values that shouldn't be possible as seen in the image.
2) I'm using micros() to stamp a timestamp each serial readout of data from the accelerometer and I note a variance between each value. For example, it will be 977 microseconds between two sets, and then at a seemingly random interval, there will be a difference of 1953 microseconds, but that is the only variance. I would have assumed each accelerometer value to be read at the same delta time moment. Any ideas?
I'm also looking for some advice with fixing the offset in the accelerometer in addition to the advice in attempting to fix these bugs.
Thank you for your time.
Thanks for your response. I actually was working on this over the weekend and concluded that:
1) Is a power/grounding issue on my breadboard. I note that if I hold down my power cables and ground cables the device does not crash.
2) I was using wired i2c when I timestamped data. I am transmitting the code over BlueTooth link but that is post-XYZ-capture. I've switched to SPI over the weekend and I think it might have something to do with micros(). I note the BMA456 does have a Sensor Time (counter that increments at 39.0625 us) that I may investigate.
It does seem weird that the timing is not 625us, I've been following through the code to see if there is any delay in the XYZ capture but there appears to be nothing.
The nrf52840 clk speed is 64Mhz (and I didn't modify the i2c speed so I assume it to be 100 kbit/s) so I don't think its because of the MCU unless there is something fishy going on.
I'll keep you posted. Thanks for your help 🙂
The timing issues are because Serial was slowing it down. Placing it in a buffer and reading through and serial outputting it fixes the timing inconsistency.
My only thing now is I'm trying to get it to synchronise the data correctly. I think my next strategy is to use an interrupt on the accelerometer to alert when data is ready to be captured and then read the data rather than a delay.