AnsweredAssumed Answered

ADXL345 change BW_RATE on running generate ACTIVITY interrupt

Question asked by Maurizio_IT on Jul 4, 2018
Latest reply on Jul 6, 2018 by neilzhao

Dear Analog Support team,

 I'm using ADX345 for al long time on my design. I want reduce the current when there isn't any movement of the peaple that is under tracking when INACTIVITY interrupt assert. I try to change the BW_RATE from 50Hz to 12,5Hz after INACTIVITY event, but it happen a ACTIVITY interrupt immeditly after this change.

Her is my corrent configuration:

 

 

  ADXL345_SetRegisterValue(ADXL345_POWER_CTL, 0x0); //standby mode at startup. 
  ADXL345_SetRegisterValue(ADXL345_INT_ENABLE, 0x00); //disable interrupt 
  register_val = ADXL345_GetRegisterValue(ADXL345_DEVID) ;//check ID if Read operation works
  if(register_val == ADXL345_ID)
  {
   printf("ADXL345 WHOIAM[0xE5]=0x%x configure..", register_val );
  }
  /*Chip inizialization. */
  ADXL345_SetRegisterValue(ADXL345_BW_RATE, XL345_RATE_50); //data rate 
  ADXL345_CurrentDataRate = XL345_RATE_50;
  /*start INACTIVITY SETTING INT1 */
  ADXL345_SetRegisterValue(ADXL345_INT_MAP, 0x00); //map all on INT1 

  ADXL345_SetRegisterValue(XL345_THRESH_INACT, 0x05); 
  ADXL345_SetRegisterValue(XL345_TIME_INACT, 10); 

  ADXL345_SetRegisterValue(XL345_ACT_INACT_CTL, XL345_INACT_Z_ENABLE|XL345_INACT_Y_ENABLE|XL345_INACT_X_ENABLE|XL345_INACT_AC); 
  
  /*Start FIFO settings and watermark level */
  ADXL345_SetRegisterValue(ADXL345_FIFO_CTL, ADXL345_FIFO_MODE(ADXL345_FIFO_STREAM) | ADXL345_TRIGGER | ADXL345_SAMPLES(31)); //FIFO mode 0xF samples WTMK INT1
  ADXL345_SetRegisterValue(XL345_DATA_FORMAT, XL345_FULL_RESOLUTION | XL345_DATA_JUST_RIGHT | XL345_RANGE_16G);  

 /*End FIFO settings */

 

  ADXL345_SetRegisterValue(ADXL345_INT_ENABLE,  ADXL345_WATERMARK |  ADXL345_FREE_FALL); 
  ADXL345_SetRegisterValue(ADXL345_POWER_CTL, ADXL345_PCTL_MEASURE); //start to measure

 

 

When I detect INACTIVITY interrupt this the code when I try to change BW_RATE:

case ADXL_INACTIVITY:

.....

    if( ADXL345_CurrentDataRate == XL345_RATE_50 )
    {
     ADXL345_SetRegisterValue(ADXL345_POWER_CTL, 0x0); //standby mode to change registers
     ADXL345_SetRegisterValue(ADXL345_INT_ENABLE, 0x00); //disable interrupt      
     ADXL345_SetRegisterValue(ADXL345_BW_RATE, XL345_RATE_12_5); //reduce data rate from XL345_RATE_50
     ADXL345_CurrentDataRate = XL345_RATE_12_5;
     ADXL345_SetRegisterValue(ADXL345_INT_ENABLE, ADXL345_ACTIVITY | ADXL345_INACTIVITY | ADXL345_FREE_FALL);
     ADXL345_SetRegisterValue(ADXL345_POWER_CTL, ADXL345_PCTL_MEASURE); //no sleep, measure active start again      
    }

 

After reduction of BW_RATE setting ADXL345 assert ACTIVITY interrupt bit, even it is stable on desk.

Why this happen?

How to avoid that and what is suggested procedure to change BW_RATE on fly (up scale and down scale)?

 

Thank you for support.

Regards

 

Maurizio

Outcomes