Pan-Tilt-Roll Compensator - Help!

Hi

My current project involves using an 6DOF IMU (http://www.sparkfun.com/products/10121) to compensate for movements in the pan, tilt and roll axis. My project comprises of 2 platforms, top and bottom platform. The top platform is stationary, while the bottom platform is allowed to move in the pan, tilt and roll axis.

Initially the IMU is located on the bottom platform, and it moves together with the bottom platform as it rotates around the pan axis. Thus the axis of the IMU is always aligned with the bottom platform, and I can fixed use the x-axis of the IMU for tilt compensation and y-axis for roll compensation. I have no problems with the tilt and roll compensation, except the pan compensation. When the IMU detects a movement(noise) in the pan axis, it attempts to compensate the noise by moving in the opposite direction, however at this point the IMU detects the compensation as a movement, and will try to "compensate the initial compensation". Thus it rocks back and forth continuously on the pan axis.

Thus, I decided to move the IMU to the top platform, which is stationary throughout. At this point, the pan axis compensation has no problem as the IMU does not move when the bottom platform is moving. However, there is now a problem with the tilt and roll axis. Since the IMU on the top patform does not move when the bottom platform moves, its axis is never aligned with the bottom platform. For example, at one instance I'll use the x-axis of the IMU to compensate for tilt, but when the bottom platform moves 90 degrees, I'll have to use the y-axis of the IMU to compensate for the tilt. Similar for roll as well.

Thus, as a summary my problems are as follows:

  1. Pan axis compensation when my IMU is located on the movable bottom platform.
  2. TIlt/Roll axis compensation when my IMU is located on the fixed top platform.

Any ideas on how to solve either of the 2 problems? Thank you so much!