This is more of a theory question than one specific to the arduino, I hope this is the right sub for such a question.
I have just finally gotten my 3 axis gyroscope working, and I must say it's a thing of beauty. Its there not making a peep in serial, and then rapidly streams the updated degrees from start (NOT speed!), stopping suddenly at 89-91 as my breadboard squares the other side against the table.
Now that I have that working accurately, I will be adapting it for smoothing the tilt correction on my compass, that's currently relying solely on an accelerometer. (they're a bit jumpy, the gyro should REALLY smooth things out)
But I foresee a snag, in a gyroscopic effect that maybe I should have foreseen. I can spin this thing all around and it does a very good job of holding position, usually within a degree or two, as long as it's only turned on one axis at a time. When I "swirl" it, it does exactly what I would expect a gyroscope to do. It rotates the entire system.
Let me make sure you understand what I mean when I say "swirl". Imagine a cone with the tip pointed down and the bottom circle facing up. The vertial surface of the cone is made up of lines that go up from the tip to all around the circle. Imagine the gyroscope placed at the tip, with the body of the gyro being moved in a swirling motion such that the top center of the gyro is facing exactly an edge of the circle above it. Sorry, it's difficult to explain.
But if you try that with a gyroscope, you will notice as you twist, it torques itself at 90 degrees to the angle it's spinning and the angle you are moving. There's a name for that effect I'm sure someone will drop soon but I can't recall it right now. (you really need to be familiar with this when working on RC helicopters, that's really important for how the head is controlled) Anyway, when you finish your swirl, the gyroscope's ends won't be in the same alignment they were before. The axis of the gyro wlll be changed.
And that's what my gyro is doing too. After a swirl, the Z axis, which should be back at 0, is now maybe a 70. Now I intend to use this compass to keep track of north on a piece of handheld gear as the user is walking around on uneven ground, not paying too much attention to the physical orientation of the gear, and the gear needs to be continuously aware of north, as accurately as possible. This is why the tilt compensation is critical. I don't expect the user to be "swirling" the gear, but I foresee this causing problems with the tilt correction. I'm going to be using the simpler (non kalman) method that basically figures current tilt based on 98% of the previous angle + the change in the gyro, + 2% of the accelerometer. Given the large influence the gyro will have, I think I need to keep it as accurate as possible.
I hadn't really expected this snag with the gyro. The entire thing has really been stacking up on me. Got a compass. ok need to correct that with an accelerometer. ok need to correct that with a gyro. Now I need to correct that too??! Ideas? (and sorry for the long post)