Thanks to Patrik for getting this subject going again. I am in dire need of help......
Ok, so I've built a couple of balancing robots but have yet to achieve 'balance'. I'll post photos and video clips later (am at work), but for now I'd like to fish for advice given I get the same problem irrespective of code/hardware changes.
I've used code from a few sources, but am currently testing KbotV1.1 which I've managed to adapt to my setup.
I've used sparkfun IMU's, but am currently using the one from gadgetgangster.
I've used Pololu 300rpm motors, but have just switched to a couple of 300rpm planetary gear motors I sourced locally in the UK (E192.12.13
So, my problem seems to be that when I have the gain high enough so that it can pick itself up to the point of low freq oscillations (overshoot) I seem to get an additional high freq oscillation which I _think_ seems to be caused by motor/gearbox backlash. It's like the robot is bouncing off the backlash points.
I have fitted an LED on my robot which basically will be on when driving forward and off when driving backwards......this LED will flash rapidly. I also scoped the PWM output and you can see the 'chatter' in the output.
It's almost as though the gyro/accel signal is noisy.
So, I raised the robot off the ground and have it sitting perfectly vertical and very stable/fixed. If I leave the main loop scan at 9mS then the chatter is noticeable, but the more I reduce it the better it gets.
So believe it or not I overclocked my Arduino to 28mHz and got the main loop down to less than 2mS and it's better but still there.
No matter what code I use (i've tried a good few from various sources and including writing my own) the problem is always the same. I've played with the PID settings, I've replaced the PID code with others I've found.
I've written my own interrupt routines to fix the scan time of all the subroutines not just the main loop.
I've tried different sized wheels, weighted the robot differently, moved the IMU central to the axle.....everything.
I guess a video will speak a million words, so I'll upload one tonight.....for now here's where my test code lives:-http://www.ianjohnston.com/content/images/stories/IanJ/Segway/Code/