Post Go back to editing

ADXl345 - number of Samples for ODR - 3200

Dear Sir/Madam, 

This is Srinivasa Rao Beera , working with Akrivia Automation. We are working on motor health monitoring project and we have selected ADXL345 . We are using 3200 Hz as output data rate. When we monitor output data samples from adxl345 , it is not exactly nearby 3200 number of samples. 

For example if we take 3 Nos adxl345 sensors, all three are not giving same number of samples . 

First sensor is giving 3180 samples 

Second sensor is giving 3260 samples 

Third sensor is giving 3300 samples. 

How can we get all sensors are in same page ?  Atleast 3200 samples +/- 5 samples in all the sensors. We have purchased 300 Nos sensor , so please help in this regard. 

  • Hi Srinivasa,

    It seems like you may be measuring your rate of data acquisition as opposed to the ODR of the ADXL345? How exactly did you measure the above results?

    The ADXL34x devices produce data using an internal clock, which is independent of your communication signals (when the timing of those signals is within datasheet-provided guidelines). The ADXL345 uses an RC oscillator for clock generation with an accuracy of +/-10% over temperature and accounting for any drift over time. When new data is ready, the data-ready signal (when configured correctly) will pulse. This signal provides an opportunity for you to measure the ODR.

    If you can measure the time between DATA_READY interrupts in your set-up, you may be able to get a more accurate ODR measurement. The acceleration data is sampled at a rate given by the ODR configured by the user (register 0x2C BW_RATE). If what you are trying to achieve is to acquire data in a synchronous way, you can do so by mapping the DATA_READY bit of register INT_SOURCE (0x30) to an interrupt pin, and using this pin for synchronization. Any time a set of data (X,Y,Z) is ready, DATA_READY will be set to HIGH. Once you read the registers 0x32 to 0x37, DATA_READY will automatically set to low. This is well explained in page 20 of the datasheet.

    I hope this helps.

    Chris

  • Dear Chris, 

    Thank you for your support. 

    We are acquiring the data in a synchronous way only by  mapping the DATA_READY bit of register INT_SOURCE (0x30) to an interrupt pin (INT2). 

    Below we are providing the code for your reference, If you have any feedback on this , please let me know. 

    void adxl345_setInterrputs(adxl345_int intType, bool intPin)
    {
    adxl345_setRegBit(ADXL345_INT_ENABLE, intType, ENABLE);
    adxl345_setRegBit(ADXL345_INT_MAP, intType, intPin);
    }

    uint8_t adxl345_readAndClearInterrupts(void)
    {
    uint8_t regVal;
    adxl345_RegRead(ADXL345_INT_SOURCE, &regVal, 1);
    return regVal;
    }

    main()
    {
    while(1)
    {
    HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
    adxl345_setInterrputs(ADXL345_DATAREADY, ADXL345_INT2_PIN);
    adxl345_readAndClearInterrupts();

    HAL_Delay(1000);
    adxl345_deleteInterrupt(ADXL345_DATAREADY);
    HAL_NVIC_DisableIRQ(EXTI9_5_IRQn);
    printf("Data Aquisition time Finished\r\n");
    adxl345_setMeasureMode(DISABLE);
    }
    }

    void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
    {
    if(GPIO_Pin == INT2_PIN) {
    FuncOn_Data_Aquisition();


    }
    }

    Thanks

    Srinivas