2024-03-11 04:02 AM
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
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.
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);
}
}
2024-03-11 05:54 AM
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?
2024-03-11 06:04 AM
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?
2024-03-11 06:27 AM
That will adjust the output data rate. But it doesn't set it to 32 Hz for reasons I explained in my previous post.
2024-03-11 07:34 AM
Set to continuous mode as shown below, then IIS3DWB_FIFO_CTRL3 is set to 6.
And the buffer was read in units of 100.
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);
}
`}
}
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.
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?