AnsweredAssumed Answered

ADXL362 not functional?

Question asked by MEK on May 23, 2015
Latest reply on May 25, 2015 by neilzhao

Hi All,

After setting up my sparkfun breakboard-mounted ADXL362, and having seen g's about 1.3 while still, I decided to run the self-test on it.

 

I am not too experienced with programming these babies, so please point me to any noob's mistake I might be running into.

 

I followed the instructions in the datasheet and set it up with precision +/-8g's, 100Hz, normal operation (no noise reduction) and no anti-aliasing. It runs on under 3v on an nRF51 DK board.

 

I executed this method:

 

void do_self_test()

{

  uint32_t err_code;

  uint8_t inBuffer[8];//first two are padding, rest if for 6 uint's

  uint8_t regIn;

/*

Self-Test Output Change

  Min Typ Max

XOUT 230 550 870 mg

YOUT -870 -550 -230 mg

ZOUT 270 535 800 mg

*/

  SEGGER_RTT_printf(0, "\r\nSelf testing...\r\n", regIn);

  nrf_delay_ms( 1000 );

  MK_SPI_ReadRegs( MK_ACC_REG_XDATA_L, 6, inBuffer );

  fifo_in_good[0].x = processPairOfUints12BitsSigned( inBuffer[2], inBuffer[3] );

  fifo_in_good[0].y = processPairOfUints12BitsSigned( inBuffer[4], inBuffer[5] );

  fifo_in_good[0].z = processPairOfUints12BitsSigned( inBuffer[6], inBuffer[7] );

  int16_t xG = fifo_in_good[0].x;

  int16_t yG = fifo_in_good[0].y;

  int16_t zG = fifo_in_good[0].z;

  xG *= 4;//to mg's

  yG *= 4;//to mg's

  zG *= 4;//to mg's

  SEGGER_RTT_printf(0, "Original = %03x %03x %03x = %04d %04d %04d; mG = (%d, %d, %d)\r\n",

  fifo_in_good[0].x, fifo_in_good[0].y, fifo_in_good[0].z,

  fifo_in_good[0].x, fifo_in_good[0].y, fifo_in_good[0].z,

  xG, yG, zG );

 

 

  MK_SPI_WriteReg( MK_ACC_REG_SELF_TEST, 0xFF );

 

 

  // wait 4/ODR

  nrf_delay_ms( 40 );

 

 

  int16_t xGacc = 0;

  int16_t yGacc = 0;

  int16_t zGacc = 0;

  for(int i= 0; i < 8; i ++)

  {

  MK_SPI_ReadRegs( MK_ACC_REG_XDATA_L, 6, inBuffer );

  fifo_in_good[0].x = processPairOfUints12BitsSigned( inBuffer[2], inBuffer[3] );

  fifo_in_good[0].y = processPairOfUints12BitsSigned( inBuffer[4], inBuffer[5] );

  fifo_in_good[0].z = processPairOfUints12BitsSigned( inBuffer[6], inBuffer[7] );

  int16_t xGaux = fifo_in_good[0].x;

  int16_t yGaux = fifo_in_good[0].y;

  int16_t zGaux = fifo_in_good[0].z;

  xGaux *= 4;

  yGaux *= 4;

  zGaux *= 4;

  SEGGER_RTT_printf(0, "Reading %d = %03x %03x %03x = %04d %04d %04d; mG = (%d, %d, %d)\r\n", i+1,

  fifo_in_good[0].x, fifo_in_good[0].y, fifo_in_good[0].z,

  fifo_in_good[0].x, fifo_in_good[0].y, fifo_in_good[0].z,

  xGaux, yGaux, zGaux );

  xGacc += xGaux;

  yGacc += yGaux;

  zGacc += zGaux;

  }

  // Div by 8

  xGacc /= 8;

  yGacc /= 8;

  zGacc /= 8;

  SEGGER_RTT_printf(0, "Final mG = (%d, %d, %d)\r\n", xGacc, yGacc, zGacc );

  SEGGER_RTT_printf(0, "Delta mG = (%d, %d, %d)\r\n", xGacc - xG, yGacc - yG, zGacc - zG );

  SEGGER_RTT_WriteString(0, "Done!\n" );

 

 

  MK_SPI_WriteReg( MK_ACC_REG_SELF_TEST, 0x00 );

 

 

  while( true );

}

 

Running it results in the following output (please don't mind the console's bug when formatting ints as hex):

 

Resetting device...

Read ID0 + 3 = 0xFFFFFFAD, 0x1D, 0xFFFFFFF2, 0x02.

FIFO_CTL = 0x0A, FIFO_SAM = 0xFFFFFFFF

FILTER_CTL = 0x83

POWER_CTL = 0x02

 

 

Self testing...

Original = 01F 018 153 = 0031 0024 0339; mG = (124, 96, 1356)

Reading 1 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Reading 2 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Reading 3 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Reading 4 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Reading 5 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Reading 6 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Reading 7 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Reading 8 = 143 FFFFFEE3 258 = 0323 -285 0600; mG = (1292, -1140, 2400)

Final mG = (1292, -1140, 2400)

Delta mG = (1168, -1236, 1044)

 

According to the datasheet, the delta in mg's is way off (by about a factor of 2). Does this mean my 362 is out of combat? or am I doing something wrong in the test procedure?

 

Thanks in advance for any clues you may provide me with.

 

Regards,

 

M.

Outcomes