I am trying to use the raspberry pi with an ADXL355 digital accelerometer over SPI and would like to sample at 4000hz. Does the pi have a maximum sampling rate cap, or can I somehow adjust it so it can process data that fast. I can do 500-1000 without the FIFO overflowing and losing some of my data points
Thanks in advance
6 posts • Page 1 of 1
What programing language are you using? My experience with python and a mcp3008 (spi) was that i can get 48 readings per second while using IDLE, but 4700 readings per second while running the code the command line.
According to How Fast Is SPI the Linux SPI driver (in a C language program) seems to max out around 20K bytes per second. I don't know how many bytes each ADXL355 sample is that you want to transfer across that 20K bytes per second channel - you need to divide the 20,000 bytes by the number of bytes for each sample.
The other thing at issue here is that Python, on Raspbian does not guarantee you will execute. I don't know what the slice gaps are, but those can affect how often you get the opportunity to read the samples.
The top line is 1 byte per second, the bottom line slower for 5 bytes per second, which implies 12 bytes per second will be even lower samples per second, but perhaps probably still higher than 4K samples per second, so it would seem the answer is (in C at least) that 4K samples with this SPI IMU should be possible.
As to why the OP is only able to see 1K samples per second w/out buffer overrun, deeper analysis would be needed to see the max time in background, and how python unpacking is affecting it. (and if the while len[samples] < msamples is the fastest "end of while" test available.