2021-09-07 03:18 AM
Hello,
I am trying to implement some functionality that will fill the LSM6DSO(32)s FIFO buffer when a severe impact is detected. This is done by utilising the wake up interrupt with the slope filter enabled, when the sensor is in bypass-to-fifo mode. And it works very well when I am only recording acceleration and timestamp data.
However I also wish to record pressure data collected from the LPS22HH, by utilising the LSM6DSOs sensor hub configuration.
This is where things get odd.
I noticed that despite a severe impact not being detected, the FIFO buffer will start to fill with timestamp data. I have confirmed that the sensor is still in bypass mode, since I can still trigger the FIFO buffer to be filled by jolting the sensor. It's just that the first part of the FIFO is filled with timestamp information, and given enough time will completely fill it.
The rate at which the FIFO is filled, appears to be dictated by the sensor hub data rate and fifo timestamp decimation factor. I created a simple application to test this and it appears to support the theory. The simple firmware sets up the accelerometer to fill the FIFO on a severe impact, and cycles through various sensor hub data rates while tracking the time it takes for a fifo full interrupt to be generated without touching the board (FIFO is filled with just timestamp data). Here is a snippet of the output.
Set to 104 Hz, expect full buffer in around 2.62 mins
0:0:1: Test started
0:2:36: Interrupt detected!
Set to 52 Hz, expect full buffer in around 5.25 mins
0:2:37: Test started
0:7:48: Interrupt detected!
Set to 26 Hz, expect full buffer in around 10.5 mins
0:7:49: Test started
0:18:11: Interrupt detected!
I have attached the source file for this, which can simple be copied into a project to run on a Nucleo-F401RE board with the IKS01A3 expansion board. (to build and run, you will also need to grab driver files from here -> https://github.com/STMicroelectronics/lsm6dso/tree/ec52bc39c3aec7c03bf702c9b92698859fedae0f)
I have also confirmed that this behaviour is only seen when the FIFO is configured in the bypass-to-fifo mode. When in bypass mode only, I was unable to trigger the fifo full interrupt. So I'm assuming no timestamp data is being written.
After reading the application note on the LSM6DSO, I can see the following under the section about collecting timestamp (Auxiliary sensor) data in the FIFO.
"Auxiliary sensors cannot trigger a write in FIFO. Their registers are written when the first main sensor or the
external sensor event occurs (even if they are configured at a higher batch data rate)."
Does this mean that if I have the sensor hub enabled, I am unable to wait until the wake up event occurs to start filling the FIFO?
Or am I missing something in my configuration? (see attached c file)
Many Thanks
Calum
2021-09-09 07:09 AM
Hi Calum @CBigg.1 ,
>> Does this mean that if I have the sensor hub enabled, I am unable to wait until the wake up event occurs to start filling the FIFO?
This means that the sensors that are connected to the sensor hub (the LPS22HH pressure sensor in your case, for example when it exceeds some threshold) are not able to trigger the FIFO and to start it filling. You can only trigger the FIFO with the LSM6DSO(32) triggers. Which wake up event are you triggering with the LPS22HH?
Did you also check the lsm6dso_sensor_hub_lps22hh.c Github example for having a benchmark for your code?
-Eleon
2021-09-09 07:48 AM
Hi Eleon,
My trigger to start filling the FIFO is the LSM6DSO(32) wake up interrupt (intention is to generate an interrupt when the product experiences an impact - spike in acceleration).
The sensor hub is set up to continuously read the LPS22HH, and my expectation was that the FIFO buffer on the LSM6DSO(32) would not actually start to fill until the internal wake up interrupt was generated.
This is partially true.
No pressure data is recorded in the FIFO buffer until the wake up interrupt BUT, the FIFO does start to fill with timestamp data.
I believe that the timestamp data is being written into the FIFO before the wake up interrupt, due to the fact that the accelerometer has been set up to continuously poll the pressure sensor.
If this is the case, is there a way that I can avoid this?
Thanks for example link, but I believe have seen that one before.
Many thanks
Calum
2021-09-13 08:32 AM
Hi Calum,
so you want to avoid that the timestamps is stored in FIFO after the wakeup event?
And do you receive only timestamps and not sensor data?
-Eleon
2021-09-13 09:39 AM
Hi Eleon,
Timestamp data after the wakeup event is wanted.
What I want to avoid is timestamps filling the FIFO BEFORE the wake up event.
I do get sensor data but, as it stands the FIFO is not empty when the wake up event is generated.
And the only data that is getting written into the FIFO BEFORE the wakeup event, is timestamps.
Many thanks
Calum
2021-10-04 03:01 AM
Hi @Eleon BORLINI,
I was just wondering if there was any update on this.
Many thanks
Calum
2021-10-11 06:49 AM
Hi Calum,
not much guess, unfortunately.
What if you set the BATCH_EXT_ SENS_0_EN of the SLAVE0_CONFIG (17h) to 1? This is used to enable the batching in FIFO of the external sensor associated to slave0.
-Eleon
2021-10-11 07:12 AM
Hi Eleon,
Unfortunately that is something I have already tried and is included in the lightweight example code I originally attached (see line 48).
Could you please take a quick look at the attached snippet and let me know if anything stands out as an issue.
If you want to also look at the code in the functions, it can be found here -> https://github.com/STMicroelectronics/lsm6dso/tree/ec52bc39c3aec7c03bf702c9b92698859fedae0f
Many thanks
Calum
static void SetUpNextTest(void)
{
static int testId = 0;
// Perform soft reset
lsm6dso_reset_set(&deviceContext, PROPERTY_ENABLE);
HAL_Delay(1000);
// apply base config
lsm6dso_i3c_disable_set(&deviceContext, LSM6DSO_I3C_DISABLE);
lsm6dso_block_data_update_set(&deviceContext, PROPERTY_ENABLE);
lsm6dso_wkup_ths_weight_set(&deviceContext, LSM6DSO_LSb_FS_DIV_64);
lsm6dso_xl_hp_path_internal_set(&deviceContext, LSM6DSO_USE_SLOPE);
lsm6dso_wkup_threshold_set(&deviceContext,
(uint8_t)WAKE_UP_THRESHOLD_TARGET_MG_TO_REG_VALUE(5000));
lsm6dso_wkup_dur_set(&deviceContext, 3);
lsm6dso_fifo_xl_batch_set(&deviceContext, LSM6DSO_XL_BATCHED_AT_3333Hz);
lsm6dso_fifo_timestamp_decimation_set(&deviceContext, LSM6DSO_DEC_32);
lsm6dso_sh_slave_connected_set(&deviceContext, LSM6DSO_SLV_0);
switch (testId++)
{
case 0:
printf("Set to 104 Hz, expect full buffer in around 2.62 mins\n");
lsm6dso_sh_data_rate_set(&deviceContext, LSM6DSO_SH_ODR_104Hz);
break;
case 1:
printf("Set to 52 Hz, expect full buffer in around 5.25 mins\n");
lsm6dso_sh_data_rate_set(&deviceContext, LSM6DSO_SH_ODR_52Hz);
break;
case 2:
printf("Set to 26 Hz, expect full buffer in around 10.5 mins\n");
lsm6dso_sh_data_rate_set(&deviceContext, LSM6DSO_SH_ODR_26Hz);
break;
}
if (testId == 3)
{
testId = 0;
}
lsm6dso_sh_write_mode_set(&deviceContext, LSM6DSO_ONLY_FIRST_CYCLE);
lsm6dso_sh_slv0_cfg_read(&deviceContext,(lsm6dso_sh_cfg_read_t*)&pressureSensorSlaveConfig);
lsm6dso_sh_master_set(&deviceContext, PROPERTY_ENABLE);
lsm6dso_sh_batch_slave_0_set(&deviceContext, PROPERTY_ENABLE);
// THE CHANGE THAT SEEMS TO MAKE THE DIFFERENCE
// - Bypass behaves as expected (the fifo doesnt fill)
// - Bypass to fifo seems to fill the FIFO before the trigger to switch modes
// and it is just timestamp data that is added
lsm6dso_fifo_mode_set(&deviceContext, fifoMode);
lsm6dso_timestamp_set(&deviceContext, PROPERTY_ENABLE);
// Configure Interrupts
lsm6dso_pin_polarity_set(&deviceContext, LSM6DSO_ACTIVE_HIGH);
lsm6dso_pin_mode_set(&deviceContext, LSM6DSO_PUSH_PULL);
lsm6dso_int_notification_set(&deviceContext, LSM6DSO_ALL_INT_LATCHED);
lsm6dso_pin_int1_route_set(&deviceContext, int1_config);
lsm6dso_pin_int2_route_set(&deviceContext, NULL, int2_config);
// Enable the sensor!
lsm6dso_xl_data_rate_set(&deviceContext, LSM6DSO_XL_ODR_6667Hz);
PrintMessageWithTimestamp("Test started\n");
}
2021-10-21 05:20 AM
Hi Calum @CBigg.1 ,
unfortunately no further guess from my side...
Could you try lowering the ODR value in the last function, and to set the interrupts pulsed instead of latched?
-Eleon