# Calibrating gyro

Hey people im trying to get a gyro upp and running by making a code so i found a good referance in Joope brooking. But the gyro gets a drift and this is his solution, but in my mind his pitch/roll/yaw calculated is the avrege and not the offsett. Can annyone please tell me im wrong and why?

The function im talking about is the last (void compute_gyro_offset)

The code is utter nonsense.

Gyros drift, which means they report some angular rotation rate (not angles) even when held still.

You calibrate a gyro by holding it still, collecting a few hundred measurements on each axis, and average them.

That average will be the offset that you subtract from the measured rates later.

The problem with gyro drift is that it changes with time and temperature, so you have to calibrate frequently.

Hehe, it looks like you looked on the upper and not the lower

But thanks because the lower is just ass you described it sould be

You can eliminate random error by taking multiple measurements during the actual event to increase the confidence interval of the sample mean.

Secondly, you need to calibrate by taking a large sample number of readings when the gyro is at the true value of (0,0,0 xyz) and then use this to compensate for the bias in the instrumental innacuracy to give "calibrated" readings.

The device may not have a linear bias. Ideally, you would place it in a 3D rotation device and calibrate for all known angles and use a LUT...but that would be some major coding/work and even then...temperature, magnetic and RF interference would also cause potential inaccuracies.

Tanks for the ansers, but what im left wondering now is how to combine the data from the gyro and accelerometer (yess a complimentary filter), but the gyro gets me angular rate and the accelerometer G force (that i guess i could get angels from). But i dont get the total transission and would be gratefull if annyone could explain