2021-08-29 08:30 AM
Using the ST Micro github drivers as reference, I have an lis2dtw12 that I want to use to detect 2 things:
For case 1, I put the device to sleep, wake on activity, and fill the FIFO with the following:
/* Set full scale */
lis2dtw12_full_scale_set(&dev_ctx, LIS2DTW12_2g);
/* Configure FIFO */
lis2dtw12_fifo_watermark_set(&dev_ctx, 10);
lis2dtw12_fifo_mode_set(&dev_ctx, LIS2DTW12_BYPASS_TO_STREAM_MODE);
/* Set Output Data Rate */
lis2dtw12_data_rate_set(&dev_ctx, LIS2DTW12_XL_ODR_200Hz);
/* Configure filtering chain (Fig7 IN DS) * Accelerometer - filter path / bandwidth */
//Output Regs get the top path in Fig7:
lis2dtw12_filter_path_set(&dev_ctx, LIS2DTW12_HIGH_PASS_ON_OUT);
/* Configure power mode */
lis2dtw12_power_mode_set(&dev_ctx, LIS2DTW12_CONT_LOW_PWR_LOW_NOISE_12bit);
/* Set wake-up duration */
lis2dtw12_wkup_dur_set(&dev_ctx, 0);
/* Set sleep duration */
lis2dtw12_act_sleep_dur_set(&dev_ctx, 0);
/* Set Activity wake-up threshold */
lis2dtw12_wkup_threshold_set(&dev_ctx, 4);
/* Config activity / inactivity or stationary / motion detection */
lis2dtw12_act_mode_set(&dev_ctx, LIS2DTW12_DETECT_ACT_INACT);
If I change the lis2dtw12_wkup_threshold_set from 4 to anything lower, it seems to always get triggered, but at 4 and higher, instead of "any" motion - there needs to be pretty significant motion to trigger an event (like a shake, not just "picking up the device").
Is it possible to dial this in more to detect a not very sudden "device movement"?
Also, full scale, data rate, etc seem to really have no bearing on the ability to wake the part up, right?
<edit > Also, oddly enough - when i call `lis2dtw12_filter_path_set` with high pass, or low pass (with bw/2, or bw/4), behaviour is the exact same - seems the wake logic only cares about the threshold...
For case 2:
Do you have any suggestions on how you would detect the part being dropped on a hard floor? (And using that event to send data to the FIFO / wake INT2)?
2021-08-30 07:03 AM
Hi, I see there is an example on github configuring the lis2dtw12 to detect an activity and generating the wake-up interrupt:
/* Set full scale */
lis2dtw12_full_scale_set(&dev_ctx, LIS2DTW12_2g);
/* Configure filtering chain
* Accelerometer - filter path / bandwidth */
lis2dtw12_filter_path_set(&dev_ctx, LIS2DTW12_LPF_ON_OUT);
lis2dtw12_filter_bandwidth_set(&dev_ctx, LIS2DTW12_ODR_DIV_4);
/* Configure power mode */
lis2dtw12_power_mode_set(&dev_ctx,
LIS2DTW12_CONT_LOW_PWR_LOW_NOISE_12bit);
/* Set wake-up duration
* Wake up duration event 1LSb = 1 / ODR
*/
lis2dtw12_wkup_dur_set(&dev_ctx, 2);
/* Set sleep duration
* Duration to go in sleep mode (1 LSb = 512 / ODR)
*/
lis2dtw12_act_sleep_dur_set(&dev_ctx, 2);
/* Set Activity wake-up threshold
* Threshold for wake-up 1 LSB = FS_XL / 64
*/
lis2dtw12_wkup_threshold_set(&dev_ctx, 2);
/* Data sent to wake-up interrupt function */
lis2dtw12_wkup_feed_data_set(&dev_ctx, LIS2DTW12_HP_FEED);
/* Config activity / inactivity or stationary / motion detection */
lis2dtw12_act_mode_set(&dev_ctx, LIS2DTW12_DETECT_ACT_INACT);
/* Enable activity detection interrupt */
lis2dtw12_pin_int1_route_get(&dev_ctx,
&int_route.ctrl4_int1_pad_ctrl);
int_route.ctrl4_int1_pad_ctrl.int1_wu = PROPERTY_ENABLE;
lis2dtw12_pin_int1_route_set(&dev_ctx,
&int_route.ctrl4_int1_pad_ctrl);
/* Set Output Data Rate */
lis2dtw12_data_rate_set(&dev_ctx, LIS2DTW12_XL_ODR_200Hz);
You can check if you have done all the steps and if the threshold/duration values are ok.
Case 2: For detecting the free fall, you can use the free fall feature (0g detection), while for detecting the hit to the ground a "high-g" threshold should be better, maybe setting a FullScale of 16g and using the SINGLE_TAP feature setting the maximum threshold on all the axis TAP_THS_X, TAP_THS_Y, TAP_THS_Z (hitting the floor should cause high acceleration values).
\Dk
2021-08-30 01:54 PM
Thanks for the quick response!
That github repo is the one I'm using as reference.
Wanting to understand: for the purpose of wake-up, is the fullscale, filter path, etc relevent at all?
It seemed to me that just power mode (maybe?), and hten threshold were the important things. Could you confirm?
For the dropped device - thanks for the idea - will try! (you know testing this is going to be fun!)