I have heard a lot of different versions of what a PID loop is. I am going to post my version as taught to me by my PID coach when learning to tune and autopilot on a UAV. Also i am going to throw some tuning tips in as well.
P term -
The P term is like a big strong man on the steering wheel. He sees he is off course and muscles the steering wheel over in the direction he thinks he should be going. Nothing really accurate about it, just proportional to the obvious error that he perceives.
I term -
The I term is like your average backseat driver. He looks closer at the error they are off course and is tugging at the steering wheel gently... at first... to get back on course. But the longer he sees the error the more excited he gets and the harder he tugs.
D term -
The d Term is a very nervous individual. He doesn't mind so much that he is in error as he minds speeding past where he wants to be and having to go back. So he is constantly looking at how fast their collective goal is approaching and is fighting both the P-strongman and the I-backseat driver to prevent them from overshooting their target.
Now for a little tuning tips...
Start Small -
Use very small Control values. Forget about the D term for now. it will only cause you grief until you get some solid results from the P term .
Set your I term low as well. Especially if you expect large errors to occur. Remember that the I term is adding up all the error and when he is in error for any length of time he will exert a very strong powerful force on whatever you are controlling. I think an error limit routine in your code with help deal with this. For instance if you are flying a UAV, and you want to change altitude. You would, of course add power. Well how fast does your overloaded uav climb? If you went from 500 to 600 feet it might take a few minutes. Meanwhile your PID loop has made 6000 readings in the last second! Now lets send the UAV to 3000 feet! See what I mean?
Change one thing at a time -
Don't get carried away changing ten different values in your PIDs. You will go crazy. Enough said.
Set your trims -
On a UAV you want to trim the aircraft to fly staight and level before you start telling the autopilot how to fly it. Remember that a PID controlled anything works on error. Environmental factors will give you enough to overcome without throwing in some error on your own.
Nested PIDs -
Sometimes you want to use nested PID loops. Example is my heading control routine. If i pass the PID turn values directly to my rudder I could get some really high turn rates. So I nest that PID inside my turn Rate PID. So my heading PID gives me a suggested turn rate that I check against my maximum allowed turn rate. If the PID suggests a turn rate of 15 I set it back to 7 (i like a turn rate of 7 degrees per second and that is my set Maximum) then i pass that to my Turn rate PID. My turn Rate PID checks the YAW rate gyro and then calculates how much rudder is added or reduced to satisfy the suggested turn rate from the Heading PID.
Record Everything -
I don't mean video Camera either. Record all of your data. In a UAV I record the ALT, desired altitude ,AirSpeed, Desired airspeed, Heading, Desired Heading, and all the servo positions.
Why you may ask? Duh! For tuning!!
You can easily write software or use excel to 'see' what the aircraft or whatever your controlling is doing. this makes it sooooooo much easier to tune!
Now, if you are feeling froggy -
Design your device with real time tuning i.e: Write it so you can chage you PIDs on the fly...literally! Flying a UAV is risky at best. If you have to launch and recover your UAV a hundred times to tune it you risk killing it a hundred times. It is best to have two people to tune a UAV. one to fly and one to upload new PID terms and then release the bird to the autopilot to see what happens. When you are satisfied (or not) give the pilot control again and make changes.
Accelerometers and Kalman filters -
you would be really surprised how well a UAV can fly if the aircraft is inherantly stable. you definately need to kill the noise on your gyros because these will be needed for turn rates and envioronmentally induced roll (Wind gusts and air pockets). Do you really need to know the attitude of the aircraft if the aircraft at zero with fly straight and level? Remember, if you want to use all the positional data on your aircraft then be prepared to isolate the autopilot gyros and Accelerometers from the vibration from your Fuji boxer 4 stroke engine 9 inches away!
When you tune the UAV correctly the aircraft with fly without all that extreme math and do well with just you PIDs cranking away.
Good luck! Try not to make new craters with your UAVs