How to get the best performance out of LIS3DH accelerometer

Thread Starter

zazas321

Joined Nov 29, 2015
893
Hello. I plan to use accelerometer to measure the vibrations of cnc machine spindle. I have picked up a LIS3DH module and wired it up to a microcontroller using I2C. I have downloaded Adafruit LIS3DH library which makes it very easy to interface with the accelerometer. The sketch is as following:
Code:
// Basic demo for accelerometer readings from Adafruit LIS3DH

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

// software SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
Adafruit_LIS3DH lis = Adafruit_LIS3DH();

void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("LIS3DH test!");

  if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start");
    while (1) yield();
  }

// to turn on high resolution:
//ctrl_reg1[3] LPEN bit - 0
//ctrl_reg4[3] HR bit - 1
  
  Serial.println("LIS3DH found!");

  lis.setRange(LIS3DH_RANGE_2_G);   // 2, 4, 8 or 16 G!

  Serial.print("Range = "); Serial.print(2 << lis.getRange());
  Serial.println("G");

  lis.setDataRate(LIS3DH_DATARATE_200_HZ);
  Serial.print("Data rate set to: ");
  switch (lis.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
  }
}

void loop() {
  lis.read();      // get X Y and Z data at once
  // Then print out the raw data
  Serial.print("X:  "); Serial.print(lis.x);
  Serial.print("  \tY:  "); Serial.print(lis.y);
  Serial.print("  \tZ:  "); Serial.print(lis.z);

  /* Or....get a new sensor event, normalized */
  sensors_event_t event;
  lis.getEvent(&event);

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
  Serial.print(" \tY: "); Serial.print(event.acceleration.y);
  Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
  Serial.println(" m/s^2 ");

  Serial.println();

  delay(200);
}
The current configuration:

Range: 2G
Data rate : 200HZ
High resolution (12-bit mode) is enabled.


When I look at the readings over few seconds when the accelerometer is standing still on my table:

1625809343066.png


I have 2 main questions:

1. As you can see, the readings fluctuate quite a bit ( for example Z axis can read as low as 15800 and as high as 16100 ). Is this normal behaviour? I am worried that this is going to cause problems when I am trying to measure slight vibrations of the spindle

2. Is there a good way to calibrate it for my environment so when its standing where all the force is towards the Z axis, the other 2 axis should read as close to 0 as possible?

This perhaps is not the best way to measure the spindle vibrations but keep in mind that this is a school project and it does not have to be perfect. As long as I can get some sort of viable results - it is fine. I am hoping to get some clarification from someone who is fammiliar with the LIS3DH chip and how it supposed to operate
 

andrewmm

Joined Feb 25, 2011
1,757
take step back
you have an I2C interface,
whats the maximum speed you can take a reading at ?

Nyquist , that number above will be twice the maximum frequency you cna read

I'd suggest that number is in range of Hz,
a rotating spindle I would suggest is going to have a much higher frequency of vibration,

Is that fast enough for you ?
its normal to use the analog accelorometers to detect vibration,
or even a simple microphone,
 

Thread Starter

zazas321

Joined Nov 29, 2015
893
take step back
you have an I2C interface,
whats the maximum speed you can take a reading at ?

Nyquist , that number above will be twice the maximum frequency you cna read

I'd suggest that number is in range of Hz,
a rotating spindle I would suggest is going to have a much higher frequency of vibration,

Is that fast enough for you ?
its normal to use the analog accelorometers to detect vibration,
or even a simple microphone,
Hello thank you for the response. Can you please clarify regarding the frequency?
For example, if the spindle is rotating at 5000rpm. that will be 83.3Hz based on the internet converter that I have found:
https://mainfacts.com/convert-rpm-to-hz

From the LIS3DH datahseet I read that the chip is capable of 1hz to 5.3khz datarates. Does that imply that I can take a accelerometer readings at a rate of 5.3khz? If that is the case. I think it I should be able to measure the spindle right? Can you explain more from the theoretical point of view what do you mean twice the maximum frequency? Are we talking here about the LIS3DH datarate or the spindle rotation frequency?
 
Last edited:

andrewmm

Joined Feb 25, 2011
1,757
Hello thank you for the response. Can you please clarify regarding the frequency?
For example, if the spindle is rotating at 5000rpm. that will be 83.3Hz based on the internet converter that I have found:
https://mainfacts.com/convert-rpm-to-hz

