I have built a self-balancing unicycle that uses a Sparkfun 6dof digital IMU (ITG3200 gyro/ADXL345 accelerometer) that communicates via I2C, an Uno, and a SyRen 25 motor driver which runs a 24v scooter motor. The machine balances well and is somewhat ride-able, but once it is moving, the angle measurement changes from what it should read. It doesn't wildly oscillate, but changes somewhat smoothly. A bench test revealed that the effect increases as the power output increases. If I hold the Unicycle at a constant angle with the wheel off the ground, the power output will rise and fall. This is a major problem while riding, because it will accelerate and decelerate randomly making it difficult to keep under control. I initially thought that vibration was the culprit, but after some testing, I'm nearly certain it is some kind of electrical interference. I have done plenty of debugging and I am certain that my code isn't causing the issue because it operates flawlessly when the motor isn't running.
The Arduino and IMU are running on a separate battery while the motor controller is powered by two 12v batteries in series. The only connection between the Arduino and motor controller is the serial lines. Could this be the source of the noise? Otherwise it must be coming through the air. It could be coming from the motor controller (which is right next to the Arduino), the numerous power wires running through the project box, or the electric motor itself. How can I protect these electronics from interference? Also, is the Arduino itself susceptible to interference issues? Thanks.
Here is a picture of my setup. The IMU is on top, the motor driver is on the left, and the Arduino is behind the mess of wires.