Having Issue with Free Fall Detection in MMA8451Q accelerometer sensor

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Having Issue with Free Fall Detection in MMA8451Q accelerometer sensor

1,565 Views
punitchotaliya
Contributor I

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 

0 Kudos
1 Reply

1,494 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

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.

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-1001573%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHaving%20Issue%20with%20Free%20Fall%20Detection%20in%20MMA8451Q%20accelerometer%20sensor%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1001573%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20am%20using%20the%20nRF51822%20MCU%26nbsp%3B%20and%20MMA8451Q%20Accelerometer%20sensor%20to%20detect%20free%20fall%2C%20I%20have%20referred%20Application%20note%20and%20%3CSTRONG%3EI%20am%20able%20to%20detect%20a%20free%20fall%20if%20I%20drop%20a%20sensor%20from%20a%20particular%20height%3C%2FSTRONG%3E%2C%26nbsp%3B%20also%20I%20am%20getting%20free-fall%20interrupt%20when%20I%20tilt%20the%20sensor%20around%20X-axis.%26nbsp%3B%20I%20have%20also%20%3CSTRONG%3Edisabled%20free%20fall%20along%20the%20x-axis%20and%20y-axis%26nbsp%3B%20from%20FF_MD_CONFIG%20Register%20%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20need%20free-fall%20detection%20only%20when%20I%20drop%20a%20sensor%20from%20a%20height%2C%20not%20when%20I%20tilt%20the%20sensor%20around%20the%20x-axis%3C%2FP%3E%3CP%3E%3CSTRONG%3Ehere%20is%20my%20free-fall%20detection%20configuration%20settings%3C%2FSTRONG%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Efree_fall_init()%3CBR%20%2F%3E%20%7B%3CBR%20%2F%3E%20uint8_t%20data%5B2%5D%3B%3CBR%20%2F%3E%20uint8_t%20temp%3B%3CBR%20%2F%3E%20%2F%2FPut%20the%20device%20in%20standby%20mode%3CBR%20%2F%3E%20uint8_t%20CTRL_REG1%20%3D%200x2A%3B%3CBR%20%2F%3E%20data%5B0%5D%3D%20CTRL_REG1%3B%3CBR%20%2F%3E%20data%5B1%5D%3D%200x20%3B%3CBR%20%2F%3E%20send(data)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%2F%2Ffreefall%2Fmotion%20configuration%20register%20%3CBR%20%2F%3E%20uint8_t%20FF_MD_CONFIG%20%3D%200x15%3B%3CBR%20%2F%3E%20data%5B0%5D%3D%20FF_MD_CONFIG%3B%3CBR%20%2F%3E%20data%5B1%5D%3D%200xA0%3B%3CBR%20%2F%3E%20send(data)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%20%2F%2F%20setting%20threshould%20%3CBR%20%2F%3E%20uint8_t%20THR_REGISTER%20%3D%200x17%3B%3CBR%20%2F%3E%20data%5B0%5D%3D%20THR_REGISTER%3B%3CBR%20%2F%3E%20data%5B1%5D%3D%200x03%3B%3CBR%20%2F%3E%20send(data)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%20%2F%2F%20setting%20debounce%20counter%3CBR%20%2F%3E%20uint8_t%20DEBOUNCE_REGISTER%20%3D%200x18%3B%3CBR%20%2F%3E%20data%5B0%5D%3D%20DEBOUNCE_REGISTER%3B%3CBR%20%2F%3E%20data%5B1%5D%3D%200x06%3B%3CBR%20%2F%3E%20send(data)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%20%2F%2F%20Enable%20motion%2Ffreefall%20interrupt%20function%3CBR%20%2F%3E%20uint8_t%20INT_ENABLE%20%3D%200x2D%3B%3CBR%20%2F%3E%20data%5B0%5D%3D%20INT_ENABLE%3B%3CBR%20%2F%3E%20data%5B1%5D%3D0x04%3B%3CBR%20%2F%3E%20send(data)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%20%2F%2FRoute%20the%20Motion%2FFreefall%20Interrupt%20to%20INT2%20hardware%20pin%3CBR%20%2F%3E%20uint8_t%20INT_2%20%3D%200x2E%3B%3CBR%20%2F%3E%20data%5B0%5D%3D%20INT_2%3B%3CBR%20%2F%3E%20data%5B1%5D%3D%200x00%3B%3CBR%20%2F%3E%20send(data)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%20%2F%2Fput%20the%20device%20in%20active%20mode%3CBR%20%2F%3E%20temp%20%3D%20read(%26amp%3BCTRL_REG1)%3B%3CBR%20%2F%3E%20temp%20%7C%3D%200x01%3B%3CBR%20%2F%3E%20data%5B0%5D%3DCTRL_REG1%3B%3CBR%20%2F%3E%20data%5B1%5D%3D%20temp%3B%3CBR%20%2F%3E%20send(data)%3B%3CBR%20%2F%3E%20%7D%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3Ehere%20is%20my%20Interrupt%20handler%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Evoid%20Interrupt2_handler(nrf_drv_gpiote_pin_t%20pin%2C%20nrf_gpiote_polarity_t%20action)%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%20nrf_gpiote_event_clear(NRF_GPIOTE_EVENTS_IN_0)%3B%20%2F%2F%20clearing%20interrupt%20flag%3CBR%20%2F%3Euint8_t%20system_interrupt%26nbsp%3B%20%3D%20read(%26amp%3BSYSTEM_INT)%3B%20%2F%2F%20register%200x0C%3CBR%20%2F%3E%20status%20%3D%20read(%26amp%3BFF_STATUS)%3B%20%2F%2F%20reading%20FF_MD_STATUS%20register%20to%20enable%20next%20interrupt%26nbsp%3B%3CBR%20%2F%3Edropped%20%3D%200x01%3B%3CBR%20%2F%3E%20accelerometer_dropped_update(%26amp%3Bm_acc%2Cdropped)%3B%20%2F%2F%20notifying%20client%20through%20notification%26nbsp%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Ei%20dont%20want%20free%20fall%20detection%20interrupt%20when%20i%20tilt%20the%20sensor%20along%26nbsp%3B%20x%20axis%26nbsp%3B%3C%2FP%3E%3CP%3Edoes%20any%20one%20hase%20solution%20for%20this%20problem%20%3F%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Ethank%20you%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1001574%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Having%20Issue%20with%20Free%20Fall%20Detection%20in%20MMA8451Q%20accelerometer%20sensor%20%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1001574%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Punit%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIf%20you%20have%20only%20the%20Z-axis%20enabled%20and%20rotate%20the%20sensor%20along%20the%20X%20or%20Y-axis%2C%20then%20you%20always%20get%20a%20state%20when%20the%20Z-axis%20acceleration%20value%20is%20lower%20than%20the%20threshold%20value.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIn%20order%20to%20avoid%20generating%20the%20freefall%20interrupt%20in%20such%20a%20case%2C%20you%20need%20to%20enable%20also%20the%20X%20and%20Y-axis%20(FF_MT_CFG%20%3D%200xB8).%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EHope%20it%20helps!%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3ETomas%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CEM%20style%3D%22border%3A%201pt%20none%20windowtext%3B%20font-weight%3A%20inherit%3B%20font-size%3A%209pt%3B%20padding%3A%200in%3B%22%3EPS%3A%26nbsp%3BIf%20my%20answer%20helps%20to%20solve%20your%20question%2C%20please%20mark%20it%20as%20%22Correct%22%20or%20%E2%80%9CHelpful%E2%80%9D.%20Thank%20you.%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E