02-24-2021 04:02 PM
Good morning,
i start working with BMA400 accelerometer and i would like to detect activity mode.
I want to blink a led each time a receive an interrupt.
Setup procedure:
BMA_WriteRegister(0x7E, 0xB6); --> software reset (maybe optional)
BMA_WriteRegister(0x19, 0x02); --> normal mode
BMA_WriteRegister(0x1A, 0x38); --> range 2G, ODR 100 HZ, osr highest accuracy
BMA_WriteRegister(0x21, 0x04); --> enable generic interrupt 1 to int1 pin
BMA_WriteRegister(0x20, 0x00); --> non latched mode
BMA_WriteRegister(0x24, 0x02); --> int1 pin interrupt High active
BMA_WriteRegister(0x3F, 0xFB); --> enable X,Y,Z axis, data source = acc_filt2, update every time, hysteresis = 96 mg
BMA_WriteRegister(0x40, 0x02); --> enable activiy detection with OR logic
BMA_WriteRegister(0x41, 0x01); --> set threshold
BMA_WriteRegister(0x42, 0x00); --> set duration time
BMA_WriteRegister(0x43, 0x01); --> set duration time
BMA_WriteRegister(0x1F, 0x04); --> gen1 interrupt in normal mode
The code works: if i move my accelerometer, i can blink a led but i have some questions about my configuration:
1) is it right that OR logic generates an interrupt if the acceleration detected by the sensor from at least one of its axis is over a threshold and for AND logic detects an interrupt if the acceleration is detected from all the axis at the same time?
2) if i want to reduce the number of interrupt (now i receive a lot of interrupts) i have to modify threshold and duration register?
best regards,
Alessandro
Solved! Go to Solution.
02-24-2021 07:15 PM
Hello Alessandro10,
You probably need to increase threshold because if the BMA400 is on the table, Z value shall be 1G.
So, if you said threshold value as 0 and duration is 10ms, the interrupt pin always high in case interrupt is active high.
Did you check the result using scope?
And here is the answer for your questions.
1) is it right that OR logic generates an interrupt if the acceleration detected by the sensor from at least one of its axis is over a threshold and for AND logic detects an interrupt if the acceleration is detected from all the axis at the same time?
- Yes,
2) if i want to reduce the number of interrupt (now i receive a lot of interrupts) i have to modify threshold and duration register?
- Simply, increase threshold and duration as I guide.
BMA_WriteRegister(0x41, 0x96); --> set threshold //1200mg
BMA_WriteRegister(0x42, 0x00); --> set duration time
BMA_WriteRegister(0x43, 0x14); --> set duration time // 200ms
Thanks,
02-25-2021 09:45 AM
Hello Minhwan,
thank you for your suggestion but unfortunately, when i setup your configuration i cannot receive interrupt.
I'm using a breadboard with BMA400 moving it on a desk. Is it wrong?
thanks,
Alessandro
02-25-2021 09:31 PM
Hello Alessandro10,
No, it should work in bread board as well.
Here is my two suggestions. ( I highly recommend first one)
1) Please migrate BMA400 API and use our example - activity change. Then, you can check where you have some issue.
https://github.com/BoschSensortec/BMA400-API/tree/master/examples/activity_change
2) Capture i2c or spi interface, then read all register you write. Then you can figure it out the data is really written in target registers.
Thanks,
09-29-2021 01:17 AM - edited 09-29-2021 02:17 AM