cancel
Showing results for 
Search instead for 
Did you mean: 

Less number of samples collected than the sample rate used

AK.08
Associate III

I am using Lis3DSH at 1600 sample rate . I am using I2C at frequency 250Hz for communication with sensor.

If I want to capture 3 seconds data(4800 samples), the actual time taken to complete this procedure is more than 3 seconds, which means overrun is happening, but overrun flag is not getting set.

Same goes for 800 samples/sec rate.

But,When I reduced the Sample rate to 100, the samples are received in exact time.

How can we collect data in exact time? and why is it taking longer than mentioned?

8 REPLIES 8
KnarfB
Principal III

Think 250Hz is a typo. Typ. I2C freq. is 400 kHz might be still too slow.

How long (bytes) is a data packet? 6 bytes? (3*16bit)?

How many bytes are in 1 sensor reading in total? (There is a typ. write+read sequence).

For fast sensor reading, SPI is used, I2C might be too slow.

Eleon BORLINI
ST Employee

Hi @Community member​ ,

besides @KnarfB​  indications, check also if you are running in FIFO mode ("simultaneously" reading samples inside a batch of FIFO) or in continuous mode (bypassing the FIFO).

-Eleon

Hi,

Sorry for the Typo, its 250KHz.

A data packet is 6*4bytes and I am reading 20 such samples in one iteration as I have set Water Mark level to 20 and I have total 4800 samples.

Hi,

I am running in Stream Mode

Eleon BORLINI
ST Employee

Hi @Community member​ ,

does your procedure take much more than 3 seconds to complete?

Because sometimes the actual device ODR is slightly different from the nominal one, and you could have for example actual 1560Hz instead of nominal 1600Hz, resulting in a longer total acquisition time for the 4800 samples.

To measure the precise ODR of your device you can enable the DRDY on interrupt and measure the actual data rate. In this procedure, it is strongly recommended to set the BDU (block data update) bit to 1 in the CTRL_REG4 register.

And if you don't set the FIFO full threshold level, do you still experience issues?

If however this is not the case, I suggest you to compare your code with the C example on github lis3dsh_fifo_stream.c, to check if you find any (big) differences.

-Eleon

It takes around 4.5seconds to acquire 4800 samples.

I will check the rest of your suggestions

Yes, without setting the FIFO full threshold level, I am getting the same issue.

My code is almost similar to the example code.

While you are reading one batch of 6*4bytes, is the FIFO filling in the meantime with the next sample batch?

-Eleon