theFPVgeek / aeroquad

Automatically exported from code.google.com/p/aeroquad
0 stars 0 forks source link

Mag calibration values in 5883L Compass class for X and Y are crossed #144

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The sensor read code from the 5883L compass class reads as follows:

    #if defined(SPARKFUN_9DOF)
      // JI - 11/24/11 - SparkFun DOF on v2p1 Shield Configuration
      // JI - 11/24/11 - 5883L X axis points aft
      // JI - 11/24/11 - 5883L Sensor Orientation 3
      measuredMagX = -((Wire.receive() << 8) | Wire.receive()) * magCalibration[YAXIS];
      measuredMagZ = -((Wire.receive() << 8) | Wire.receive()) * magCalibration[ZAXIS];
      measuredMagY =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[XAXIS];
    #elif defined(SPARKFUN_5883L_BOB)
      // JI - 11/24/11 - Sparkfun 5883L Breakout Board Upside Down on v2p0 shield
      // JI - 11/24/11 - 5883L is upside down, X axis points forward
      // JI - 11/24/11 - 5883L Sensor Orientation 5
      measuredMagX =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[YAXIS];
      measuredMagZ =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[ZAXIS];
      measuredMagY =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[XAXIS];
    #else

Should be:

    #if defined(SPARKFUN_9DOF)
      // JI - 11/24/11 - SparkFun DOF on v2p1 Shield Configuration
      // JI - 11/24/11 - 5883L X axis points aft
      // JI - 11/24/11 - 5883L Sensor Orientation 3
      measuredMagX = -((Wire.receive() << 8) | Wire.receive()) * magCalibration[XAXIS];
      measuredMagZ = -((Wire.receive() << 8) | Wire.receive()) * magCalibration[ZAXIS];
      measuredMagY =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[YAXIS];
    #elif defined(SPARKFUN_5883L_BOB)
      // JI - 11/24/11 - Sparkfun 5883L Breakout Board Upside Down on v2p0 shield
      // JI - 11/24/11 - 5883L is upside down, X axis points forward
      // JI - 11/24/11 - 5883L Sensor Orientation 5
      measuredMagX =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[XAXIS];
      measuredMagZ =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[ZAXIS];
      measuredMagY =  ((Wire.receive() << 8) | Wire.receive()) * magCalibration[YAXIS];
    #else

Note the swapping of the X and Y axis magCalibration values

Original issue reported on code.google.com by ihle...@gmail.com on 1 Dec 2011 at 7:04