Electronic – arduino – Gyro Angle calculations isn’t precise

analogarduinogyro

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;
    gyroRotation=gyroRotation+gyroRate*dtime1/1000;
    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 ?

Best Answer

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.