From the LIS3DH datahseet I read that the chip is capable of 1hz to 5.3khz datarates. Does that imply that I can take a accelerometer readings at a rate of 5.3khz? If that is the case. I think it I should be able to measure the spindle right?
The rate the sensor can run at is immaterial to how fast you can read the data from the sensor, thats down to your system design.

You have decided to use I2C,
I don't know your system, but assuming the sensor is not co mounted on the pcb with the processor, I'd suggest that you are running the I2C at 100 K bit / second.

Assuming your I2C transaction is a write, then 6 reads ( 3 axis of motion, 12 bits each , 8 bits per read, not compressed )
each of 10 bits ( start , data , ack)
( OK you will save a few bits on the ack / start / stop , but a good first assumption )

then your maximum read rate is around 1.5 KHz,
so the abs max frequency you can receive , if 700 Hz,

All for the processor code only accessing the i2C 1/4 the time ( as it needs to do other things )
your down to a max frequency of 170 Hz.

Allowing filtering on this ( nyquest ) then you're down to around 50 Hz to 100 Hz max frequency .

are you certain that s fast enough for you ?

A shaft running at 5000 RPM ( 83 rev per second ) is very capable of making a singing noise up in the KHz region,


Then as you have seen, the sensor is very sensitive,
and a high noise source,
so your code has to filter out that noise,
The way to do that is to over sample and corelate / FFT

which requires either data synchronised to the rotation of the shaft, or around 10 times more data

I'd also suggest that you look at how long it takes to make a print out
that is the same sort of time as the sampling rate you want,

so slowing you sampling down even more,

Suggest a few tests , if you have a scope, probe theI2C line, see how often the I2C transaction is,
the make a program that takes say 1000 samples form the sensors,
and at the end prints out how long it took to take the samples,
this is the abs max frequency you can ever get with your system.

Digital sensors are getting better, and I use them a lot in products, but historically , theses sort of diagnostic readings are made using analog accelerometers, and an ADC, with filtering and processing for the above reasons
 

ahmaza

Joined Jul 10, 2021
8
Well, even if the sensor is standing still on table, there are also some vibration we can't feel. this is why recording studios uses special mounts for their microphones. Hence it's expected to get these fluctuations.

Also I'd suggest to isolate the measurement setup with shock absorbers
 
Last edited:

andrewmm

Joined Feb 25, 2011
1,757
Filtering is a problem, as the OP wants to detect the frequencies, down to almost DC, but not DC and to quiet high frequency for an accelerometer, and the OP just not have sufficient samples to allow the loss of information inherent in filtering.
 

Thread Starter

zazas321

Joined Nov 29, 2015
893
Thanks for all the responses. I have been reading up about the i2c a little bit more. It seems that both accelerometer and my microcontroller (ESP32) are capable of 400kbit/s data transfer rate ( high speed i2c). However, that still does not sound promising based on what andrewmm have suggsted. Ideally, I would like to be capable of measuring a spindle vibrations while the spindle is rotating up to 30.000 rpm. Is that even realistic to do? I have looked up another type of sensor ADXL335 which is analog. Maybe that would be better choise for this application
 
Last edited:

Thread Starter

zazas321

Joined Nov 29, 2015
893
I also just realised that there is also an option to use SPI instead if I2C. From what I read, the SPI is capable of much higher speeds than I2C. Perhaps if I use SPI, that would be enough speed?
 

andrewmm

Joined Feb 25, 2011
1,757
SPi is faster,
your still constrained by the speed the sensor can read at

problem with SPI is also the speed,

If you have a good PCB with the two parts on, then you can probably run at the speed set by the slowest part, probably 30 Mb/s
if you have cables, then speed starts to drop,
over say 300 mm, your back to Kb/s , unless you start taking good care of signals , may be differential ,

Just go analog,
 

kaindub

Joined Oct 28, 2019
88
Remember that Arduino code is not optimised. The compiler converts your C++ into machine code, but it doesnt make it the fastest running code.
Microprocessors that require short program cycle times are usually programmed in assembler.
 

Thread Starter

zazas321

Joined Nov 29, 2015
893
Hey all. Thanks for the responses. I have been further exploring the LIS3DH. Please correct me if I am wrong.

I have been experimenting more with the SPI communications now instead of I2C.

My ctrl1 register is set to 151 decimal and my ctrl4 is set to 136 decimal. I think that results in 1.3khz High resolution mode if I understand the datasheet correctly:
1627280279435.png


So in theory, I am able to take 1 reading every 1/1344 = 0.74ms. Is that right?


Also, I am a bit confused regarding the Serial.print of arduino. I am printing without any delay with a timestamp and it seems weird:
1627280413203.png

