Pages: [1]   Go Down
Author Topic: Can't get negative values from L3G4200D Gyro (i2cDev Library)  (Read 411 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using a GY80 with an Arduino Due for a quadcopter project, which has a L3G4200D gyroscope. I've been trying to calculate pitch and roll but I just noticed something I'm not sure is correct. Basically the values for the gyroscope never go below zero. I though it was supposed to be positive values for clockwise rotation and negative values for anti-clockwise.

Below is a sample bit of code. I'm using the I2Cdev arduino library.

Code:

#include <Wire.h>
#include <I2Cdev.h>
#include <L3G4200D.h>

L3G4200D gyro;

int16_t gyroX, minVal;

void setup() {
  Wire.begin();
  Serial.begin(115200);
  gyro.initialize();
  gyro.setFullScale(2000);
}

void loop() {
  gyroX = gyro.getAngularVelocityX();
  minVal = min(minVal, gyroX);
  Serial.print("Raw: "); Serial.print(gyroX);
  Serial.print(" Min: "); Serial.println(minVal);
}



Is this working correctly? Am I doing something wrong?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just updating this for anyone with the same issue, I tried out the https://github.com/pololu/L3G/tree/master/L3G library instead of the i2cdev library and I'm now getting values between -65,535 and 65,536 with negative values for anti-clockwise rotations.

There's either an issue in the i2cdev library for the L3G4200D or I was just using it incorrectly.

Logged

Pages: [1]   Go Up
Jump to: