Hey guys,
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
-
- Posts: 2
- Joined: Wed Aug 07, 2019 1:04 pm
Re: Raspberry Pi High Frequency Sampling
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.
-
- Posts: 2
- Joined: Wed Aug 07, 2019 1:04 pm
Re: Raspberry Pi High Frequency Sampling
I am using python and the script is found here https://github.com/nuclearfutureslab/adxl355-pi. The MCP3008 is an analog to digital converter, the accelerometer I am using is digital already? Is there something I'm missing here?
Re: Raspberry Pi High Frequency Sampling
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.raspberrycomslex wrote: ↑Wed Aug 07, 2019 1:07 pmHey guys,
ADXL355 digital accelerometer over SPI and would like to sample at 4000hz.
Does the pi have a maximum sampling rate cap,
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.
Re: Raspberry Pi High Frequency Sampling
That is samples per second, not bytes per second. So if each sample was 12 bytes (4 bytes each of X, Y, Z) then that would be 20,000 times 12 or 240,000 bytes per second.
Re: Raspberry Pi High Frequency Sampling
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.