PID Tuning in a Nearly Finished Ball-Balancing Robot

Hi All,

I'm getting close to the close of my senior project (About 5 weeks out as of now). It's a 3 wheel Ball-Balancer like this one:

Mine is going quite well and a freshly posted video of my current status can be seen here:

I'm mostly interested on people thoughts on PID tuning... I'm using the common "parallel" form:

My current gain values are:

P = 1450
I = 14750
D = 26
I limit = 100

The error is in degrees of tilt referenced to 0 (i.e: no tilt). I'm curious what people who have experience in PID tuning think of the blend, seem like a lot of "I" based on what I've read. If I go any higher with "P" or "D" I get instability. Less "I" down to about 7000 is a bit less stationary... less than that and the robot starts to lean and run off. That's what I would think the important details are but I can post lot's more info if it would help.


Well, I thought about it a bit and I'm not longer concerned about the huge difference in numbers. I realized that most people tuning a loop with a constant loop time exclude the "*dt" for the integral and the "/dt" on the derivative. Since my loop time is .02 seconds that explains why I need huge I values before they have an impact and why very low D values seem to have a huge effect.

I'm still looking to hear other thoughts about the performance you see in the video, or alternative methods to tuning. I'm playing with the Idea of using an exponent on the error to put a curve on the performance of the PID loop. The idea being that it would allow gentler values when the tilt error is below 1 degree and more aggressive response at larger errors much more rapidly. I'll try it shortly...



I have no experience with PID, however have read about a sine equation (thing) being used to smooth an acceleration for a stepper, so what you have described sounds similar, and logically makes sense to my mind.

You might want to check out the Twiddle Algorithm!/c-cs373/l-48743150/m-48700486 as shown by Sebastian Thrun in his Udacity class CS-373 Artificial Intelligence for Robotics. Algorithm finds the optimum values for the P/ I/ D parameters in a PID-control algorithm.

I am wondering if you could do the same thing as twiddle, but using a binary search, by establishing (sane / common sense) starting upper and lower limits in the code and then detecting failure - in this case not balancing == falling vs balancing.

You could store values in the eeprom to track your changes and once the process is finished you'd have your best values ready for restart.