Hello,
I have a problem reading my acceleration sensor fast enough.
I'm using an Arduino Nano Every and two ADXL 357 acceleration sensors. I want to log the Data to an SD card and achieve at least a frequency of 1kHz (rather 2 kHz).
I'm using the FIFO buffer to read a lot of sensor data at once. The Buffer can take up to 96 values and I'm reading it when 81 (27*x, y & z) are reached. The Acceleration Data consists of 20 Bit, so I have to read 3 Byte per value. That makes it 243 Byte (1944 Bit) to read the FIFO Buffer. I'm using an SPI frequency of 5Mhz, so I would ideally need about 0.4 ms to read the FIFO Buffer (I know that this is impossible, because SPI also needs to send Data before reading, but im just looking at the magnitude).
I measure the time for the read and it takes about 16 ms to read the FIFO Buffer of one Sensor. The time also doesn't change when I lower the SPI frequency to 1Mhz and I can't use 10 Mhz because thats too much for my wiring (even though the Sensor could do it).
Here is the code for the read function and my SPI settings.
void ADXL357::readMultipleFIFORegisters(int dataSize, uint8_t *Dataread, int start) {
uint8_t address = 0x23;
digitalWrite(_CS_Pin, LOW);
SPI.transfer(address);
for (int i = start; i < dataSize + start; i++) {
Dataread[i] = SPI.transfer(0x00);
}
digitalWrite(_CS_Pin, HIGH);
}
SPI.begin();
SPISettings settings(5000000, MSBFIRST, SPI_MODE0);
SPI.beginTransaction(settings);
Thank you for your Help!
Till