I'm using this LISY300AL Gyro: DataSheet

But i cant get a precise data..

Here is my calculation:    

    sensitivity = 0.716454545;
    gyroAdc = analogRead(0);
    if(abs(gyroAdc - gyroZero) <= Threshold)
      gyroAdc = gyroZero;
    gyroRate = (gyroAdc-gyroZero)/sensitivity;
    gyroAngle = abs((gyroRotation - 360 * ceil(gyroRotation / 360))); // Round up between 0-360
    dtime = millis() - stime; // millis() is the milliseconds since my controller started
    stime = millis();

I dont get a precise angle, i move my object 90 degrees but the gyro drifts too much so it showes something else...

Maybe i'm doing something wrong ? or i should just add an Accelerometer to make it more precise ?


2 Answers 2


I didn't look at your datasheet, but cheap gyros (not 10s of 1000s of $) inherently get a signal proportional to the rate of turning. To get angle, this must be integrated. Any error in the rate signal therefore accumulates over time. Cheap MEMS gyros have drift and accuracy such that angle is pretty meaningless after a few seconds.

Real mechanical gyroscopes work on a totally different principle which keeps the axis pointing in the same direction. These therefore provide true angle outputs, not angle rate of change, so are more useful for inertial navigation.

Accellerometers can give you absolute angle magnitude with respect to gravity if you know the object is not otherwise accellerating. However, that is only angle with respect to down. They won't help you determine angle of turning sideways, for example.

  • \$\begingroup\$ Great explanation. Just wanted to comment that the LSM303 chip contains both an accelerometer and magnetometer and could be useful to get both pitch and heading. Pololu has a good module for Arduino. \$\endgroup\$ Commented Nov 8, 2011 at 7:09

In order to avoid this drift in my gyro, I added if statements to filter out the drift. Something like this:

    rollAngle += degrees(gyroRate[XAXIS])*timeDiff/1000.00; 
    pitchAngle += degrees(gyroRate[YAXIS])*timeDiff/1000.00; 
    yawAngle += degrees(gyroRate[ZAXIS])*timeDiff/1000.00;

So, when the gyro's rate is less than +/- 0.5 (usual drift of gyros) it will not update the the angle.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.