Notice that there are many prints with the same timestamp. Is that how arduino serial print works? I dont think this is correct. Because every reading should be with a different timestamp
 
Last edited:

Thread Starter

zazas321

Joined Nov 29, 2015
893
I am now trying to read 10 accelerometer readings in high precision mode and merge them together. The serial output looks like:



1627287993553.png




The values still deviate a lot even after merging 10 readings. How much better would analog accelerometer be? Since I am going to convert the acceleromter G reading to the displacement and I need it to be lass than 1mm accuracy, I do not think neither LIS3DH or analog accelerometer will be capable of detecting 1mm or more accurate displacement? Perhaps there is a better method of detecting very small changes in distance very fast
 

Attachments

andrewmm

Joined Feb 25, 2011
1,757
I am now trying to read 10 accelerometer readings in high precision mode and merge them together. The serial output looks like:



View attachment 244428




The values still deviate a lot even after merging 10 readings. How much better would analog accelerometer be? Since I am going to convert the acceleromter G reading to the displacement and I need it to be lass than 1mm accuracy, I do not think neither LIS3DH or analog accelerometer will be capable of detecting 1mm or more accurate displacement? Perhaps there is a better method of detecting very small changes in distance very fast

Your getting there,

so your sampling say twice per second,
thats 2 Hz,

analog, you would be sampling at say 60 KHz,


also,
how long do you think the serial print takes ?

I'd suggest let have a look at your code ,

Are you taking the SPI with an interrupt on a regular basis ?
if not, then averaging might not be that useful,

averaging is a filter function,
and as such has a frequency responce,

many options,
but at two samples per second, not much you can do,

Have you looked at the sensor fusion ?
Have you looked yet at Kalman filtering
to get the resolution your after, I'm thinking you are goign to have to do both these,
 

Thread Starter

zazas321

Joined Nov 29, 2015
893
Hey. Thanks again for the response. Even if I am able to read the data at the required speeds, do you think the accelerometer is sensitive enough to capture <1mm displacement?
Full code is here:

Code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>


// Used for hardware & software SPI
#define LIS3DH_CS 5

// software SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
//Adafruit_LIS3DH lis = Adafruit_LIS3DH();

  uint8_t ctr1l_reg;
  uint8_t ctrl4_reg;
  uint8_t fifoctrl_reg;
  uint8_t status_reg;
  uint8_t ctrl5_reg;
  int32_t x_10_readings;
  int32_t y_10_readings;
  int32_t z_10_readings;
  int16_t final_x_reading;
  int16_t final_y_reading;
  int16_t final_z_reading;
  uint8_t loop_counter=0;

void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("LIS3DH test!");

  if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start");
    while (1) yield();
  }


  
  lis.setRange(LIS3DH_RANGE_2_G);   // 2, 4, 8 or 16 G!

  Serial.print("Range = "); Serial.print(2 << lis.getRange());
  Serial.println("G");

  Serial.print("writing to ctrl reg1");// this sets the data rate to 1.3khz
  lis.write_register(LIS3DH_REG_CTRL1,0x97);

/*  
  lis.setDataRate(LIS3DH_DATARATE_100_HZ);
  Serial.print("Data rate set to: ");
  switch (lis.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
  }
  */
  
 // supposed to be 1.3khz

  int data_rate = lis.getDataRate();
  Serial.print("data rate = ");
  Serial.println(data_rate);

}




