Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> the sensor has its own built-in sample rate, 400 times per second. If I read it too quickly, I might just be grabbing the same number twice

The author is configuring the sensor wrong i think. The usually way is you setup sampling rate of register, setup fifo inside register, wait for interrupt from sensor(through GPIO pin), then read from FIFO. Just blindly read data from sensor will get you in trouble, like reading duplicate value



Not all microcontrollers[1]} have FIFOs for stuff like this, but perhaps you meant implementing it in software as a regular queue or something.

Anyway, even easier since the OP seems to be dealing a lot with the time between samples, would be to just make sure that at least 2.5 ms have passed before reading the sensor again. Right?

[1] Not sure if older blog posts detail the hardware, I do remember reading about this product on here before.


Their chip seems to be [0] an LIS3DH from ST, it has a fifo [1]. I actually haven't come across a modern IMU that doesn't have one.

> would be to just make sure that at least 2.5 ms have passed before reading the sensor again

You're resampling at the same rate by doing this, which won't be accurate due to very slight variations in timings.

[0] https://cdn.shopify.com/s/files/1/0914/0181/4398/files/24-10...

[1] page 19, https://www.st.com/resource/en/datasheet/lis3dh.pdf


>Not all microcontrollers[1]} have FIFOs

No, i mean the FIFO inside the sensor. The sensor will populate FIFO itself, and trigger interrupt to MCU when the FIFO is full(or half full, configurable)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: