Hi,
I am using the nRF51822 MCU and MMA8451Q Accelerometer sensor to detect free fall, I have referred Application note and I am able to detect a free fall if I drop a sensor from a particular height, also I am getting free-fall interrupt when I tilt the sensor around X-axis. I have also disabled free fall along the x-axis and y-axis from FF_MD_CONFIG Register ;
I need free-fall detection only when I drop a sensor from a height, not when I tilt the sensor around the x-axis
here is my free-fall detection configuration settings
free_fall_init()
{
uint8_t data[2];
uint8_t temp;
//Put the device in standby mode
uint8_t CTRL_REG1 = 0x2A;
data[0]= CTRL_REG1;
data[1]= 0x20;
send(data);
//freefall/motion configuration register
uint8_t FF_MD_CONFIG = 0x15;
data[0]= FF_MD_CONFIG;
data[1]= 0xA0;
send(data);
// setting threshould
uint8_t THR_REGISTER = 0x17;
data[0]= THR_REGISTER;
data[1]= 0x03;
send(data);
// setting debounce counter
uint8_t DEBOUNCE_REGISTER = 0x18;
data[0]= DEBOUNCE_REGISTER;
data[1]= 0x06;
send(data);
// Enable motion/freefall interrupt function
uint8_t INT_ENABLE = 0x2D;
data[0]= INT_ENABLE;
data[1]=0x04;
send(data);
//Route the Motion/Freefall Interrupt to INT2 hardware pin
uint8_t INT_2 = 0x2E;
data[0]= INT_2;
data[1]= 0x00;
send(data);
//put the device in active mode
temp = read(&CTRL_REG1);
temp |= 0x01;
data[0]=CTRL_REG1;
data[1]= temp;
send(data);
}
here is my Interrupt handler
void Interrupt2_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
nrf_gpiote_event_clear(NRF_GPIOTE_EVENTS_IN_0); // clearing interrupt flag
uint8_t system_interrupt = read(&SYSTEM_INT); // register 0x0C
status = read(&FF_STATUS); // reading FF_MD_STATUS register to enable next interrupt
dropped = 0x01;
accelerometer_dropped_update(&m_acc,dropped); // notifying client through notification
}
i dont want free fall detection interrupt when i tilt the sensor along x axis
does any one hase solution for this problem ?
thank you
Hi Punit,
If you have only the Z-axis enabled and rotate the sensor along the X or Y-axis, then you always get a state when the Z-axis acceleration value is lower than the threshold value.
In order to avoid generating the freefall interrupt in such a case, you need to enable also the X and Y-axis (FF_MT_CFG = 0xB8).
Hope it helps!
Best regards,
Tomas
PS: If my answer helps to solve your question, please mark it as "Correct" or “Helpful”. Thank you.