09-27-2019 09:57 AM
Hi there,
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.
Kind Regards,
Sam
09-27-2019 03:44 PM
10-01-2019 05:54 AM - edited 10-01-2019 05:57 AM
Hi o_o,
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 🙂
srob95
10-03-2019 06:55 AM
Edit 2:
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.