Skip to main content
Visitor II
January 13, 2021
Question

Less number of samples collected than the sample rate used

  • January 13, 2021
  • 3 replies
  • 1960 views

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?

    This topic has been closed for replies.

    3 replies

    Super User
    January 13, 2021

    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.

    AK.08Author
    Visitor II
    January 15, 2021

    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.

    ST Employee
    January 13, 2021

    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

    AK.08Author
    Visitor II
    January 15, 2021

    Hi,

    I am running in Stream Mode

    ST Employee
    January 15, 2021

    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

    AK.08Author
    Visitor II
    January 15, 2021

    It takes around 4.5seconds to acquire 4800 samples.

    I will check the rest of your suggestions