In a system with only a gyro, what is the best way to compensate for zero offset? I have tried a number of ways to collect measurements for a number of seconds, and then determine the resting angle rate, and then apply that to each measurement for correction. There is always a remaining angle rate which I haven't succeeded in compensating out. What am I missing?
The most simple method of computing GYRO offset is spinning several times and then taking an average of at-rest numbers. I assume this is what you are doing but you are not satisfied with the result. Using the above method the bulk of the error should have been removed.
How much residual error are you seeing? This may be an orientation-dependent offset and require an Accel/Mag for further correction. You may refer to NXP Sensor Fusion, in which the gyro offset is computed automatically and the Kalman filter should indicate the output. However, please note that NXP's algorithm uses all available sensors and the Code for the algorithm is not trivial and requires detailed understanding.
I was doing exactly what you said, but without the spinning several times. I will try that to see how it works. Thank you for the suggestion. I am using the sensor with the IC mounted on a board which is vertical. The Z axis is horizontal in my application. I don't know whether that has an impact on what I get out of the X axis.
Because I don't have any of the other sensors, I didn't try to dig into the sensor fusion software. That can come later if it becomes required, along with a re-spin to add at least an accelerometer.
One more update. Motion prior to collecting data while stationary does seem to help a little, but more accuracy was gained (using motion or without) by extending the sampling time. I now sample for 30 sec which greatly improved accuracy of the calculated bias factor. I observe that there is a low-frequency component of the bias which needs some time to be collected in the summation for the bias factor. Thank you for your help!