Jump to content
I2Cdevlib Forums


  • Posts

  • Joined

  • Last visited

brundylop's Achievements


Newbie (1/14)



  1. I think I got it! Looking at the MPU6050.cpp code in the library, there are 2 Gyrofunctions: getXGyroOffset and getXGyroOffsetUser after re-declaring the offset inputs as int16_t and using setXGyroOffsetUser made the difference. It converges now!
  2. Hi everyone, Even after updating my I2C library like StrayVoltage suggested in#35, the sketch does not converge for me. I think I've found the underlying problem in my setup: setXGyroOffset (and the Y,Z functions too) cannot handle negative inputs. In my code, I declare: accelgyro.setXAccelOffset(-1); accelgyro.setYAccelOffset(-1); accelgyro.setZAccelOffset(-1); accelgyro.setXGyroOffset(-1); accelgyro.setYGyroOffset(-1); accelgyro.setZGyroOffset(-1); But then when I read them out with Serial.print(accelgyro.getXAccelOffset()); Serial.print(accelgyro.getYAccelOffset()); Serial.print(accelgyro.getZAccelOffset()); Serial.print(accelgyro.getXGyroOffset()); Serial.print(accelgyro.getYGyroOffset()); Serial.print(accelgyro.getZGyroOffset()); I see -1 ; -1; -1 ; 63 ; 63 ; 63 That is, the accelerometer is able to handle negative inputs, but the Gyroscope functions freak out and change -1 to 63. I think this has to do with negative representation (63 = 111111 in binary) but what's odd is that 64 is a 6 bit number, not 8 or 16 That's why my sketch doesn't converge. It seems like the sketch is trying to add negative numbers when the readings are positive, so that the sum is 0. But instead of adding a negative number, it is positive; thus the indefinite cycling. I am looking into how to fix this, but my programming background is still crappy: edited to add my system: I'm using a Teensy 3.2 with the SparkFun 9150 breakout board, with both the old and new I2C dev libraries. ( I need to comment out Wire.h in my calibration.ino code because of conflicting libraries) I still see the same problem when I use my Arduino Uno instead of the Teensy
  • Create New...