hi,
very nice!
from this analog perspective I dare to assume:
Wait 1-2 minutes from the start for the offset to settle,
then calculate 1 gyro unit in dependency from the gliding voltage average (of 3) ,
and squeeze the resulting sensor values through a median filter (of 3).
I think I'll take a rest from the gyro investigation for now, so just a few points.
I have found a quite successful way of auto-calibrating the gyro zero offset, using a floating average with the last 10 readings. If the average over the last ten readings is less than one degree, I assume that the sensor is not moving, and I'll let the offset slowly converge towards the current zero point. With this method, the compass stays stable for about a minute or so. (I am of course also using the battery voltage to get an approximation of the zero point).
Another problem has emerged: As Aswin pointed out, we probably cannot assume that the gyro readings are neither linear nor independent of external factors. Just as with the offset, the rotation reading appears to vary with the battery voltage. It looks like the readings are lower at high voltage, and high at low voltage: When I slowly rotate the sensor 90º with fresh batteries, the integration shows about 85º, whereas used batteries would show 95º. This reading varies a lot, and depends quite a bit on the rotation speed, but it is not caused by the zero offset calculation.
As I mentioned before, I'll take a break from the gyro sensor and concentrate on other issues with my robot. I anyone here would like the source texts to play with, I'll post the latest version here, just ask.
Thank you for all the valuable comments and feed-back!