Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    How to store bma280 acceleration data at 2000 Hz sampling speed

    Highlighted
    Member

    How to store bma280 acceleration data at 2000 Hz sampling speed

    In the XDK datasheet I can see that the bma280  accelerometer has the highest sampling speed of 2000 Hz. I would like to know how can I set the 2000 Hz speed because I can see that the highest bandwidth I can set for the accelerometer is 500Hz. Also, as I want to store the data from the accelerometer using the XDK, how can I store 2000 samples per second? Right now, with 500 Hz Bandwidth, I am using a timer which calls a function every one millisecond. The function then reads the sensor data and writes it to the sd card. But for 2000 sampling speed, I need to call the timer every 0.5 milli second and the timer function does not support a half millisecond repetition rate. So, briefly, I would like to know two things?
    How can I set the sampling speed of the BMA 280 to 2000 Hz?
    If  I am able to get 2000 samples per second, how can I store the data that fast in the SD card?
    Thank you.

    3 REPLIES 3
    Highlighted
    Occasional Visitor

    Re: How to store bma280 acceleration data at 2000 Hz sampling speed

    Hi Ankit,

    There is a mistake in the data sheet. The XDK has a BMA150 and not the other part number you mentioned.

    Software Timers will only allow you a resolution of 1ms (the OS tick), so in order to read with 2000Hz, you have to use the support from the BMI150:

    Please configure the BMI150 to use the desired ODR and signal path filtering settings. Also enable the Data Ready interrupt: The BMI150 has a data-ready interrupt pin which is connected to the XDK micro-controller so on every acquired sample, the sensor notifies this to the XDK. On the XDK side you have an interrupt handler which signals a OS task to read data from the BMI150 as the SPI/I2C read functions will not work in interrupt context.

    Tags (2)
    Highlighted
    Member

    Re: How to store bma280 acceleration data at 2000 Hz sampling speed

    As far as I have understood from your solution, I have configured the BMI160 accelerometer of the XDK for my purpose which has a bandwidth of 1600Hz. Now, to read the data, I am creating a task; the task calls a function which goes trough an infinite while loop and and keeps storing the accelerometer data. I keeps this task alive for 1 minute using vTaskDelay(60000) and then I suspend this task. With this, I achieve, quite a high speed for sure. But now, after one minute, its storing different number of datas. For example, Once I got 146701 samples after one minute, i.e around 2445 samples/second the other time I got 150940 samples, i.e. 2515 samples/second. I have to stabilize it to a fixed rate. Can you give a solution to that? I am attaching the code I am using for this to read the accelerometer data. Also I am attaching screenshot of the data that I stored in the csv files for 2 different times. Thank you.

     while(1)
     {
         Retcode_T returnValue = RETCODE_FAILURE;
         char acelBuffer[100] = { 0 };

      
         Accelerometer_XyzData_T bmi160 = {INT32_C(0), INT32_C(0), INT32_C(0)};
         memset(&bmi160, 0, sizeof(CalibratedAccel_XyzMps2Data_T));
         returnValue = Accelerometer_readXyzGValue(xdkAccelerometers_BMI160_Handle,&bmi160);
         long int valueAccl=(long int) bmi160.zAxisData;
         if (RETCODE_OK == returnValue) {
      memset(&acelBuffer, 0x00, sizeof(acelBuffer));
      sprintf(acelBuffer, "%ld\n", valueAccl);
      writeDataIntoFileOnSdCard(acelBuffer);
         }
    Tags (1)
    Highlighted
    New Poster

    Re: How to store bma280 acceleration data at 2000 Hz sampling speed

    Hi Ankit,

    Can you describe more about sensor configuration and number of task running in the application ?

    From your queries, i understood that you are suspending the task after 60seconds but without any conditon check, how could task suspended from the while loop?

    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