2
\$\begingroup\$

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 ?

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\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\$ – geometrikal Nov 8 '11 at 7:09
0
\$\begingroup\$

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

if(abs(degrees(gyroRate[XAXIS]))>0.5) 
    rollAngle += degrees(gyroRate[XAXIS])*timeDiff/1000.00; 
if(abs(degrees(gyroRate[YAXIS]))>0.5) 
    pitchAngle += degrees(gyroRate[YAXIS])*timeDiff/1000.00; 
if(abs(degrees(gyroRate[ZAXIS]))>0.5) 
    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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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