Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMA250 Selftest

    BMA250 Selftest

    elieli
    Member

    Hello

    I am trying to implement inline self-test of the BMA250 accelerometer, mounted on a board at our product. It is calibrated to measure up to 2g. As you point out at the datasheet at table 10, I should see difference of at least 0.8g between +x and -x g values - i.e. difference of 256*0.8=204.8 beteween the values. 

    Unfotrunately I checked in 2 different accelerometers and on x dimention the difference is never larger than 120, so it is not even close. The other 2 axis pass the self-test fine. I put 300 ms sleep between every measure and reading.

    What do you think is the problem?

    Kind reagrds

    Eli

    9 REPLIES 9

    Yanchao
    Community Moderator
    Community Moderator

    Hi,

    I haven't BMA250 datasheet, only refer page 20 self-test of bst-bma253-ds000.pdf .

    One suggestion, when you active each axis, please wait for at least 50 msec, then read register data.

    Or, You could upload this datasheet and code here, I could double check if any problem.

    Best regards.

    Yanchao_0-1610419508279.png

     

    Hi

    I also don't have the latest datasheet and I use this one from muser: https://www.mouser.com/datasheet/2/783/BST-BMA250-DS002-05-786487.pdf

    It is revision 1.15 so maybe there are typos there... Please check if you have access to the most updated datasheet.

    Regarding the code, please see it here in python:

    def selftest(self):

    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.3)

    self.bus.write_byte_data(self.address, 0x32, 0x01)
    time.sleep(0.3)
    data_x_pos = self.bus.read_i2c_block_data(self.address, 0x02, 2)
    # Convert the data to 10 bits
    Accl_x_pos = (data_x_pos[1] * 256 + (data_x_pos[0] & 0xC0)) / 64
    if Accl_x_pos > 511 :
    Accl_x_pos -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.3)

    self.bus.write_byte_data(self.address, 0x32, 0x05)
    time.sleep(0.3)
    data_x_neg = self.bus.read_i2c_block_data(self.address, 0x02, 2)
    # Convert the data to 10 bits
    Accl_x_neg = (data_x_neg[1] * 256 + (data_x_neg[0] & 0xC0)) / 64
    if Accl_x_neg > 511 :
    Accl_x_neg -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.3)


    self.bus.write_byte_data(self.address, 0x32, 0x02)
    time.sleep(0.3)
    data_y_pos = self.bus.read_i2c_block_data(self.address, 0x04, 2)
    # Convert the data to 10 bits
    Accl_y_pos = (data_y_pos[1] * 256 + (data_y_pos[0] & 0xC0)) / 64
    if Accl_y_pos > 511 :
    Accl_y_pos -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.3)

    self.bus.write_byte_data(self.address, 0x32, 0x06)
    time.sleep(0.3)
    data_y_neg = self.bus.read_i2c_block_data(self.address, 0x04, 2)
    # Convert the data to 10 bits
    Accl_y_neg = (data_y_neg[1] * 256 + (data_y_neg[0] & 0xC0)) / 64
    if Accl_y_neg > 511 :
    Accl_y_neg -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.3)

    self.bus.write_byte_data(self.address, 0x32, 0x03)
    time.sleep(0.3)
    data_z_pos = self.bus.read_i2c_block_data(self.address, 0x06, 2)
    # Convert the data to 10 bits
    Accl_z_pos = (data_z_pos[1] * 256 + (data_z_pos[0] & 0xC0)) / 64
    if Accl_z_pos > 511 :
    Accl_z_pos -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.3)

    self.bus.write_byte_data(self.address, 0x32, 0x07)
    time.sleep(0.3)
    data_z_neg = self.bus.read_i2c_block_data(self.address, 0x06, 2)
    # Convert the data to 10 bits
    Accl_z_neg = (data_z_neg[1] * 256 + (data_z_neg[0] & 0xC0)) / 64
    if Accl_z_neg > 511 :
    Accl_z_neg -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.3)

    return Accl_x_pos, Accl_x_neg, Accl_y_pos, Accl_y_neg, Accl_z_pos, Accl_z_neg

    the output of the function is:

    selftest acc results:
    -59.0
    86.0
    -218.0
    285.0
    146.0
    359.0

    as you can see, both x axis values are with much smaller difference then needed. The IMU lays stable on the table with z axis looking downwards.

    Yanchao
    Community Moderator
    Community Moderator

    Hi,

    Two suggestion, please try.

    1 After softreset, add 10 mec delay.

    2 adjust x/y/z Self-test sequence, maybe result is different.

    Unfortunately it does not seem to help...

    I changed the seqence of the test to z-y-x and changed the delay after every softreset to 0.01:

    def selftest(self):

    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.01)

    self.bus.write_byte_data(self.address, 0x32, 0x03)
    time.sleep(0.3)
    data_z_pos = self.bus.read_i2c_block_data(self.address, 0x06, 2)
    # Convert the data to 10 bits
    Accl_z_pos = (data_z_pos[1] * 256 + (data_z_pos[0] & 0xC0)) / 64
    if Accl_z_pos > 511 :
    Accl_z_pos -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.01)

    self.bus.write_byte_data(self.address, 0x32, 0x07)
    time.sleep(0.3)
    data_z_neg = self.bus.read_i2c_block_data(self.address, 0x06, 2)
    # Convert the data to 10 bits
    Accl_z_neg = (data_z_neg[1] * 256 + (data_z_neg[0] & 0xC0)) / 64
    if Accl_z_neg > 511 :
    Accl_z_neg -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.01)

    self.bus.write_byte_data(self.address, 0x32, 0x02)
    time.sleep(0.3)
    data_y_pos = self.bus.read_i2c_block_data(self.address, 0x04, 2)
    # Convert the data to 10 bits
    Accl_y_pos = (data_y_pos[1] * 256 + (data_y_pos[0] & 0xC0)) / 64
    if Accl_y_pos > 511 :
    Accl_y_pos -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.01)

    self.bus.write_byte_data(self.address, 0x32, 0x06)
    time.sleep(0.3)
    data_y_neg = self.bus.read_i2c_block_data(self.address, 0x04, 2)
    # Convert the data to 10 bits
    Accl_y_neg = (data_y_neg[1] * 256 + (data_y_neg[0] & 0xC0)) / 64
    if Accl_y_neg > 511 :
    Accl_y_neg -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.01)

    self.bus.write_byte_data(self.address, 0x32, 0x01)
    time.sleep(0.03)
    data_x_pos = self.bus.read_i2c_block_data(self.address, 0x02, 2)
    # Convert the data to 10 bits
    Accl_x_pos = (data_x_pos[1] * 256 + (data_x_pos[0] & 0xC0)) / 64
    if Accl_x_pos > 511 :
    Accl_x_pos -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.01)

    self.bus.write_byte_data(self.address, 0x32, 0x05)
    time.sleep(0.03)
    data_x_neg = self.bus.read_i2c_block_data(self.address, 0x02, 2)
    # Convert the data to 10 bits
    Accl_x_neg = (data_x_neg[1] * 256 + (data_x_neg[0] & 0xC0)) / 64
    if Accl_x_neg > 511 :
    Accl_x_neg -= 1024
    self.bus.write_byte_data(self.address, 0x14, 0xB6)
    time.sleep(0.01)

    return Accl_x_pos, Accl_x_neg, Accl_y_pos, Accl_y_neg, Accl_z_pos, Accl_z_neg

    the results of the few runs I did for +x, -x, +y, -y, +z, -z order (in many seqences) are as follows:

    nvidia@tegra-ubuntu:~/Downloads$ sudo python3 imu.py
    IMU operation - Please choose CALIB or SELFTEST or READ
    SELFTEST
    selftest acc results:
    -59.0
    85.0
    -220.0
    283.0
    146.0
    356.0
    nvidia@tegra-ubuntu:~/Downloads$ sudo python3 imu.py
    IMU operation - Please choose CALIB or SELFTEST or READ
    SELFTEST
    selftest acc results:
    -59.0
    84.0
    -219.0
    286.0
    147.0
    359.0
    nvidia@tegra-ubuntu:~/Downloads$ sudo python3 imu.py
    IMU operation - Please choose CALIB or SELFTEST or READ
    SELFTEST
    selftest acc results:
    -61.0
    84.0
    -221.0
    285.0
    147.0
    359.0
    nvidia@tegra-ubuntu:~/Downloads$

    Same type of results is for another BMA250 accelerometer I tried... what do you suggest?

    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