Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMA456 - Trouble with timing and crashing

    Member

    BMA456 - Trouble with timing and crashing

    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

    3 REPLIES 3
    Community Moderator
    Community Moderator

    Re: BMA456 - Trouble with timing and crashing

    Hi Sam,

    1) The sensor's raw output is in LSB. I suspect that -0.06 must be rounding error when converting an invalid value to floating point. I highly doubt that this is coming from the sensor, but the only way to be sure, would be to log the actual state of the bus using a logic analyzer, and compare it with a log of the raw data to make sure that the protocol decoding is working and that there are no communication errors.

    2) At 1.6kHz, the sensor should output data every 625us, not 977us. Could it be that:
    a) your timestamp resolution is not that small ? or
    b) Your MCU is not processing interrupts fast enough to measure all samples ?

    Regarding the variance, I quickly glanced at your code. Are you logging data over a wireless link ? If so, I would first investigate the chances of a simple packet drop. 1953/977 = 1.999, which highly suggests that there was simply a sample that was lost in transmission.

    o_o
    Member

    Re: BMA456 - Trouble with timing and crashing

    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

    Member

    Re: BMA456 - Trouble with timing and crashing

    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. 

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist