ADXL 345 calibration

Hello,
I'm using ADXL 345 accelerometer with an Arduino Leonardo.

Everything looks fine but i am having problems with the 3-axis 1g-values.
When i set range to +-2g the 1g values should be like 255/256 but i receive this:

x-axis:
+1g: ~262
-1g: ~-253

y-axis:
+1g ~268
-1g ~-256

z-axis:
+1g; ~220-225
-1g: ~-280

the 0g values are good too so i cannot just add a calculated offset. Does someone of you know why the z-axis values are that bad or how i can filter this deviation?

static int16_t read16(uint8_t reg)
{
  Wire.beginTransmission(ADXL345_ADDRESS);
  i2cwrite(reg);
  Wire.endTransmission();
  Wire.requestFrom(ADXL345_ADDRESS, 2);
  return (int16_t)(i2cread() | (i2cread() << 8));
}

static uint8_t i2cread(void)
{
  return Wire.read();
}

i appreciate your help
daniel

Hey

I don't think it's a problem ...... after you calibrate you calibrate and scale the adxl345 readings

Go to page 35 of 40 in the link below and try all the orientations and make sure you get the correct reading from the adxl345.

http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf

Good luck ......................

thats what i did.
i display the values in m/s² thats the result:

x: 0-0,3 m/s²
y: 0-0,15 m/s²
z: 9,7-9,9 m/s²

thats fine but when i turn the board on the x-axis:

x: 0-0,3 m/s²
y: 10,7 - 10,9 m/s²
z: 0,1-0,4 m/s²

static double getYa(int count)
{
  double y_val = 0;
  for (int i = 0; i < count; i++)
  {
    y_val += read16(ADXL345_REG_DATAY0); 
}  
  return (y_val * ADXL345_range * 9.81 / (512 * count));
}

redo your calibration and compensate the sensor correctly ....

i am sorry i cant help much as i am also a beginner.

For best results all accelerometers and magnetometers should be recalibrated frequently using a robust procedure. There will be a different gain and offset along each axis. For magnetometers there is often also a rotation, especially if something in the environment is distorting the local magnetic field.

Here is my favorite, described for magnetometers, but it works equally well for accelerometers providing the sensor is held as still as possible while each data point is taken. Sailboat Instruments: Improved magnetometer calibration (Part 1)