AnsweredAssumed Answered

Problems with ADXL362 motion detection

Question asked by simon12 on May 28, 2014
Latest reply on May 29, 2014 by neilzhao

Hello everybody!

At present I work with the ADXL362 in order to build a vibration monitoring system. Therefore I would like to use the detection mode of the ADXL to get an interrupt  on the INT1/INT2 when the acceleration exceeds or falls below a defined threshold.

After testing the basic examples from the ADXL362 Arduino library, I tried by myself to compile a program. Unfortunately I got some issues. I would be very nice of you if someone on your side could check if the registers were correctly set.

The program runs with ODR = 400Hz in the measurement mode with an absolute threshold configuration. During a standstill I measure a maximum amplitude of 1250. In my opinion I should get a low output on the INT2-pin when I let run my program with a threshold of 1400 for the activity detection. In fact that’s not the case, the INT2-pin output is high all the time!

I have another question concerning the inactivity mode: Is it correct, that the acceleration on all the 3 axes has to be lower than the threshold in order to be able to detect inactivity?

Thank you very much in advance!

Greetings from Germany!

Simon

 

Below the register configuration:

Register

Value

0x20

0x78

0x21

0x05

0x22

0x28

0x27

0x01

0x2B

0x10

0x2C

0x17

0x2D

0x02

 

Arduino Code:

 

#include <SPI.h>

const int slaveSelectPin = 10;

 

void setup(){

    Serial.begin(9600);

    pinMode(slaveSelectPin, OUTPUT);

    SPI.begin();

    SPI.setDataMode(SPI_MODE0); //CPHA = CPOL = 0    MODE = 0

    delay(1000);

   

    // Set Activity Threshold to 1400 -> activity shouldn't be detected (1g = 1250)

    // THRESH_ACT_L

    digitalWrite(slaveSelectPin, LOW);

    SPI.transfer(0x0A);  // write

    SPI.transfer(0x20);  //  Reg 20 THRESH_ACT_L

    SPI.transfer(0x78);  //  Reg 20 = dec 250  

    digitalWrite(slaveSelectPin, HIGH);

    delay(100);

 

    // THRESH_ACT_H

    digitalWrite(slaveSelectPin, LOW);

    SPI.transfer(0x0A);  // write

    SPI.transfer(0x21);  //  Reg 21 THRESH_ACT_H

    SPI.transfer(0x05);  //  Reg 21 = 0x05   

    digitalWrite(slaveSelectPin, HIGH);

    delay(100);

  

    // Set Activity Timer to 40. With ODR = 400Hz after 0.1s activity should be detected

    // TIME_ACT  

    digitalWrite(slaveSelectPin, LOW);

    SPI.transfer(0x0A);  // write

    SPI.transfer(0x22);  //  Reg 22 TIME_ACT

    SPI.transfer(0x28);  // 40/400 => 0.1 sec

    digitalWrite(slaveSelectPin, HIGH);

    delay(100);

   

    // Set Default Mode + Absolute Activity + Activity enable

    // ACT_INACT_CTL

    digitalWrite(slaveSelectPin, LOW);

    SPI.transfer(0x0A);  // write

    SPI.transfer(0x27);  //  Reg 27 ACT_INACT_CTL

    SPI.transfer(0x01);  // ACT_EN

    digitalWrite(slaveSelectPin, HIGH);

    delay(100);

   

    // Configure INT2: map the activity status to INT2

    // INTMAP2

    digitalWrite(slaveSelectPin, LOW);

    SPI.transfer(0x0A);  // write

    SPI.transfer(0x2B);  //  Reg 2B INTMAP2

    SPI.transfer(0x10);  //  ACT

    digitalWrite(slaveSelectPin, HIGH);

    delay(100);

   

    // Set Range 2g + Bandwidth 1/4 ODR + ODR = 400Hz

    // FILTER_CTL

    digitalWrite(slaveSelectPin, LOW);

    SPI.transfer(0x0A);  // write

    SPI.transfer(0x2C);  //  Reg 2B FILTER_CTL

    SPI.transfer(0x17);  //  ODR 400Hz | HALF_BW | 2g

    digitalWrite(slaveSelectPin, HIGH);

    delay(100);

   

    // Select Measurement Mode

    // POWER_CTL

    digitalWrite(slaveSelectPin, LOW);

    SPI.transfer(0x0A);  // write

    SPI.transfer(0x2D);  //  Reg 2D

    SPI.transfer(0x02);  // begin meanusre  

    digitalWrite(slaveSelectPin, HIGH);

    delay(100);

   

    attachInterrupt(0, reset, RISING);

}

 

void loop(){

}

 

// ISR to handle the Interrupt by reading the STATUS-Register

void reset() {

  digitalWrite(slaveSelectPin, LOW);           

  SPI.transfer(0x0B);  // write

  SPI.transfer(0x0B);  //  Reg 20 THRESH_ACT_L

  SPI.transfer(0x00);

  digitalWrite(slaveSelectPin, HIGH);

  Serial.println("interrupt");

  }

Outcomes