cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSOX INT1 & INT2 Trigger on Tap Detection

Christopher1971
Associate II

Hi,

I have designed a circuit with the LSM6SDOX.

It is operating via the I2C BUS and the Gyroscope and Accelerometer are sending data. I have also managed to configure Single and Double Tap detection, however it is the tap detection where I have an issue.

When I single tap, it works and triggers INT1 on the Microcontroller, when I double tap, it also works and triggers INT2, however the double tap also triggers the single tap at the same time.

The registers are configured as follows in the function below.

Please see a screen capture from my Oscilloscope attached. Yellow is the Single Tap, while Blue is the Double Tap. Hopefully it will be self explanatory.

Can anyone point me in the right direction on how I stop INT1 from triggering when INT2 is detected?

Thanks. 

 

INT1 and INT2.PNG

/*-----------------------------------------------------------------*/

void configureRegisters() {
 
// Set FUNC_CFG_ACCESS and PIN_CTRL registers
writeRegister(LSM6DSOX_ADDRESS, FUNC_CFG_ACCESS, B00000000);
writeRegister(LSM6DSOX_ADDRESS, PIN_CTRL, B00000000);
 
// Configure INT1 and INT2 to trigger on tap events
writeRegister(LSM6DSOX_ADDRESS, INT1_CTRL, B00000000);
writeRegister(LSM6DSOX_ADDRESS, INT2_CTRL, B00000000);
 
// Configure tap detection registers
writeRegister(LSM6DSOX_ADDRESS, TAP_CFG0, B00001110);
writeRegister(LSM6DSOX_ADDRESS, TAP_CFG1, B00001111);
writeRegister(LSM6DSOX_ADDRESS, TAP_CFG2, B10001000);
writeRegister(LSM6DSOX_ADDRESS, TAP_THS_6D, B00001000);
writeRegister(LSM6DSOX_ADDRESS, TAP_SRC, B00110000);
 
writeRegister(LSM6DSOX_ADDRESS, INT_DUR2, B00111111);
writeRegister(LSM6DSOX_ADDRESS, WAKE_UP_THS, B10000000);
writeRegister(LSM6DSOX_ADDRESS, MD1_CFG, B01000000);
writeRegister(LSM6DSOX_ADDRESS, MD2_CFG, B00001000);
 
// Additional configurations for the LSM6DSOX:
writeRegister(LSM6DSOX_ADDRESS, CTRL1_XL, B01011100);
writeRegister(LSM6DSOX_ADDRESS, CTRL2_G, B01011100);
writeRegister(LSM6DSOX_ADDRESS, CTRL3_C, B00000100);
writeRegister(LSM6DSOX_ADDRESS, CTRL4_C, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL5_C, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL6_C, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL7_G, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL8_XL, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL9_XL, B11100000);
writeRegister(LSM6DSOX_ADDRESS, CTRL10_C, B00000000);
}
1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @Christopher1971 ,

Welcome to ST Community!

The single tap interrupt is triggered by the first tap of the double tap, so it has to be there.

What I can suggest is to check for both interrupts in the INT1 routine and continue doing what you have to do for the single tap only if just the INT1 is triggered.

 

To better explain, here is the pseudo code:

int1_callback(){

  int1_up = 1;

}

 

int2_callback(){

  int2_up = 1;

}

 

main(){

  while(1){

    if((int1_up==1) && (int2_up==0)){

      /// int1 routine

    }

    if(int2up==1){

      /// int2 routine

    }

  }

}

If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster :)

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

7 REPLIES 7
Federica Bossi
ST Employee

Hi @Christopher1971 ,

Welcome to ST Community!

The single tap interrupt is triggered by the first tap of the double tap, so it has to be there.

What I can suggest is to check for both interrupts in the INT1 routine and continue doing what you have to do for the single tap only if just the INT1 is triggered.

 

To better explain, here is the pseudo code:

int1_callback(){

  int1_up = 1;

}

 

int2_callback(){

  int2_up = 1;

}

 

main(){

  while(1){

    if((int1_up==1) && (int2_up==0)){

      /// int1 routine

    }

    if(int2up==1){

      /// int2 routine

    }

  }

}

If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster :)

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Federica,

Thanks for replying. 

I'm very pleased as this means I understood the registers after all!

It is the best answer!

Regards,

Christopher

Hi Christopher1971. I'm trying to enable double tap on lsm6dsox. If your code works correctly, can you share it with me?

 

Hi,

No problem, the code works, but as Federica has said, I need to write a function to separate a single click from a double click. I will do this via a timing "If" statement, that when INT1 is detected, it will wait for X milli-seconds to see if INT2 is also detected before changing the selected variable.

Please see attached my test Arduino INO file as a word document. Remember to save the code into a file and folder with exactly the same names ending in INO as I am using Arduino  IDE v 2.

When reading the file, you will see references to "Schmitt Triggers", please ignore them as they are for the circuit I have designed.

Regards,

Christopher

Thank you Christopher1971. I will add it to my project, taking into account what you said.

ajanky
Associate

thank you for your input and your test code.
- just one remark:

Application note AN5272 states:
"Single and double-tap recognition work independently of the selected output data rate. Recommended minimum accelerometer ODR for these functions is 417 Hz."

Your code seems to use only 104Hz

 

best regards

ajanky

Christopher1971
Associate II

Hi Ajanky,

I have looked at my code and I haven't defined the FIFO_CTRL3 (09h) register you refer to.

Therefore, as I am not setting any values in this register, it uses the default register values on power up.

Looking at the datasheet, it states that "Gyro not batched in FIFO (default)", so these settings do not apply.

I haven't read AN5272 as my code is working as well as the circuit/PCB for my purposes.

Regards,

Christopher