# Gyro not zero when returning to original position after random rotations

I am currently trying to make a self balancing robot. Making good progress but stumbled across an issue.

My gyroscope readings do not return to zero if I return in to its original position after random rotations around all 3 axes. Meaning rotation when all angles are not zero.

I am confident this issue is not caused by accuracy of the numerical integration as I have tried jerking the sensor incredibly hard around 1 axis, yet it still returns to 0 when rotated back.

I managed to get the gyro to return to zero when rotating around 1 axes when 1 angle is not zero. Meaning if Y is 45, and I rotate Z 90 degrees, I can transfer the Y angle to X, and once I return all angles back to zero individually, I can return to the original position. I've done this for all 3 pairs of angles (XY, XZ, YZ) and tried to add all 3 equations but the end result does not zero the gyro.

Anyone know any resources that I can look up on, or any idea of what the solution could be? Any help is appreciated.

• what happens if your code reads and processes only one of the axes? – jsotola Jun 24 '18 at 18:37
• You mean to see if that axis returns to 0 after random rotations in all 3 axis? If it's just rotation in that axis, without my attempt to correct 2 axis, it will return to 0. The main issue I need fixed is when the vehicle is vertical, XYZ rotation is set to Z. As the vehicle tries to balance, it will end up rotating a bit as well because I don't have speed encoders yet. When it's tilted along Z and rotates around the vertical axis, the 0 of Z will shift, then the vehicle will try to maintain a forward tilt instead. – potango Jun 24 '18 at 23:56
• Which Arduino board, what sensor, which libraries, what sketch do you use? how is the sensor connected? I would try to jump out of this problem by buying another sensor and using other code. Perhaps even make a leap forward and use a bno055. – Jot Jun 25 '18 at 3:45