I ran into a very strange issue. I'm trying to do a gyro angle drift compensation. Before the compensation, I saw there was about 67 degree drifting every hour. But after I did the compensation, the drifting became crazy, it's 30 degrees per second. >:(
In general it is much easier to find problems if you post your whole code, or at least a shortened version that still exhibits the problem.
Make sure you post it in code tags.
Your code will also be easier to read if you use more meaningful variable names, e.g.
But the real problem is that each loop you are adding the change in angle based on the gyro reading and the recent time interval, and then subtracting the total expected drift that has occurred from the start, not just the expected drift from the latest interval.