Some tuning ahead :)
October 2, 2008
Ok, so now the robot kind of works. It can stabilize for anytime when on some "helpful" ground, such as thick carpet or on my bed. When on the ground, it only last some seconds and then it fell to one side or the other, or start swinging badly.
Tonight i'm going to drill some more holes on the case to attach 3 potentiometer. One will control the center, that is, the value that indicates "up". It will be usefult to carefully tune which is the stable position.
The second will control how much to respond to the current angle. Too little, and the robot will not be able to catch up and will fall, too much and the robot will overcompensate and start swinging. This is the "Proportional" in the PID controller terminology
The third will control how much to respond to current angle rage (that is, the derivate or the angular speed, the D in PID). This must be taken into accoun too, becouse for a given robot angle, say 5°, corerction must be different whether it is falling (5° is increasin) or raising (5° is decreasing).
I might even add some kind of Integral correction in future, to have a complete PID system.
That wikipedia page also gives some very practical hints about manual tuning the system. It basically says: start with D and I parameter to zero, and increment P until your system oscillates with a stable way. Then, set P to half that value and start to increase D until the system is able to stabilize in a sufficient time, then start to increase I untill you get a fast enought response.
That's interesting, maybe i'll give it a try.
Btw i'm also planning to revamp the main robot page to make something cleaner :)