cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DW Please advise how to use the "stationary" feature of this device ?

swd
Associate II

LIS2DW Please advise how to use the "stationary" feature of this device. ? It doesn't seem to do anything. The LIS2DW is using LIS2DW12_STREAM_MODE and this is fine. We need to know if the device is stationary to decide if it's worth processing the data ? Please advise example code or tips ?

4 REPLIES 4
Eleon BORLINI
ST Employee

Hi @swd​ ,

Please note first that the LIS2DW and the LIS2DW12 are two slightly different sensors.

The stationary/motion detection function for the LIS2DW is described in the datasheet, p.23:

The (Android) stationary/motion detection function only recognizes the device’s sleep state. When the Android stationary/motion detection function is activated by setting the STATIONARY bit in WAKE_UP_DUR (35h), the LIS2DW detects acceleration below a fixed threshold but does not change either ODR or operating mode (High-Performance mode or Low-Power mode) after sleep state detection.

So, it basically simply notifies you whether your device is in stationary condition (below a certain, pre-configured, threshold) but it doesn't change the device configurations (ODR, mode...). You could find some line code involving this feature in the lis2dw12_activity.c file on LINS2DW12 Github repository.

  /* Config activity / inactivity or stationary / motion detection */
  lis2dw12_act_mode_set(&dev_ctx, LIS2DW12_DETECT_ACT_INACT);

More in details, Stationary / Motion detection is a particular case of the Activity / Inactivity functionality in which no ODR / power mode changes occur when a sleep condition (equivalent to Stationary condition) is detected. Stationary / Motion detection is activated by setting the STATIONARY bit to 1 in the WAKE_UP_DUR register. If both the STATIONARY bit and SLEEP_ON bit in the WAKE_UP_THS register are set to 1, Stationary / Motion detection is selected.

Please let me know if these explanations can help you in your application, and, if so, please select this answer as "best".

-Eleon

swd
Associate II

Hi Eleon, Thanks for that. We are using LIS2DW12. This was the set up:

  //lis2dw12_wkup_threshold_set(&dev_ctx, 5);  //set to 512 * 5 = 2,560

  //lis2dw12_act_mode_set(&dev_ctx, 1);     //sleep on

  //lis2dw12_act_mode_set(&dev_ctx, 2);     //stationary on

Then we looked that these registers below. Nothing changed....

It doesn't appear to do anything...

   lis2dw12_status_reg_get(&dev_ctx,&val);

   sprintf(Text, "%02X ", val);

   send(Text);

   lis2dw12_all_sources_get(&dev_ctx,&vals);

   sprintf(Text, "%02X ", vals.all_int_src);

   send(Text);

   sprintf(Text, "%02X ", vals.sixd_src);

   send(Text);

   sprintf(Text, "%02X ", vals.status_dup);

   send(Text);

   sprintf(Text, "%02X ", vals.tap_src);

   send(Text);

   sprintf(Text, "%02X ", vals.wake_up_src);

   send(Text);

Any thoughts would be welcome...

Best wishes

Simon

Hi Simon,

I think you should write 03h (or bin00000011) in the register... I'm not sure your initialization does it (is looks like the second command is overwriting the first one, if I'm well interpreting the code...)

typedef enum {
  LIS2DW12_NO_DETECTION        = 0,
  LIS2DW12_DETECT_ACT_INACT    = 1,
  LIS2DW12_DETECT_STAT_MOTION  = 3,
} lis2dw12_sleep_on_t;
int32_t lis2dw12_act_mode_set(stmdev_ctx_t *ctx,
                              lis2dw12_sleep_on_t val);

In lis2dw12_activity.c, LIS2DW12_DETECT_STAT_MOTION = 3, is the command.

-Eleon

swd
Associate II

Hi Eleon. I believe these two commands are not overwriting each other as they are bit fields. When I get the chance I will check. Best wishes Simon