Here is some calibration code I found here on Chielf Delphi. It basically involves adjusting the sensitivity with the gyro sitting still so that it doesn't change. It seems to help, although I don't know how accurate it was after changing the sensitivity.
Code:
void CalibrateGyro()
{
// gyro should be out of cal mode by now,
// try to find and set best sensitivity
float fAngle;
for(int uLoop = 0; uLoop < 10; uLoop++)
{
float fAngleSensitivity = Gyro::kDefaultVoltsPerDegreePerSecond;
bool bLastAdjustmentWasIncrease;
// reset the accumulator, stop a while and see if we drifted
gyro.Reset();
// taskDelay(sysClkRateGet() / 4);
Wait(.001);
fAngle = gyro.GetAngle();
if(fAngle > 0.0)
{
fAngleSensitivity -= 0.0001;
bLastAdjustmentWasIncrease = false;
}
else
{
fAngleSensitivity += 0.0001;
bLastAdjustmentWasIncrease = true;
}
gyro.SetSensitivity(fAngleSensitivity);
if((fAngleSensitivity > 0.0) && (bLastAdjustmentWasIncrease == false))
{
// we were adjusting up then went down a step - good enough
break;
}
else if ((fAngleSensitivity < 0.0) && (bLastAdjustmentWasIncrease == true))
{
// we were adjusting down then went up a step - good enough
break;
}
if((fAngleSensitivity >= (Gyro::kDefaultVoltsPerDegreePerSecond + 0.0008)) ||
(fAngleSensitivity <= (Gyro::kDefaultVoltsPerDegreePerSecond - 0.0008)))
{
// the next number would be outside any reasonable value according to the datasheet
break;
}
}
gyro.Reset();
}