Как установить частоту дискретизации?

Я хочу отслеживать вибрацию двигателя, работающего на частоте 9,5 Гц при 565 об/мин. Я использую Arduino Uno и ADXL345 в качестве оборудования для мониторинга состояния. Как мне установить частоту выборки? Я хочу делать выборку как минимум в 5 раз чаще рабочей частоты, которая составляет 50 Гц, что даст интервал в 0,02 с. Однако, чтобы собрать 2500 показаний, мне нужно будет взять около 300 с, что на 0,12 с на показание отличается от предустановленного значения в 0,02 с.

Мой код где-то неверный? Или что я могу сделать, чтобы ускорить процесс?

#include <Wire.h>
#define DEVICE (0x53)    //ADXL345 device address
#define TO_READ (6)        //num of bytes we are going to read each time    (two bytes for each axis)
#define THRESH_ACT  (0x24)
#define THRESH_INACT  (0x25)
#include <SPI.h>
#include <SD.h>
File myFile;

// Declare Variable
byte runComplete; //setting the number of iteration
int i; //delare i for count
byte buff[TO_READ];//6 bytes buffer for saving data read from the device
float x, y, z; //Acceleration variable
float x1, y1, z1; //Acceleration variable

void writeTo(int device, byte address, byte val) {
  Wire.beginTransmission(device); //start transmission to device
  Wire.write(address);        // send register address
  Wire.write(val);        // send value to write
  Wire.endTransmission(); //end transmission
}

void readFrom(int device, byte address, int num, byte buff[]) { //reads num bytes starting from address register on device in to buff array
  Wire.beginTransmission(device); //start transmission to device
  Wire.write(address);        //sends address to read from
  Wire.endTransmission(); //end transmission
  int n = Wire.requestFrom(device, num);    // request 6 bytes from device
  if( n == num)
  {     
      Wire.readBytes(buff, n);
  }
    }
void regAddress()
{
    int regAddress = 0x32;    //first axis-acceleration-data register on the ADXL345
    readFrom(DEVICE, regAddress, TO_READ, buff); //read the acceleration data from the ADXL345

     //each axis reading comes in 10 bit resolution, ie 2 bytes.  Least Significat Byte first!!
     //thus we are converting both bytes in to one int
    x = (((int)buff[1]) << 8) | buff[0];  
    y = (((int)buff[3])<< 8) | buff[2];
    z = (((int)buff[5]) << 8) | buff[4];

    x1 = (x/256);
    y1 = (y/256);
    z1 = (z/256);

 Serial.println(" ");
    Serial.print("X: ");Serial.print(x1); Serial.println(" mm/s2");
    Serial.print("Y: ");Serial.print(y1); Serial.println(" mm/s2");
    Serial.print("Z: ");Serial.print(z1); Serial.println(" mm/s2");
    Serial.println(" ");

    myFile = SD.open("x30.txt", FILE_WRITE); // if the file opened okay, write to it:
    if (myFile) {
      Serial.print("Writing to X.txt...");
      myFile.println(x1);
      myFile.close();// close the file:
      Serial.println("done.");
    } else {
      Serial.println(F("error opening x.txt")) ;// if the file didn't open, print an error:
    }

    myFile = SD.open("y30.txt", FILE_WRITE); // if the file opened okay, write to it:
    if (myFile) {
      Serial.print("Writing to Y.txt...");
      myFile.println(y1);
      myFile.close();// close the file:
      Serial.println("done.");
    } else {
      Serial.println(F("error opening Y.txt")) ; // if the file didn't open, print an error:
    }
      myFile = SD.open("z30.txt", FILE_WRITE);// if the file opened okay, write to it:
    if (myFile) {
      Serial.print("Writing to Z.txt...");
      myFile.println(z1);
      myFile.close();// close the file:
      Serial.println("done.");
      Serial.println("");
    } else {
      Serial.println(F("error opening Z.txt")); // if the file didn't open, print an error:
      Serial.println("");
    }   
       }

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
  writeTo(DEVICE, 0x2D, 0);   //Turning on the ADXL345
  writeTo(DEVICE, 0x2D, 16);  //Turning on the ADXL345
  writeTo(DEVICE, 0x2D, 8);   //Turning on the ADXL345
  writeTo(DEVICE, 0x31, 8);
  Serial.println("Initializing Accelerometer...");
  Serial.print("Initializing SD card...");
  Serial.println("");
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    Serial.println("");
    return;
  }
  delay(2000);
}

 void loop() {
   if (runComplete == 0){
  for (i=0; i<2501; i=i+1){
 Serial.print("Number of iteration(seconds) = "); Serial.print(i);
 Serial.println("");
 regAddress();
     delay(200);
   }
  runComplete = 1;
  }
}

, 👍1