void loop() {
  lis.read();      // get X Y and Z data at once
  x_10_readings = x_10_readings + lis.x;
  y_10_readings = y_10_readings + lis.y;
  z_10_readings = z_10_readings + lis.z;
  loop_counter = loop_counter +1;
  if (loop_counter == 10)
  { 
    final_x_reading = x_10_readings/10;
    final_y_reading = y_10_readings/10;
    final_z_reading = z_10_readings/10;
    x_10_readings = 0;
    y_10_readings = 0;
    z_10_readings = 0;
    loop_counter = 0;
    Serial.print("X: ");
    Serial.println(final_x_reading);
    Serial.print("Y:");
    Serial.println(final_y_reading);
    Serial.print("Z:");
    Serial.println(final_z_reading);
  }

}
The serial monitor output:
Code:
08:43:18.224 -> X: 491
08:43:18.224 -> Y:-15883
08:43:18.224 -> Z:-1230
08:43:18.224 -> X: 518
08:43:18.224 -> Y:-15862
08:43:18.224 -> Z:-1529
08:43:18.224 -> X: 302
08:43:18.224 -> Y:-15915
08:43:18.224 -> Z:-1260
08:43:18.224 -> X: 472
08:43:18.224 -> Y:-15948
08:43:18.224 -> Z:-1350
08:43:18.224 -> X: 435
08:43:18.224 -> Y:-15892
08:43:18.224 -> Z:-1243
08:43:18.224 -> X: 595
08:43:18.224 -> Y:-15840
08:43:18.224 -> Z:-1398
08:43:18.224 -> X: 406
08:43:18.224 -> Y:-15867
08:43:18.224 -> Z:-1158
08:43:18.224 -> X: 584
08:43:18.224 -> Y:-15857
08:43:18.224 -> Z:-1537
08:43:18.224 -> X: 291
08:43:18.224 -> Y:-15924
08:43:18.224 -> Z:-1452
08:43:18.224 -> X: 428
08:43:18.224 -> Y:-16041
08:43:18.224 -> Z:-1419
08:43:18.224 -> X: 446
08:43:18.224 -> Y:-15883
08:43:18.224 -> Z:-1569
08:43:18.224 -> X: 596
08:43:18.224 -> Y:-15905
08:43:18.224 -> Z:-1304
08:43:18.224 -> X: 430
08:43:18.224 -> Y:-15865
08:43:18.224 -> Z:-1372
08:43:18.224 -> X: 489
08:43:18.224 -> Y:-15796
08:43:18.224 -> Z:-1051
08:43:18.224 -> X: 612
08:43:18.224 -> Y:-15865
08:43:18.224 -> Z:-1232
08:43:18.271 -> X: 510
08:43:18.271 -> Y:-15832
08:43:18.271 -> Z:-1308
08:43:18.271 -> X: 502
08:43:18.271 -> Y:-15916
08:43:18.271 -> Z:-1436
08:43:18.271 -> X: 251
08:43:18.271 -> Y:-15939
08:43:18.271 -> Z:-1284
08:43:18.271 -> X: 462
08:43:18.271 -> Y:-15891
08:43:18.271 -> Z:-1667
08:43:18.271 -> X: 417
08:43:18.271 -> Y:-15830
08:43:18.271 -> Z:-1486
08:43:18.271 -> X: 492
08:43:18.271 -> Y:-15884
08:43:18.271 -> Z:-1497
08:43:18.271 -> X: 516
08:43:18.271 -> Y:-15784
08:43:18.271 -> Z:-936
08:43:18.271 -> X: 459
08:43:18.271 -> Y:-15963
08:43:18.271 -> Z:-1497
08:43:18.271 -> X: 444
08:43:18.271 -> Y:-15809
08:43:18.271 -> Z:-1270
08:43:18.271 -> X: 291
08:43:18.271 -> Y:-15916
08:43:18.271 -> Z:-1353
08:43:18.271 -> X: 425
08:43:18.271 -> Y:-15779
08:43:18.271 -> Z:-1254
08:43:18.271 -> X: 580
08:43:18.271 -> Y:-15820
08:43:18.271 -> Z:-1097
08:43:18.271 -> X: 499
08:43:18.271 -> Y:-15856
08:43:18.271 -> Z:-1091
08:43:18.271 -> X: 688
08:43:18.271 -> Y:-15772
08:43:18.271 -> Z:-1148
08:43:18.271 -> X: 451
08:43:18.271 -> Y:-15838
08:43:18.271 -> Z:-768
08:43:18.271 -> X: 536
08:43:18.271 -> Y:-15891
08:43:18.271 -> Z:-1377
08:43:18.271 -> X: 377
08:43:18.271 -> Y:-16028
08:43:18.271 -> Z:-1494
08:43:18.271 -> X: 620
08:43:18.271 -> Y:-15868
08:43:18.271 -> Z:-1376
08:43:18.271 -> X: 624
08:43:18.271 -> Y:-15984
08:43:18.271 -> Z:-1024
08:43:18.271 -> X: 563
08:43:18.318 -> Y:-15974
08:43:18.318 -> Z:-1179
08:43:18.318 -> X: 409
08:43:18.318 -> Y:-15931
08:43:18.318 -> Z:-1304
08:43:18.318 -> X: 630
08:43:18.318 -> Y:-15920
08:43:18.318 -> Z:-1356
08:43:18.318 -> X: 345
08:43:18.318 -> Y:-15905
08:43:18.318 -> Z:-1484
08:43:18.318 -> X: 566
08:43:18.318 -> Y:-15865
08:43:18.318 -> Z:-1264
08:43:18.318 -> X: 403
08:43:18.318 -> Y:-15835
08:43:18.318 -> Z:-1438
08:43:18.318 -> X: 473
08:43:18.318 -> Y:-15955
08:43:18.318 -> Z:-1248
08:43:18.318 -> X: 468
08:43:18.318 -> Y:-15825
08:43:18.318 -> Z:-1358
08:43:18.318 -> X: 582
08:43:18.318 -> Y:-15878
08:43:18.318 -> Z:-1345
08:43:18.318 -> X: 443
08:43:18.318 -> Y:-15808
08:43:18.318 -> Z:-985
08:43:18.318 -> X: 558
08:43:18.318 -> Y:-15830
08:43:18.318 -> Z:-1401
08:43:18.318 -> X: 457
08:43:18.318 -> Y:-15873
08:43:18.318 -> Z:-1036
08:43:18.318 -> X: 416
08:43:18.318 -> Y:-15956
08:43:18.318 -> Z:-1654
08:43:18.318 -> X: 419
08:43:18.318 -> Y:-15992
08:43:18.318 -> Z:-1128
08:43:18.318 -> X: 342
08:43:18.318 -> Y:-15907
08:43:18.318 -> Z:-1507
08:43:18.318 -> X: 377
08:43:18.318 -> Y:-15862
08:43:18.318 -> Z:-1174
08:43:18.318 -> X: 600
08:43:18.318 -> Y:-15881
08:43:18.318 -> Z:-1220
08:43:18.318 -> X: 574
08:43:18.318 -> Y:-15960
08:43:18.318 -> Z:-995
08:43:18.318 -> X: 467
08:43:18.318 -> Y:-15868
08:43:18.318 -> Z:-1414
08:43:18.318 -> X: 342
08:43:18.365 -> Y:-16054
08:43:18.365 -> Z:-1670
08:43:18.365 -> X: 457
08:43:18.365 -> Y:-15928
08:43:18.365 -> Z:-1644
08:43:18.365 -> X: 500
08:43:18.365 -> Y:-15974
08:43:18.365 -> Z:-1121
08:43:18.365 -> X: 502
08:43:18.365 -> Y:-15878
08:43:18.365 -> Z:-1174
08:43:18.365 -> X: 534
08:43:18.365 -> Y:-15785
08:43:18.365 -> Z:-1160
08:43:18.365 -> X: 560
08:43:18.365 -> Y:-15875
08:43:18.365 -> Z:-1064
08:43:18.365 -> X: 465
08:43:18.365 -> Y:-15936
08:43:18.365 -> Z:-1248
08:43:18.365 -> X: 643
08:43:18.365 -> Y:-15920
08:43:18.365 -> Z:-1155
08:43:18.365 -> X: 374
08:43:18.365 -> Y:-15929
08:43:18.365 -> Z:-1380
08:43:18.365 -> X: 614
08:43:18.365 -> Y:-15904
08:43:18.365 -> Z:-1481
08:43:18.365 -> X: 430
08:43:18.365 -> Y:-15926
08:43:18.365 -> Z:-1203
08:43:18.365 -> X: 492
08:43:18.365 -> Y:-15846
08:43:18.365 -> Z:-1177
08:43:18.365 -> X: 452
08:43:18.365 -> Y:-15830
08:43:18.365 -> Z:-1308
08:43:18.365 -> X: 641
08:43:18.365 -> Y:-15881
08:43:18.365 -> Z:-1081
08:43:18.365 -> X: 456
08:43:18.365 -> Y:-15889
08:43:18.365 -> Z:-1203
08:43:18.365 -> X: 444
08:43:18.365 -> Y:-15798
08:43:18.365 -> Z:-1187
08:43:18.365 -> X: 564
08:43:18.365 -> Y:-15892
08:43:18.365 -> Z:-1507
08:43:18.365 -> X: 363
08:43:18.365 -> Y:-15857
08:43:18.365 -> Z:-1292
08:43:18.365 -> X: 467
08:43:18.365 -> Y:-15808
08:43:18.365 -> Z:-1513
08:43:18.365 -> X: 358
If you look at the timestamps, you will notice that im printing much faster than the timestamps are updating.
I was not able to confirm the exact amount of time Serial.print function takes but after some google search it seemes that it is less than 1ms.

I have not yet looked up sensor fusion or Kalman filtering. I think with SPI I can achieve high speed data rates ofcourse maybe not as fast as analog but fast enough for my application. However, I am now concerned about the accuracy of those devices and whether it is even possible to detect such small changes in distance ( im talking less than 1mm )
 
Top