Overview
I'm attempting to write a library that sets up low-power sniff / interrupt mode on an MC3635 mems accelerometer. So far, I have been able to read continuous samples and set up a base interrupt. However, I am struggling to set the threshold values on each axis accurately.
I am able to set and change threshold values and see a difference in the amount of force required to trigger the interrupt but cannot tell how I am supposed to calculate the threshold
From my understanding, every clock cycle the accelerometer generates a delta in the raw values from the current reading to the first reading since entering sniff mode. This delta is 11 bits and is compared against the user-set 6-bit threshold. There is also a mux register that allows you to choose what range of bits are used from the 11-bit delta allowing to trigger higher values at the cost of precision.
What I have attempted
So far, I have assumed that computing the delta would be the inverse of computing acceleration (G) from the raw reading. i.e.
// 16 is the set range, 2048 is maxed 12bit signed, 11 bit unsigned
x_delta = (x_g / 16.0) * 2048
and the mux is adjusted accordingly such that the highest 1 bit is included in the 6-bit range
I have tried to set my desired threshold as 2G which would result in a delta of 256, 0b100000000 this value is outside of the first 6 bits, so I set the mux to 4, and right shif the delta until it fits
// 0b100 = mux 4
// 0b1 = enable
// th_select = which axis to write to
char data = (0b100 << 4) | (0b1 << 3) | (th_select & 0b111);
res += write_register(ADDR, SNIFF_SEL, data); // set mux and select axis
sleep(10);
res += write_register(ADDR, SNIFF_TH, 0b10100000); //C2B + axis OR + 256 right shifted
sleep(10);
I would expect the above code to trigger an interrupt on acceleration events above 2G's. But, I have detected an interrupt on events as small as 0.5G
I would try to just experimentally equate the delta to shock, but I would need to build a device that can slowly raise the acceleration on the unit, and I thought I would ask here first.
The relevant information is on the datasheet here: https://www.mouser.com/pdfDocs/MEMSIC_MC3635_Datasheet.pdf from pages 55-59
Any advice is appreciated, Thanks in advance, Ethan