Skip to main content
Explorer
March 11, 2024
Question

[iis3dwb] Read sensor data without loss.

  • March 11, 2024
  • 1 reply
  • 1676 views

Hi, 

I want to receive data coming from the sensor without loss.

For the testing, sampling rate is set to 32Hz.

26667(ODR) / 800 = 32hz

HKim23_0-1710154197476.png

if set like this, 32 data per second will be accumulated in the buffer.

and CNT_BDR_THR was set to 100.

also, FIFO_MODE was set to continus mode.

I am reading data by checking counter_bdr_ia as shown in the code below.

My expectation is that counter_bdr_ia should occur approximately once every 3 seconds, but counter_bdr_ia is occurring faster than that.
Please let me know what's wrong. Or please give me an example for reading without data loss.

 

 

Spoiler

uint16_t fifoDataCnt;
iis3dwb_fifo_status2_t countFlag;
static uint32_t time_count = 0;

while(1){

time_count = XTHAL_GET_CCOUNT();

iis3dwb_fifo_data_level_get(&dev_low_ctx, &fifoDataCnt);
iis3dwb_fifo_status_get(&dev_low_ctx, &countFlag);

if(countFlag.counter_bdr_ia == 1)
{

printf("Buff chk Before %d %d counter_bdr_ia %d \n", time_count, fifoDataCnt
, countFlag.counter_bdr_ia
);

for(int i = 0; i<100; i++)
{
iis3dwb_fifo_out_raw_get(&dev_low_ctx, (uint8_t *)sensor_raw);
}

iis3dwb_fifo_data_level_get(&dev_low_ctx, &fifoDataCnt);
iis3dwb_fifo_status_get(&dev_low_ctx, &countFlag);
printf("Buff chk After %d counter_bdr_ia %d \n", fifoDataCnt
, countFlag.counter_bdr_ia
);
}
else
{
printf("Time %d\n", time_count);
vTaskDelay(10 / portTICK_PERIOD_MS);
}

}

 

 

 

 

    This topic has been closed for replies.

    1 reply

    Super User
    March 11, 2024

    Bandwidth and output data rate data rate are different quantities. In particular, data rate must be at least 2x bandwidth in order to get above the Nyquist frequency.

    It looks like the sample rate on this chip is 26.667 kHz. The output rate at the highest low pass setting should be around 133 Hz. Is that what you're seeing?

    HKim.23Author
    Explorer
    March 11, 2024

    Thank you for answer.
    My ultimate goal is to sample vibration data at a frequency of 2kHz.
    However, the test is currently set to ODR/800 = 32hz to control the data sampling frequency to the lowest. Isn’t it correct to adjust it like this?

    HKim23_0-1710162273956.png

     

    Super User
    March 11, 2024

    That will adjust the output data rate. But it doesn't set it to 32 Hz for reasons I explained in my previous post.