Go Down

Topic: Can't get negative values from L3G4200D Gyro (i2cDev Library) (Read 647 times) previous topic - next topic


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: [Select]

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

L3G4200D gyro;

int16_t gyroX, minVal;

void setup() {

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?


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.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131