cancel
Showing results for 
Search instead for 
Did you mean: 

[iis3dwb] Read sensor data without loss.

HKim.23
Associate III

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);
}

}

 

 

 

 

4 REPLIES 4
TDK
Guru

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?

If you feel a post has answered your question, please click "Accept as Solution".
HKim.23
Associate III

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

 

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

If you feel a post has answered your question, please click "Accept as Solution".
HKim.23
Associate III

Set to continuous mode as shown below, then IIS3DWB_FIFO_CTRL3 is set to 6.
And the buffer was read in units of 100.

 

iis3dwb_xl_hp_path_on_out_set(&dev_low_ctx, IIS3DWB_LP_ODR_DIV_4);
iis3dwb_fifo_mode_set(&dev_low_ctx, IIS3DWB_STREAM_MODE);
iis3dwb_fifo_xl_batch_set(&dev_low_ctx, 6); // IIS3DWB_FIFO_CTRL3 is set as 6
 

while(1)

{

// Number of unread sensor data (TAG + 6 bytes) stored in FIFO.

iis3dwb_fifo_data_level_get(&dev_low_ctx, &fifoDataCnt); 

 

if(fifoDataCnt > 100)

    for(int i = 0; i<100; i++)

    {

        //iis3dwb_acceleration_raw_get(&dev_low_ctx, sensor_raw);

        iis3dwb_fifo_out_raw_get(&dev_low_ctx, (uint8_t *)sensor_raw);

    }

`}

}

 
As a result, about 1800 data are coming in per second.
HKim23_0-1710167324489.png

The number of data written to the buffer varies depending on the IIS3DWB_FIFO_CTRL3 setting. I don't know what unit the register is in.

HKim23_1-1710167563563.png

 


What is the sampling data rate when set to 6? And I want to optimize it to receive approximately 2000 of data per second. What value should I adjust?